User:Reel.Deal/Sandbox

From Avisynth wiki
< User:Reel.Deal
Revision as of 02:26, 8 November 2015 by Reel.Deal (Talk | contribs)
Jump to: navigation, search

A page to keep notes

Scripts/Plugins to add to the wiki

Denoising

Effects

Other

  • Logo - a simple script that will help you add logos to your video sources in the easiest, fastest and best quality methods. Download
  • Unipolator - an universal frame interpolator script
  • TGMC_SVP_Test - QTGMC() using SVP for motion analysis.


Missing Plugins


AviSynth.info


Development


AviSynth Information

Plugins

AviSynth uses the Windows functions FindFirstFile/FindNextFile to search the plugins folder. For plugins, it uses "*.dll" as the search string and it appears that this also returns any file whose extension starts with "dll" (perhaps because files with long names or extensions also have a short name for DOS compatibility). So to stop a dll from being loaded, change the extension to "_dll", for example, or add a further extension like ".old". OTOH, .avsi can be renamed to .avsx to prevent loading, since searching for "*.avsi" only returns files with exactly that extension (because it's more than 3 characters). [2]

Plugin auto-loading limit?

The current AviSynth limit is 50, that is, AviSynth can have a maximum of 50 filter dll's/.vfds (it doesn't matter how many functions the dll has) loaded at any one time. How prescanning works is it searches for .dlls/.vdf's in the plugin directory, loads them, finds any functions in the plugin and stores that information+name. It will do this for a maximum of 50 at which point it can't load anymore. Once it has all the info stored it then unloads all the prescanned plugins. After that, AviSynth does .avsi file loading.

An important point to remember is that any filters loaded with LoadPlugin() (even if they are in an avsi file) will not be unloaded if they are not actually required, that means that they stay loaded taking up one of the 50 available slots.

Now, when you attempt to open a script and AviSynth finds that it needs to invoke function x it first searches for the required function in currently loaded dlls. If doesn't find it it searches for it in prescanned dlls (which have been unloaded). If it finds it it attempts to load the needed dll (which if there are already 50 plugins loaded will fail). If it still doesn't find the function it searches the internal function list. [3]


QTGMC Notes

Notes from the QTGMC thread.

Does it take two fields in consideration or only one?

At max settings, up to fourteen fields for each output frame. Don't compare QTGMC (its workflow) with that of other deinterlacers. It works different, it IS different. Usual deinterlacers go "to weave, or not to weave, that's the question". QTGMC basically is a motioncompensated temporal superresolution filter.

Yes, QTGMC does "take both fields into account" (and more) even if you keep single rate. Every output frame is constructed from a range of neighbor fields as Didée has noted. By default the current field is interpolated into a full frame, then the two fields before and after (interpolated + motion compensated) are combined into the frame in such a way as to remove bob-shimmer. This temporal processing also enhances detail to some degree and has some noise reducing effect. So all source data will have been used in your output even after a SelectEven(). The result will be primarily based on the even fields of course, but the neighboring ("thrown away") fields will have had an influence too.

Temporal smoothing is used to remove bob-shimmer, but we don't want large areas of motion blur so the Rep0/1/2 settings limit the amount of change that the temporal smoothing is allowed to make. Higher values for Rep0/1/2 allow larger areas of change from the smoothing, but (counter intuitively) 0 switches of the limiting completely and so allows all changes through. You're right that there is a code path for Rep0/1/2 = 0 that is not used. However, that code path would only allow 2-pixel high areas of change, much bob-shimmer covers a larger area than that. It would be getting close to doing no temporal smoothing at all, similar to TR0/1/2=0 and would be especially bad on stationary detail. Having said that, it does seem to be a little odd not to allow that code path even if it is not the most useful.

Why is 2 pixels not enough? Consider a stationary single pixel high horizontal line, positioned such that it appears only in the even fields. The bob will expand that to a 3 pixel high line, and clearly it will be a cause of major bob-shimmer, flickering on and off. When temporally smoothed, the now 3 pixel high line is softened in the even frames and appears in the odd frames. Bob shimmer removed - by a 3-pixel high area of change, which would be removed if you followed the Rep0=0 code path... I could make that more clear with a diagram, but I hope you get the idea...

[I note that my comments on that function need an update for precision: the two vertical in/expands allow through areas of change up to 4 pixels high, the in/deflate and RemoveGrain are not limited vertically so they also perform some measure of mask clean up]

As I'm sure you're aware, the epsilon is only there to trigger the GaussResize to do its blur even though we're not actually resizing, I'm sure it doesn't matter much where it is placed given the tiny value and the fact it is being used on a huge blur anyway. I do wonder if there's a more efficient way to do a Gaussian nowadays, or something similar.

