Thread: MVTools
View Single Post
Old 4th May 2011, 17:07   #1445  |  Link
-Vit-
Registered User
 
Join Date: Jul 2010
Posts: 448
Quote:
Originally Posted by SubJunk View Post
Is there a way to make MVTools2 get vectors from a smaller source and apply them to a bigger source?
I have a little plugin for this. It's going to be used in a later version of QTGMC for optimization. It hasn't been tested much:

Download MScaleVectors 0.1

It lets you use motion vectors on a different sized clip than they were analyzed on. Clip sizes must be related by powers of 2.

Example
Code:
scale = 2  # 2, 4 or 8. How much to downscale the clip for analysis (and then how much upscale the resultant vectors)
pad   = 16 # Padding used in full-scale super clip, must be divisible by scale (downscaled padding needed in downscaled super clip)

clip = YourSource( "Your\Video" )
clipScaled = clip.BicubicResize( clip.Width()/scale, clip.Height()/scale )

superScaled = clipScaled.MSuper( pel=2, hpad=pad/scale,vpad=pad/scale )
bVecScaled  = superScaled.MAnalyse( blksize=8, isb=true ) # Blocksize can't go > 32 after scaling
fVecScaled  = superScaled.MAnalyse( blksize=8, isb=false )

bVec = bVecScaled.MScaleVectors( scale ) # Increase blocksize for vectors
fVec = fVecScaled.MScaleVectors( scale )

super = clip.MSuper( pel=2, hpad=pad,vpad=pad )
clip.MFlowFPS( super, bVec, fVec, den=0 )
Other Documentation
Code:
INFO

Plugin that scales MVTools motion vectors / blocksize. Main purpose is to allow vectors to be used on a differently
sized clip than they were analyzed from.

For example
- Use MAnalyze on a half-sized clip at block size 16
- Use this plugin to scale the vectors by 2 to block size 32
- Use resulting vectors for MFlowFPS, MDegrain,... on the full sized frame. 
Saves doing the MAnalyze on the full size frame, which may be faster and saves memory (good for multi-threading).

Note that you need a super clip for each frame size. The padding (hpad, vpad) on each super clip must be
manually scaled to match the vector scaling. See the example below.

Similar functionality was available in MVTools through the function MVIncrease, but it was removed.


SYNTAX

MScaleVectors( int Vectors, float Scale, int Mode )

Returns a new motion vectors clip

  Vectors :
     Motion vectors returned from MAnalyse
     [No default]

  Scale :
    Mode = 0,1: Scale is the amount to up/downscale blocksize, only valid values are 2,4 or 8. Blocksize cannot drop below 4 or exceed 32
    Mode = 2: Scale is (floating point) amount to scale the vectors, blocksize is unaffected. Only the range 0.0 to 1.0 is currently safe
    [Default Scale = 2 (for default Mode=0)]

  Mode :
    Method of scaling:
    Mode = 0: Increase the blocksize by 2, 4 or 8 (see above)
    Mode = 1: Decrease the blocksize by 2, 4 or 8
    Mode = 2: Blocksize is not scaled, only vectors themselves
    [Default Mode = 0]

    Mode 0 allows you to MAnalyse at a smaller size, then process (MDeGrain, MFlowFPS, whatever) at full size
    Mode 1 allows you to MAnalyse at full size, but have some subsequent processes run at a smaller size
    Mode 2 is for esoteric uses

Last edited by -Vit-; 4th May 2011 at 17:40.
-Vit- is offline   Reply With Quote