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 11th June 2011, 17:37   #1  |  Link
Boulder
Pig on the wing
 
Boulder's Avatar
 
Join Date: Mar 2002
Location: Hollola, Finland
Posts: 4,347
Why are these compensated frames blurry?

Code:
AVISource("e:\temp\dvnauha.avi")
TDeint(mode=1)

super=MSuper(last.Blur(1.58))
fv1=MAnalyse(super, chroma=true, isb=false)
bv1=MAnalyse(super, chroma=true, isb=true)

mc1=last.MCompensate(super, bv1)
mc2=last.MCompensate(super, fv1)

interleave(mc2,last,mc1)
Why are the compensated frames blurry? I thought that Blur is only applied to the motion vector search and not to the final result. I'm using the latest MVTools2 version, v2.5.11.2 I think.

__________________
And if the band you're in starts playing different tunes
I'll see you on the dark side of the Moon...
Boulder is offline   Reply With Quote
Old 11th June 2011, 18:16   #2  |  Link
cretindesalpes
͡҉҉ ̵̡̢̛̗̘̙̜̝̞̟̠͇̊̋̌̍̎̏̿̿
 
cretindesalpes's Avatar
 
Join Date: Feb 2009
Location: No support in PM
Posts: 610
You need a second, unprocessed superclip for MCompensate. Actually this function directly uses the provided superclip data to reconstruct the frames.
__________________
dither 1.27.2 for AviSynth | avstp 1.0.3 for AviSynth development | fmtconv r19 for Vapoursynth | trimx264opt segmented encoding
cretindesalpes is offline   Reply With Quote
Old 11th June 2011, 18:20   #3  |  Link
Didée
Registered User
 
Join Date: Apr 2002
Location: Germany
Posts: 5,390
Quote:
Originally Posted by Boulder View Post
Why are the compensated frames blurry? I thought that Blur is only applied to the motion vector search and not to the final result.
Look at the lines that are doing the actual compensations:
Code:
mc1=last.MCompensate(super, bv1)
Bingo? Bingo!


Script adapted, with more-obviously-named clips:
Code:
AVISource("e:\temp\dvnauha.avi")
TDeint(mode=1)

super_search = MSuper(last.Blur(1.58))
super_render = MSuper(last,levels=1)
fv1 = MAnalyse(super_search, chroma=true, isb=false)
bv1 = MAnalyse(super_search, chroma=true, isb=true)

mc1 = last.MCompensate(super_render, bv1)
mc2 = last.MCompensate(super_render, fv1)

interleave(mc2,last,mc1)
__________________
- We´re at the beginning of the end of mankind´s childhood -

My little flickr gallery. (Yes indeed, I do have hobbies other than digital video!)
Didée is offline   Reply With Quote
Old 11th June 2011, 18:48   #4  |  Link
Boulder
Pig on the wing
 
Boulder's Avatar
 
Join Date: Mar 2002
Location: Hollola, Finland
Posts: 4,347
Oh heck, over 8 years of Avisynth and I still stumble over the simplest things

To my defense, I did read the docs but of course didn't go to the examples where this one would have been pointed out.

Thanks, gentlemen
__________________
And if the band you're in starts playing different tunes
I'll see you on the dark side of the Moon...
Boulder is offline   Reply With Quote
Old 11th June 2011, 23:57   #5  |  Link
johnmeyer
Registered User
 
Join Date: Feb 2002
Location: California
Posts: 1,960
Every time I think I've got something figured out, I read something like this post and realize I'm still a rookie.

The thing that has me puzzled is this line in Didée's post:

Quote:
mc2 = last.MCompensate(super_render, fv1)
The usage for the MCompensate function, from the MVTools2 documentation, is as follows:

MCompensate (clip source, clip super, clip vectors, bool "scbehavior", etc., etc.)

Here is where I will show my ignorance: in AVISynth, if the source clip is provided outside the function ("last." in the quoted line above), doesn't the first parameter in the function become the next item in the list, in this case "super?" If this is true, why aren't the motion compensation vectors, which were created with the blurred "super" clip, being applied to "last?" And if they are applied to "last," which is not blurred (it is the result of TDeint, right?), why would the results of the OP's script return blurred results?

A corollary of my question is this: if the motion vectors are being applied to the "super_render" super clip (the one that is not blurred), then is "last" even used?


