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

Reply
 
Thread Tools Search this Thread Display Modes
Old 1st April 2023, 11:36   #2281  |  Link
Dogway
Registered User
 
Join Date: Nov 2009
Posts: 2,255
LeXXuz, try now, I updated SMDegrain with some improvements. First unprocessed planes are copied from input to mfilter clip when using mfilter obviously, this makes more sense.
Also multi (tr > 6) happened to don't be correct for some modes like LFR, mfilter or mode!="MDegrain", that is fixed now, and also with nice for loops, so less code lines.

About SceneStats that's a delicate issue due to the complexity of the filter. First I'm taking things slower now, and second I decided to wait until the issue happens to me again instead of searching for it, but it's acknowledged and will tackle with it when that happens.

DTL, do you have literature about this approach (covariance for texture/sharpness metrics)? What variables would covariance employ in this case?
__________________
i7-4790K@Stock::GTX 1070] AviSynth+ filters and mods on GitHub + Discussion thread

Last edited by Dogway; 1st April 2023 at 11:45.
Dogway is offline   Reply With Quote
Old 1st April 2023, 13:37   #2282  |  Link
LeXXuz
20 years and counting...
 
LeXXuz's Avatar
 
Join Date: Oct 2002
Location: Germany
Posts: 680
Thanks Dogway, updating now.

I don't know if that would be any simpler, but if you could just disable that error overlay that would be a big help already.

Otherwise I'll wait with these sources, no problem at all. Enough other stuff to work on from my collection.
LeXXuz is offline   Reply With Quote
Old 1st April 2023, 14:54   #2283  |  Link
Dogway
Registered User
 
Join Date: Nov 2009
Posts: 2,255
I don't think it's that easy, as I said the filter is quite complex, and even if I fix the eventual errors (at least the ones I was having) fades in/out will still need to be trimmed out. If someone comes up with a fade detector that would be welcomed.
__________________
i7-4790K@Stock::GTX 1070] AviSynth+ filters and mods on GitHub + Discussion thread
Dogway is offline   Reply With Quote
Old 1st April 2023, 15:36   #2284  |  Link
LeXXuz
20 years and counting...
 
LeXXuz's Avatar
 
Join Date: Oct 2002
Location: Germany
Posts: 680
Quote:
Originally Posted by Dogway View Post
I don't think it's that easy, as I said the filter is quite complex, and even if I fix the eventual errors (at least the ones I was having) fades in/out will still need to be trimmed out. If someone comes up with a fade detector that would be welcomed.
Okay, no problem. And thanks for the suggestion with Expr() and ex_lut() for mfilter preview. They show way better which areas are processed.
LeXXuz is offline   Reply With Quote
Old 1st April 2023, 16:55   #2285  |  Link
DTL
Registered User
 
Join Date: Jul 2018
Posts: 880
"do you have literature about this approach (covariance for texture/sharpness metrics)? What variables would covariance employ in this case?"

Covariance is major part of most 'complex' metrics (more complex in compare with 'simple' SAD). SSIM and VIF widely uses covariance component. SSIM have 'structure' part based on covariance and VIF also uses covariance in output computing formula. You can look into SSIM and VIF computing functions in mvtools to see how it calculated from blocks arrays samples:

SSIM https://github.com/DTL2020/mvtools/b...MFunctions.cpp

Full SSIM is SSIM_Light * SSIM_Contrast * SSIM_Structure . SSIM_Light is sort of simple average of samples. SSIM_Contrast is some function of (variance_a, variance_b) where variance_a is fsX and variance_b is fsY at https://github.com/DTL2020/mvtools/b...ctions.cpp#L57

And SSIM_Structure is function of covariance(a,b) (fsXY) - https://github.com/DTL2020/mvtools/b...ctions.cpp#L66 . And after getting all 3 components of SSIM output is simple multiplication.

But for some specific analisys each part of SSIM may be used separately. Most interesting for textures may be SSIM_Structure calculated from covariance.

VIF is https://github.com/DTL2020/mvtools/b...FFunctions.cpp