Does QTGMC just deinterlace with the presets or does it also do sharpening, denoising, noise stabilizing, etc.?

You will get a little of all three if you provide only a preset and no other settings. QTGMC is not really trying to be a sharpener or denoiser, this happens mainly a byproduct of the processing used to avoid shimmer. The light temporal smoothing / denoising improves compressibility, and the sharpening provides some detail enhancement. Despite the fact that this moves the result away from the source, most people like those effects.

The impact on noise is often very minor, and you may not care to do anything about it, especially since it will involve more processing. However, some people do take the sharpness down, and that's a free operation, e.g. Sharpness=0.4 or 0.7

However, if you really want something that's *very* close to the source, then Boulder's suggestion above is the right way to go about it. Although his MatchPreset choice is very high and will slow it down - I would usually leave that out and set an explicit Preset for clarity: Code:

QTGMC(Preset="Slower", SourceMatch=2, Lossless=2, EZKeepGrain=0.5, Sharpness=0.1)

SourceMatch specifically tries to make the deinterlace as "lossless" as possible without introducing shimmer. EZKeepGrain helps preserve the noise from the original. These are not default settings because I think most people want the slight denoise/enhance. Also these settings are slower - you can speed up the Preset a little without any major loss. I would strongly suggest an MT setup (see the first post).

Why static titles flicker after QTGMC?

Short answer: Try adding Rep1=4, Rep2=0 to your settings. This might fix your problem - it might rarely add a tiny bit of motion blur (hard to notice)

Long answer: The core operation of TGMC is to blend 50% of the current frame with 25% each of the previous & next frames (motion-compensated). That removes all bob-shimmer and helps define the missing field lines. However, it also introduces motion-blur where the motion analysis is incorrect. So there is a repair step that only allows changes that affect thin horizontal areas - because bob-shimmer normally only affects thin horizontal areas. Occasionally there is shimmer that covers a wider area, especially on static detailed things such as text. That shimmer gets through because fixing shimmer in larger areas would potentially create motion blur elsewhere.

There are settings controlling the shimmer repair step: Rep0, Rep1 and Rep2. Rep0 improves the motion search clip only so that isn't so relevant here. Rep1 and Rep2 are alternative ways to repair the output, you set them to a value from 1 to 5 to control the repair strength (it's a bit more complicated but that's the basic idea). The higher you set the value the more shimmer is removed but with the possibility that some motion blur might creep through. Rep1 has a stronger effect than Rep2, but again might let more motion blur through. The defaults are Rep1=0, Rep2=4. I suggest you switch the 4 to the stronger Rep1 and see if that works.

You might wonder why TGMC doesn't just mask static areas and leave them untouched to avoid all this complexity. You can try it yourself: Code:

qtgmc = QTGMC()
dw = DoubleWeave()
mask = mt_lutxy( dw, dw.SelectEvery(1,1), "x y - abs", U=1,V=1 ).mt_expand(U=1,V=1).mt_binarize(0, U=1,V=1)
mt_merge( dw, qtgmc, mask, luma=true )

That simple script leaves any pixel untouched if it and its 8 neighbors don't change over the nearby fields (could be made more robust by including chroma or more complex masking). It might fix your problem. However, any tiny change within your "static" text pixels, even a change by 1 luma then you'd need to add a threshold. You can change the 0 in the mt_binarize to 1 or 2 to allow slight dissimilarities. But that will start to cause problems in normal footage: occasional pixels will be identified as "static" and will be processed differently to their neighbors - artefacts would show up (in fact rare cases artefacts can show up even with the script as I've written it).

It's very easy to create discontinuities by naive masking during deinterlacing, different algorithms often don't match up perfectly. You see this in other deinterlacers: "this part is combed so do A, this part is not combed so do B". We see the discontinuity between A and B. Softened masks help but blur detail.

On a side note, the other problem with static detail in (Q)TGMC is that is loses too much vertical detail compared to other deinterlacers. Source match was specifically designed to greatly improve static detail. Sadly though it doesn't affect these minor shimmer issues.

What are the best settings for QTGMC?

Everyone's opinion about "best" is different. Every source has different "best" settings. Don't ask for "best", find out what's best for yourself.

This is one place to start if you don't care about speed:

QTGMC(Preset="Very Slow", SourceMatch=2, Lossless=2, EZKeepGrain=0.5, Sharpness=0.1, Sbb=0)

But that's for good quality footage that has fine detail, noisy VHS tapes probably aren't worth that kind of processing - but you asked... You will likely want to change that EZKeepGrain value (increase it to keep more noise, decrease if you don't care about preserving noise. Change it to EZDenoise and increase the value if you want QTGMC to denoise for you.)

Personal tools