Sorry to be so stupid, but I am confused.
johnmeyer is offline   Reply With Quote
Old 12th June 2011, 02:47   #6  |  Link
Didée
Registered User
 
Join Date: Apr 2002
Location: Germany
Posts: 5,390
Quote:
Originally Posted by johnmeyer View Post
in AVISynth, if the source clip is provided outside the function ("last." in the quoted line above), doesn't the first parameter in the function become the next item in the list, in this case "super?"
Yes, it's exactly like that. Nothing more to say.

Quote:
If this is true, why aren't the motion compensation vectors, which were created with the blurred "super" clip, being applied to "last?"
Because MVTools' functions don't work that way.

- MVAnalyse works solely on the super clip. The motion search does not require the original base clip, the vector search happens only on the super clip.

- Other functions like MCompensate, MDegrain, MFlow etc. work in that way that the compensated pixels are in fact created from the pixels of the super clip. The base clip is used only in so far as its pixels have to contribute any actual weight into the result. (Like e.g. MDegrain2, where the base clip provides basically 20% weight, and the compensations of the prev2, prev1, next1 next2 also 20% each.) [not considering thSAD weighting, for simplicity of explaining.]
MCompensate is a bit of a special case because no weighting is taking place. It's a "merciless" compensation, all compensated pixels are taken from the super clip pixels. [safe for "thSAD" which disables compensation for bad blocks, using the base clip's original pixels for such bad blocks. But thSAD is skyrocket-high per default, i.e. disabled)


Meh, already too much words for a simple relation. The short version:

If any MVTools function creates compensated(interpolated) pixels, they are created from the pixels of the specified super clip.


Application example:
"Denoise with MDegrain2, do slight sharpening where motionmatch is good, do slight blurring where motionmatch is bad"

Code:
source = whatever

sup_srch = source.msuper()
sup_rend = source.sharpen(0.6).msuper(levels=1)
bv1 = sup_srch.manalyse(isb=true, delta=1)
fv1 = sup_srch.manalyse(isb=false,delta=1)
bv2 = sup_srch.manalyse(isb=true, delta=2)
fv2 = sup_srch.manalyse(isb=false,delta=2)
                                           
source.blur(0.6).mdegrain2(sup_rend,bv1,fv1,bv2,fv2)
In areas where MAnalyse cannot find good matches, the blur() will be dominant. In areas where good matches are found, the sharpen()'ed pixels will overweight the blur()'ed pixels when the pixel averaging is performed.
__________________
- We´re at the beginning of the end of mankind´s childhood -

My little flickr gallery. (Yes indeed, I do have hobbies other than digital video!)
Didée is offline   Reply With Quote
Old 12th June 2011, 04:17   #7  |  Link
johnmeyer
Registered User
 
Join Date: Feb 2002
Location: California
Posts: 1,960
Didée,

Many thanks for the excellent explanation. I am very glad that my understanding of AVISynth itself is OK, but now that you have told me exactly what I needed to know about how the super clip is used, I will go back and re-read the MVTools2 documentation. I need to make sure that the several dozen scripts I've written over the years which use MVTools2 don't include a similar mistake. I think I would have noticed if the results were not what I'd expected, but I want to make sure.

Again, thank you.
johnmeyer is offline   Reply With Quote
Old 13th June 2011, 21:24   #8  |  Link
Nephilis
--preset WTF!
 
Join Date: Feb 2009
Posts: 86
Shortly;

Quote:
super_search = MSuper(last.Blur(1.58)) <= At this stage we prepare the superclip that we'll use in MAnalyze.Therefore we should blur the source to obtain a better and more reliable motion vector search process (we need all levels here)
super_render = MSuper(last,levels=1) <= At this stage we prepare the superclip that we'll use in compensation process (one finest level is enough here)

Last edited by Nephilis; 13th June 2011 at 21:28.
Nephilis is offline   Reply With Quote
Old 20th October 2011, 04:12   #9  |  Link
Boulder
Pig on the wing
 
Boulder's Avatar
 
Join Date: Mar 2002
Location: Hollola, Finland
Posts: 4,347
One more thing to this thought of MSupers - can I utilize vectors created under different "pel" in functions that use a different pel value, for example create vectors using pel=2, then use pel=1 for MCompensate and MDegrain and reuse the vectors created earlier?
__________________
And if the band you're in starts playing different tunes
I'll see you on the dark side of the Moon...
Boulder is offline   Reply With Quote
Reply

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 13:54.


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