It uses covariance of DWT - https://github.com/DTL2020/mvtools/b...ctions.cpp#L66 (DWT_a component) for VIF_A part and also some covariance for VIF_E part - https://github.com/DTL2020/mvtools/b...ctions.cpp#L98

It may be possible to convert C-computing to AVS scripting computing and you can make full or structure-only SSIM in AVS function.

The VIF DWT-based require DWT (it is not complex but more slow). The most diffrerence between SSIM and VIF for structure part is SSIM compute from direct input blocks samples covariance and VIF compute covariance from DWT-transformed blocks (may be sort of low-pass filtering or twice reducing ?).

Last edited by DTL; 1st April 2023 at 17:05.
DTL is offline   Reply With Quote
Old 1st April 2023, 18:17   #2286  |  Link
Dogway
Registered User
 
Join Date: Nov 2009
Posts: 2,255
Thanks for the links, I will have a look later. If none of covariance components come from a texture analysis it would be a moot point. I have SSIM ported to a function in SimilarityMetrics, but I don't recall any texture extraction.
VIF doesn't sound familiar to me so will have a look (EDIT: ok, VIF -Visual Information Fidelity- from my metrics issue). DWT is frequency based so that might be useful.

The problem probably with blocks is that small details vanishes from the block average, unless augmentation is performed, that or dynamic sized blocks come into play like x265.
__________________
i7-4790K@Stock::GTX 1070] AviSynth+ filters and mods on GitHub + Discussion thread

Last edited by Dogway; 1st April 2023 at 18:19.
Dogway is offline   Reply With Quote
Old 1st April 2023, 18:48   #2287  |  Link
Boulder
Pig on the wing
 
Boulder's Avatar
 
Join Date: Mar 2002
Location: Finland
Posts: 5,610
For visualizing the effect of filters outside MDegrain, I've used the Subtract method like Subtract(finalclip_nonblurred, finalclip.mergechroma(finalclip_nonblurred)).levels(127*256, 1, 132*256, 0*256, 255*256).subtitle("Effect of blur in result", y=40). Here 'finalclip' is the normal output, finalclip_nonblurred the one where there is no denoising other than MDegrain and then I just want to see how luma looks like so the chroma planes are merged from the normal output.

Funny thing is that the filter gets quite a big weight even if you use something like thsad=10000 in MDegrain, it won't change the output much if you limit the effect of MDegrain itself. I was always under the impression that thsad can be used to control which parts of the frame get processed by MDegrain and which parts are skipped because the calculated thsad is too high.
__________________
And if the band you're in starts playing different tunes
I'll see you on the dark side of the Moon...
Boulder is online now   Reply With Quote
Old 1st April 2023, 19:39   #2288  |  Link
DTL
Registered User
 
Join Date: Jul 2018
Posts: 880
" If none of covariance components come from a texture analysis it would be a moot point. "

Covariance in SSIM is direct math covariance between samples of compared blocks. It shows how the samples of the compared blocks changes in similar way at each sample. If one block is blurry and second is sharp (non-damaged by blur) - the covariance metric will be lower.

Covariance is
fsXY += (float)((pWorkSrc[x] - isuX) * (pWorkRef[x] - isuY));
- sum of multiplication of (blocks values - mean block value (mean DC component)). So if samples changes in same direction from mean value - the mul operation gives higher result. Also it is positive for both positive and negative difference from mean value (DC) if both differences have same sign.

So if some processing start to damage texture in compare with 'initial source' - the covariance metric become lower and it can be detected and the processing may be adjusted to keep texture more non-damaged. Also the processing may be optimized (zopti ?) to maximize covariance metric between input and output.

Last edited by DTL; 1st April 2023 at 19:49.
DTL is offline   Reply With Quote
Old 1st April 2023, 19:46   #2289  |  Link
LeXXuz
20 years and counting...
 
LeXXuz's Avatar
 
Join Date: Oct 2002
Location: Germany
Posts: 680
Quote:
Originally Posted by Boulder View Post
Funny thing is that the filter gets quite a big weight even if you use something like thsad=10000 in MDegrain, it won't change the output much if you limit the effect of MDegrain itself. I was always under the impression that thsad can be used to control which parts of the frame get processed by MDegrain and which parts are skipped because the calculated thsad is too high.
I think without raising thSCD as well you will not do much, even with thSAD that exorbitant high, since every frame is probably considered a scene change now?
LeXXuz is offline   Reply With Quote
Old 1st April 2023, 23:07   #2290  |  Link
Boulder
Pig on the wing
 
Boulder's Avatar
 
Join Date: Mar 2002
Location: Finland
Posts: 5,610
Quote:
Originally Posted by LeXXuz View Post
I think without raising thSCD as well you will not do much, even with thSAD that exorbitant high, since every frame is probably considered a scene change now?
thSAD is not directly connected to scene change detection, you can use a higher thSAD value than thSCD1 and the frame will still show motion vectors with MShow (which is very useful with showsad=true). As far as I know, thSCD1 sets the threshold (per block) and thSCD2 then sets the max amount of blocks triggered by thSCD1.
__________________
And if the band you're in starts playing different tunes
I'll see you on the dark side of the Moon...
Boulder is online now   Reply With Quote
Old 1st April 2023, 23:12   #2291  |  Link
DTL
Registered User
 
Join Date: Jul 2018
Posts: 880
If you set thSAD to very high value and scene detection still not skip frame - you simply lost protection from bad blends and MDegrainX will work as linear motion compensated blending engine (may be equal to MCompensate + Average()). If MVs are not perfect or there is other non-supported and not-compensated transforms left it will cause either blurring or visible several different blocks blended. thSAD adjustment in MDegrainX is only to protect user for possible artifacts of the very very simple temporal denoise method of different frames blocks weighted averaging.

In a perfect world with ideal transforms compensation no any protection required (see RIFE + Average() denoise example).

thSCD protects from more general error of blending different scenes in single frame.

Last edited by DTL; 1st April 2023 at 23:18.
DTL is offline   Reply With Quote
Old 2nd April 2023, 03:22   #2292  |  Link
FTLOY
Friend of a friend..
 
FTLOY's Avatar
 
Join Date: Feb 2023
Posts: 110
Quote:
Originally Posted by Dogway View Post
Simply used:
Code:
pre=ex_Median(mode="IQMST",thres=255)
STTWM(sw=50,tw=50,aw=100,sthres=5,tthres=5)
SMDegrain(tr=2,thSAD=200,thSADC=100,contrasharp=true,prefilter=pre,str=1.2,refinemotion=true)
FrameRateConverterMIX(FrameDouble=true)
in AvsPmod, and I think without Prefetch() even as I only use it when encoding.
You might need to review your workflow, use avs+ test 9, setmemorymax to an appropiate value, and load the mt-modes.avsi. Also test with other source loaders.
I think I might have figured out what's going on...

What type (resolution) video did you test this script on ?

I am trying to use FrameConverter on 4K HDR10 content, and I think the combination is just too much for it, 'cause it seems to be ok, but slow, on lesser resolution's.
FTLOY is offline   Reply With Quote
Old 2nd April 2023, 07:42   #2293  |  Link
LeXXuz
20 years and counting...
 
LeXXuz's Avatar
 
Join Date: Oct 2002
Location: Germany
Posts: 680
Quote:
Originally Posted by FTLOY View Post
I think I might have figured out what's going on...

What type (resolution) video did you test this script on ?

I am trying to use FrameConverter on 4K HDR10 content, and I think the combination is just too much for it, 'cause it seems to be ok, but slow, on lesser resolution's.
Could be a memory problem. How much RAM does your system have? If you have 32GB for example, try adding

Code:
SetMemoryMax(20*1024) # max RAM usage in kilobytes
SetCacheMode(0)
at the very beginning of your script. If your machine has more RAM you can raise that even more.

I have some script combinations which have very high RAM demands and either will not start or be very very slow on higher resolutions, if I don't set MemoryMax correctly.

Also, some filters don't really like caching, especially in multithreading with a high prefetch count, so I have to set cache mode explicitely to zero.
LeXXuz is offline   Reply With Quote
Old 2nd April 2023, 07:51   #2294  |  Link
FTLOY
Friend of a friend..
 
FTLOY's Avatar
 
Join Date: Feb 2023
Posts: 110
Quote:
Originally Posted by LeXXuz View Post
Could be a memory problem. How much RAM does your system have? If you have 32GB for example, try adding

Code:
SetMemoryMax(20*1024) # max RAM usage in kilobytes
SetCacheMode(0)
at the very beginning of your script. If your machine has more RAM you can raise that even more.

I have some script combinations which have very high RAM demands and either will not start or be very very slow on higher resolutions, if I don't set MemoryMax correctly.

Also, some filters don't really like caching, especially in multithreading with a high prefetch count, so I have to set cache mode explicitely to zero.
I do only have 32Gb....

And I have this in every script:-

Code:
SetCacheMode(1)
SetMemoryMax(16384)
And the Prefetch is 16, but it's not included in the scripts.
FTLOY is offline   Reply With Quote
Old 2nd April 2023, 08:24   #2295  |  Link
LeXXuz
20 years and counting...
 
LeXXuz's Avatar
 
Join Date: Oct 2002
Location: Germany
Posts: 680
Quote:
Originally Posted by FTLOY View Post
I do only have 32Gb....

And I have this in every script:-

Code:
SetCacheMode(1)
SetMemoryMax(16384)
And the Prefetch is 16, but it's not included in the scripts.
Try with cache mode 0.
LeXXuz is offline   Reply With Quote
Old 2nd April 2023, 09:44   #2296  |  Link
Boulder
Pig on the wing
 
Boulder's Avatar
 
Join Date: Mar 2002
Location: Finland
Posts: 5,610
Quote:
Originally Posted by DTL View Post
If you set thSAD to very high value and scene detection still not skip frame - you simply lost protection from bad blends and MDegrainX will work as linear motion compensated blending engine (may be equal to MCompensate + Average()). If MVs are not perfect or there is other non-supported and not-compensated transforms left it will cause either blurring or visible several different blocks blended. thSAD adjustment in MDegrainX is only to protect user for possible artifacts of the very very simple temporal denoise method of different frames blocks weighted averaging.

In a perfect world with ideal transforms compensation no any protection required (see RIFE + Average() denoise example).

thSCD protects from more general error of blending different scenes in single frame.
My case was just an example of trying to emphasize the effect. My default values for thSAD and thSCD1 are 400 and 600 respectively. thSCD1 sometimes needs to be bigger if the source is very grainy (despite heavy prefiltering).
__________________
And if the band you're in starts playing different tunes
I'll see you on the dark side of the Moon...
Boulder is online now   Reply With Quote
Old 2nd April 2023, 10:21   #2297  |  Link
FTLOY
Friend of a friend..
 
FTLOY's Avatar
 
Join Date: Feb 2023
Posts: 110
Quote:
Originally Posted by LeXXuz View Post
Try with cache mode 0.
Isn't 0 default, so I could simply remove that call...
FTLOY is offline   Reply With Quote
Old 2nd April 2023, 10:55   #2298  |  Link
LeXXuz
20 years and counting...
 
LeXXuz's Avatar
 
Join Date: Oct 2002
Location: Germany
Posts: 680
I don't trust defaults.
LeXXuz is offline   Reply With Quote
Old 2nd April 2023, 11:37   #2299  |  Link
FTLOY
Friend of a friend..
 
FTLOY's Avatar
 
Join Date: Feb 2023
Posts: 110
Quote:
Originally Posted by LeXXuz View Post
I don't trust defaults.
I might as well raise the "memorymax", too...

Last edited by FTLOY; 2nd April 2023 at 12:50.
FTLOY is offline   Reply With Quote
Old 2nd April 2023, 12:37   #2300  |  Link
LeXXuz
20 years and counting...
 
LeXXuz's Avatar
 
Join Date: Oct 2002
Location: Germany
Posts: 680
You probably have to. 16GB is not very much for more complex filtering of 4k content.
LeXXuz is offline   Reply With Quote
Reply

Tags
avisynth, dogway, filters, hbd, packs

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:24.


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