# MVTools

## Abstract

Authors: |  | Manao, Tsp, TSchniede, SEt, Fizick (Alexander Balakhnin), Vit, Firesledge, pinterf
Version: |  | 2.7.41
git: |  | https://github.com/pinterf/mvtools/tree/mvtools-pfmod
Forum: |  | https://forum.doom9.org/showthread.php?t=173356
Base versions: |  | 2.6.0.5 + 2.5.11.22
Base download: |  | Contained in the Dither package, http://ldesoras.free.fr/prod.html
Category: |  | Misc Plugins
Requirements: |  | YV12, YV16, YV24 or YUY2, Y, YUV420P10-16, YUV422P10-16, YUV444P10-16 for finding vectors
|  | 8-32 bit Y, YUV 420, 422, 444 and planar RGB for MSuper, MCompensate and MDegrains and MFlowXX family
License: |  | GPL

## Table of contents

1. About MVTools
2. About MVTools version 2
3. Function descriptions
4. Examples
5. Disclaimer (don't skip that part, but we don't force you to learn it either)
6. Revisions
7. Download

## I) About MVTools

MVTools plugin for Avisynth+ and AviSynth 2.6 is collection of functions for estimation and compensation of objects motion in video clips. Motion compensation may be used for strong temporal denoising, advanced framerate conversions, image restoration and other tasks.

The plugin contains the motion estimation server-function MAnalyse to find the motion vectors and several motion compensation client-functions (MCompensate, MMask and others) which use these vectors.

Plugin uses block-matching method of motion estimation (similar methods are used in MPEG2, MPEG4, etc). At analysis stage plugin divides frames by small blocks and try to find for every block in current frame the most similar (matching) block in second frame (previous or next). The relative shift of these blocks is motion vector. The main measure of block similarity is sum of absolute differences (SAD) of all pixels of these two blocks compared. SAD is a value which says how good the motion estimation was.

The output of MAnalyse (server) is special clip with motion vector information in some format.

At compensation stage the plugin client functions read the motion vectors and use them to move blocks and form motion compensated frame (or realize some other full or partial motion compensation or interpolation function). Every object (block) in this (fully) compensated frame is placed in the same position as this object in current frame. So, we may (for example) use strong temporal denoising even for quite fast moving objects without producing annoying artefactes and ghosting (object's features and edges are coincide if compensation is perfect). Plugin can create compensated neighbor frames for every current frame, and denoise it by internal function. Alternatively, you can use compensated and original frames to create interleaved clip, denoise it by any external temporal filter, and select central cleaned original frames for output (see examples).

Of course, the motion estimation and compensation is not ideal and precise. In some complex cases (video with fading, ultra-fast motion, or periodic structures) the motion estimation may be completely wrong, and compensated frame will be blocky and (or) ugly. Severe difficulty is also due to objects mutual screening (occlusion) or reverse opening. Complex Avisynth scripts with many motion compensation functions may eat huge amount of memory and result in very slow processing. It is not simple but quite advanced plugin. Use it for appropriate cases only, and try tune its parameters. There are many discussions about motion compensation using at doom9 Avisynth forum. In particular see old MVTools thread , true motion thread, new MVTools thread, MVTools-pfmod thread and some other. Try read postings in addition to this documentation and ask for support there. If you really interested in motion estimation and compensation topics, you can easy find numerous scientific publications (use WWW search).

2.5.11.22 and 2.6.0.5 classic versions had some limitations, only progressive YV12, YUY2 video were supported. Versions from 2.7.5.22 support all 420, 422, 444 planar YUV formats, 8 and 10-16 bits with recent Avisynth Plus versions. Since 2.7.40 almost all 8-32 bit Y, YUV and planar RGB colorspaces are supported for many filters. Except that for motion vector search only 8-16 bit Y or YUV clips are supported. Use color format conversion and try using (smart) bob-deinterlace for interlaced video (`SeparateFields` may works too with or without `SelectEven`/`SelectOdd`). Some complex scripts (`QTGMC`, `TempGaussMC`, `MVBOB`, `MCBOB`) use MVTools for motion compensated deinterlacing. Alternatively you can try to use Motion plugin by mg262.

## II) About MVTools version 2

MVTools version 2 is a major internal and external upgrade. Main goals of MVTools v2.X branch are clarity and stability (in particular for multithreaded environment with multicore CPU) and of course performance and memory usage improving.

Main mean for goals achievement is removing MVTools internal buffer with mysterious (for many people) index (idx) and some other internal tricks (see thread MVTools without idx ). To implement this without performance degradance we use normal effective Avisynth cache and introduce new mandatory preparation stage (before motion estimation by `MAnalyse`). At this stage a new function `MSuper` will get source clip and prepare special "super" clip with multilevel (hierarchical scaled) frames data (in previous MVTools versions 0.X-1.X these multilevel datas were prepared, saved and cached internally with idx as an index of pseudo-clip of these "superframes"). The super clip is then used by both `MAnalyse` function and client motion compensation functions.

Related syntax change: some `MAnalyse` parameters (pel, sharp) are moved to `MSuper` function.

Other essential external change is replacing all named clips parameters by unnamed (mandatory, without double-quotes in description) for normal work of Avisynth implicit "last" clip.

Also faster planar processing for YUY2 is implemented in v2.0.

Since v2.2 `MVTools.dll` is renamed to `mvtools2.dll`, and since v2.3 all functions are renamed from MVxxx to Mxxx (e.g. from `MVAnalyse` to `MAnalyse`), so you can continue to use old MVTools 1.x with your old scripts, and you are able to use / make new scripts with MvTools 2.x without changing the dll loading.

I also have an intention to remove (not implement) some obsolete functions like MVDenoise, MVFlowFps2 (please, vote).

Full list of changes see at Revisions section.

Generally, new MVTools 2.0 should provide similar results as v1.11.4. Algorithm improvements is planned in v2.1 and later.

Note: MVTools v1.x branch is not developed and not supported anymore (by Fizick).

To benefit from native multi-threading, you'll have to install the latest `avstp.dll` in your plugin folder. This is recommended but not mandatory.

## III) Function descriptions

### Common parameters

Filters that use motion vectors have common parameters. Those are the scene-change detection thresholds, and the isse MMX flag. They also use one or several vectors stream, which are produced by `MAnalyse`.

thSCD1 (int, 400)

Threshold which decides whether a block has changed between the previous frame and the current one. When a block has changed, it means that motion estimation for it isn't relevant. It occurs for example at scene changes. So it is one of the thresholds used to tweak the scene changes detection engine. Raising it will lower the number of blocks detected as changed. It may be useful for noisy or flickered video. The threshold is compared to the SAD (Sum of Absolute Differences, a value which says how bad the motion estimation was ) value. For exactly identical blocks we have SAD = 0. But real blocks are always different because of objects complex movement (zoom, rotation, deformation), discrete pixels sampling, and noise. Suppose we have two compared 8×8 blocks with every pixel different by 5. It this case SAD will be 8×8×5 = 320 (block will not detected as changed for thSCD1 = 400). Actually this parameter is scaled internally in MVTools, and it is always relative to 8x8 block size. Default is 400 (since v.1.4.1).

thSCD2 (int, 130)

Threshold which sets how many blocks have to change for the frame to be considered as a scene change. It is ranged from 0 to 255, 0 meaning 0 %, 255 meaning 100 %. Default is 130 (which means 51 %).

isse (bool, true)

Flag which allows to enable (if set to True) or disable ISSE, MMX and other CPU optimizations (for debugging). If your processor doesn't support CPU optimizations, it will be disabled anyway (and you won't be able to activate them).

planar (bool, false)

Flag to use special planar color format for YUY2 clips both for input and output of function. It uses special trick for storing of frames with planar color data organisation (separate Y, U, V planes in memory) in normal interleaved YUY2 frames format as a container. This way we can avoid numerous internal interleaved to planar conversions and increase speed. You can convert normal interleaved YUY2 source clip to planar format with `Interleaved2planar` function from RemoveGrain plugin by kassandro , and convert final result by `Planar2interleaved` function. This special planar YUY2 format is also supported by Removegrain plugin by Kassandro, MaskTools2 plugin by Manao and some others. This trick will not be needed in Avisynth v2.6 with native support of planar YV16 format. This paramenter is ignored for YV12 clips. Note: super clip is always planar.

### MSuper

    MSuper (
    	clip,
    	int  hpad (8),
    	int  vpad (8),
    	int  pel (2),
    	int  levels (0),
    	bool chroma (true),
    	int  sharp (2),
    	int  rfilter (2),
    	clip pelclip (undefined),
    	bool isse,
    	bool planar,
    	bool mt (true)
    )

Get source clip and prepare special "super" clip with multilevel (hierarchical scaled) frames data. The super clip is used by both `MAnalyse` and motion compensation (client) functions. For storing and transferring its parameters we use audio properties of super clip (specifically, `num_audio_samples`) as a trick. So, audio is killed in super clip. That is one of reasons why we additionally use source clip with client functions. You may have a look to super clip yourself (it has normal format). Supported formats: greyscale, YUV and planar RGB 8-32 bits, YUY2 You can use different Super clip for generationg vectors with MAnalyze and a different super clip format for the actual action. Thus MFlowFPS can support native RGB (planar), and MDegrain can work with 32 bit float input clips.

hpad

It is horizontal padding added to source frame (both left and right). Small padding is added for more correct motion estimation near frame borders. (In MVTools before v2.0 the value of padding = block size was always used internally. Now it is not strict but recommended value.)

vpad

It is vertical padding added to source frame (both top and bottom).

pel

It is the accuracy of the motion estimation. Value can only be 1, 2 or 4. 1 means a precision to the pixel. 2 means a precision to half a pixel, 4 means a precision to quarter a pixel, produced by spatial interpolation (more accurate but slower and not always better due to big level scale step). Default is 2 since v1.4.10.

levels

It is the number of hierarchical levels in super clip frames. `MAnalyse` is need in all levels, but for other client functions single finest level is enough (coarser levels are not used). 0 = auto, all possible levels are produced.

chroma

If set to true, it allows to prepare chroma planes too in superclip. False means luma only.

sharp

Subpixel interpolation method for pel = 2 or 4. Use:

0 | for soft interpolation (bilinear),
1 | for bicubic interpolation (4 tap Catmull-Rom),
2 | for sharper Wiener interpolation (6 tap, similar to Lanczos).

This parameter controls the calculation of the first level only. When pel = 4, bilinear interpolation is always used to compute the second level.

rfilter

Hierarchical levels smoothing and reducing (halving) filter.

0 | Simple 4 pixels averaging like unfiltered SimpleResize (old method),
1 | Triangle (shifted) filter like `ReduceBy2` for more smoothing (decrease aliasing),
2 | Triangle filter like `BilinearResize` for even more smoothing,
3 | Quadratic filter for even more smoothing,
4 | Cubic filter like `BicubicResize(b=1, c=0)` for even more smoothing.

Default is 2 (since v2.3.1). You may also try to apply some external filter to superclip or its coarse bottom part (by appropriate crop and overlay).

pelclip

Optional upsampled source clip for using instead of internal subpixel interpolation (for pel > 1). Pixels at rows and colunms positions multiple to pel (0, 2, 4,… for pel = 2) (without padding) must be original source pixels, other pixels must be interpolated. Example for pel = 2:

    LanczosResize (width*2, height*2, src_left=0.25, src_top=0.25)

Recent note: it is true for luma, but it doesn't correspond to chroma pixels positions of internal MVTools interpolation. Nevertheless vectors and motion compensation are quite similar for usual clips, same chroma would be with `src_left = 0.5` for YUY2 and additionally `src_top = 0.5` for YV12.

Other useful example is EEDI2 edge-directed resampler.

mt

Enables internal multi-threading (through avstp.dll).

### MAnalyse

    MAnalyse (
    	clip   super,
    	int    blksize (8),
    	int    blksizeV (blksize),
    	int    levels (0),
    	int    search (4),
    	int    searchparam (2),
    	int    pelsearch (pel),
    	bool   isb (false),
    	int    lambda (0 | 1000*blksize*blksizeV/64),
    	bool   chroma (true),
    	int    delta (1),
    	bool   truemotion (true),
    	int    lsad (400 | 1200),
    	int    plevel (0 | 1),
    	bool   global (truemotion),
    	int    pnew (0 | 50),
    	int    pzero (pnew),
    	int    pglobal (0),
    	int    overlap (0),
    	int    overlapV (overlap),
    	string outfile (""),
    	int    dct (0),
    	int    divide (0),
    	int    sadx264 (0),
    	int    badSAD (10000),
    	int    badrange (24),
    	bool   isse,
    	bool   meander (true),
    	bool   temporal (false),
    	bool   trymany (false),
    	bool   multi (false),
    	bool   mt (true),
    	int    scaleCSAD (0)
    )

Get prepared multilevel super clip, estimate motion by block-matching method and produce special output clip with motion vectors data (used by other functions).

Some hierarchical multi-level search methods are implemented (from coarse image scale to finest). Function uses zero vector and neighbors blocks vectors as a predictors for current block. Firstly difference (SAD) are estimated for predictors, then candidate vector changed by some values to some direction, SAD is estimated, and so on. The accepted new vector is the vector with minimal SAD value (with some penalty for motion coherence).

Try using `MShow` function to check estimated motion field and tune parameters.

Note: `MAnalyse` (if pel ≥ 2) detects fieldbased video flag (after `SeparateFields`) and automatically makes correction of motion vectors according to verticlal shift of fields with different parity. Try using AssumeFrameBased if you do not need in it.

Technical note: MAnalyse does not generate a regular clip that can be displayed. Don't try to modify its content or it will get corrupted. It is made of a single long line, actually containing binary data (vectors, block SAD, misc. information…) instead of pixel values. It also alters the audio descriptor to pass additional data to other filters before any frame request. Therefore, in the current state, a vector clip cannot be saved to a lossless file and reloaded later for processing. If you want to do so, you have to transcode it first with `MStoreVect` and `MRestoreVect`. Furthermore, joining vector clips generated with different parameters may lead to unexpected results, because the aforementioned additional data is global to the whole clip and is not updated on each frame. When the MAnalyse filter is destructed (removed from the memory), the additional data is lost too, and an attempt to using the produced vectors may crash the application or give wrong results. For this reason, avoid using MAnalyse in `ScriptClip` and other functions of the Avisynth runtime subsystem.

super

This is multilevel super clip prepared by MSuper function. Mandatory.

blksize

Size of a block (horizontal). Larger blocks are less sensitive to noise, are faster, but also less accurate.
List of available block sizes (blksize x blksizeV)
64x64, 64x48, 64x32, 64x16
48x64, 48x48, 48x24, 48x12
32x64, 32x32, 32x24, 32x16, 32x8
24x48, 24x24, 24x32, 24x12, 24x6
16x64, 16x32, 16x16, 16x12, 16x8, 16x4, 16x2
12x48, 12x24, 12x16, 12x12, 12x6, 12x3
8x32, 8x16, 8x8, 8x4, 8x2, 8x1
6x24, 6x12, 6x6, 6x3
4x8, 4x4, 4x2
3x6, 3x3
2x4, 2x2
Note: some smaller block sizes can only be available in 4:4:4 formats, due to block size division (chroma subsampling)

blksizeV

Vertical size of a block. Default is equal to horizontal size.

levels

A positive value is the number of levels used in the hierarchical analysis made while searching for motion vectors.

Negative or zero value is the number of coarse levels NOT used in the hierarchical analysis made while searching for motion vectors. The lower the usually better (vectors with any length can be found). It is kept variable for study's purposes mostly. Sometimes levels is useful to prevent large (false) vectors (computer graphics, etc). Default = 0 since v.2.5 (all levels are used).

search, searchparam, pelsearch

search decides the type of search at every level, searchparam is an additional parameter (step, radius) for this search, and pelsearch is the radius parameter at finest (pel) level. Below are the possible values for the search type:

0 | 'OneTimeSearch'. searchparam is the step between each vectors tried (if searchparam is superior to 1, step will be progressively refined).
1 | 'NStepSearch'. N is set by searchparam. It's the most well known of the MV search algorithm.
2 | Logarithmic search, also named Diamond Search. searchparam is the initial step search, there again, it is refined progressively.
3 | Exhaustive search, searchparam is the radius (square side is 2*radius+1). It is slow, but it gives the best results, SAD-wise.
4 | Hexagon search, searchparam is the range. (similar to x264).
5 | Uneven Multi Hexagon (UMH) search, searchparam is the range. (similar to x264).
6 | pure Horizontal exhaustive search, searchparam is the radius (width is 2*radius+1).
7 | pure Vertical exhaustive search, searchparam is the radius (height is 2*radius+1).

isb

Allows to choose between a forward search (motion from the previous frame to current one) for isb =false and a backward search (motion from following frame to the current one) for isb =true (isb stands for "IS Backward", it is implemented and named exactly as written here, do not ask :-).

chroma

Set to true, it allows to take chroma into account when doing the motion estimation (false: luma only).

delta

Set the frame interval between the reference frame and the current frame. By default, it's 1, which means that the motion vectors are searched between the current frame and the previous (or next) frame. Setting it to 2 will allow you to search mvs between the frame n and n-2 or n+2 (depending on the isb setting). If delta is negative or null, -delta is the absolute index of a fixed reference frame. In this case, the isb value is ignored. Only a few functions are compatible with fixed reference frames (`MCompensate`, `MFlow` and `MDegrain*`).

pzero

relative penalty (scaled to 256) to SAD cost for zero vector. It prevent replacing of quite good predictor by zero vector with a little better SAD (lambda is not used for zero vector). Default is equal to pnew since v1.11.

pglobal

Relative penalty (scaled to 256) to SAD cost for global predictor vector. (lambda is not used for global vector).

overlap

block overlap value (horizontal). Must be even and less than block size (up to blksize/2 for `MCompensate`). The step between blocks for motion estimation is equal to (blksize − overlap). N blocks cover the size ((blksize − overlap) * N + overlap) on frame. Try using overlap value from blksize/4 to bblksize/2. The greater overlap, the more blocks number, and the lesser the processing speed. However the default value 0 may cause blocking-like artefacts. Functions with overlap support are: `MFlow`, `MFlowInter`, `MFlowFps`, `MShow`, `MMask`, `MCompensate` and all the `MDeGrain*`.

                                <----oh--->      <---oh---->       <---oh--->

                                <------------bh------------>       <------------bh------------>
               <------------bh------------>      <------------bh------------>

           ^   +--------------------------+      +--------------------------+
           |   |                +---------|----------------+       +--------------------------+
           |   |                |         |      |         |       |        |                 |
           |   |                |         |      |         |       |        |                 |
           |   |                |         |      |         |       |        |                 |
           |   |                |         |      |         |       |        |                 |
           bv  |                |         |      |         |       |        |                 |
           |   |                |         |      |         |       |        |                 |
     ^  ^  |   |+--------------------------+     |+--------------------------+                |
     |  |  |   ||               |+---------|----------------+      |+--------------------------+
     ov |  |   ||               ||        ||     ||        ||      ||       ||                ||
     |  |  |   ||               ||        ||     ||        ||      ||       ||                ||
     |  |  |   ||               ||        ||     ||        ||      ||       ||                ||
     v  |  v   +|----------------|--------+|     +|--------||------||-------+|                ||
        |       |               +|---------|------|--------+|      +|--------|----------------+|
        bv      |                |         |      |         |       |        |                 |
     ^  |      +--------------------------+|     +--------------------------+|                 |
     |  |  ^   ||               +---------|----------------+|      +--------------------------+|
     ov |  |   ||               ||        ||     ||        ||      ||       ||                ||
     |  |  |   ||               ||        ||     ||        ||      ||       ||                ||
     |  |  |   ||               ||        ||     ||        ||      ||       ||                ||
     v  v  |   |+---------------|---------|+     |+--------||------||-------|+                ||
           |   |                |+--------|------|---------|+      |+-------|-----------------|+
           |   |                |         |      |         |       |        |                 |
     ^  ^  bv  |+--------------------------+     |+--------------------------+                |
     |  |  |   ||               |+---------|----------------+      |+--------------------------+
     ov |  |   ||               ||        ||     ||        ||      ||       ||                ||
     |  |  |   ||               ||        ||     ||        ||      ||       ||                ||
     |  |  |   ||               ||        ||     ||        ||      ||       ||                ||
     v  |  |   +|----------------|--------+|     +|--------||------||-------+|                ||
        bv v    |               +|---------|------|--------+|      +|--------|----------------+|
        |       |                |         |      |         |       |        |                 |
        |       |                |         |      |         |       |        |                 |
        |       |                |         |      |         |       |        |                 |
        |       |                |         |      |         |       |        |                 |
        |       |                |         |      |         |       |        |                 |
        |       |                |         |      |         |       |        |                 |
        v       +--------------------------+      +---------|-------|--------+                 |
                                 +--------------------------+       +--------------------------+

                      bh=blocksize horizontal    bv=blocksize vertical
                      oh=overlap horizntal       ov=overlap vertical

overlapv

Vertical block overlap value. Default is equal to horizontal. Must be even for YV12 and less than block size.

outfile

Name of file to write motion vectors data, or an empty string (nothing written). This data may be used by some external program or may be by next MVTools versions for second pass coding, etc. Produced binary file has a header (`MVAnalysisData` structure, see `MVInterface.h` source code), and the data sequence:

- Frame number,
- vector data (Vx, Vy, SAD) of every block,
- next valid frame number,
- this frame vector data,
- and so on…

Important: using outfile in a multi-threaded context (Classic Avisynth MT modes 1, 2 and 4, or setting other than MT_SERIALIZED for Avisynth+) has an undefined behaviour and will generate a corrupted file. Note: Since 2.7.32 the filter registers itself automatically MT_SERIALIZED instead of MT_MULTI_INSTANCE under Avisynth+ when an output file is given

dct

Using of block DCT (frequency spectrum) for blocks difference (SAD) calculation. In particular it can improve motion vector estimation at luma flicker and fades.

0 | Usual spatial blocks, do not use DCT.
1 | Use block DCT instead of spatial data (slow for block size 8x8 and very slow for other sizes).
2 | Mixed spatial and DCT data; weight is dependent on mean frame luma difference.
3 | Adaptive per-block switching from spatial to equal-weighted mixed mode (experimental, a little faster).
4 | Adaptive per-block switching from spatial to mixed mode with more weight of DCT (experimental, a little faster).
5 | SATD instead of SAD for luma.
6 | Same as 2 only use SATD.
7 | Same as 3 only use SATD.
8 | Same as 4 only use SATD.
9 | Similar to 2, use SATD and weight ranges from SAD only to equal SAD & SATD.
10 | Similar to 3/4,use SATD weight is on SAD, only on strong luma changes.

Modes 5 to 10 were added in v1.9.5.3.

divide

post-processing motion vectors by dividing every block into 4 subblocks.

0 | Do not divide
1 | Divide blocks and assign the original vector to all 4 subblocks
2 | Divide blocks and assign median (with 2 neighbors) vectors to subblocks

Block size and overlap values must be selected to be acceptable after internal dividing.

sadx264

Use SAD functions from x264 codec if available for the blocksize

the parameter is ineffective in 2.7.x branch

0 | Autodetect CPU and select best function
1 | use MMX 16x16, 16x8, 8x8, 8x4, 4x4 (8x16, 4x8 used on chroma only)
2 | use MMX 16x16, 16x8, 8x8, 8x4 (8x16, used on chroma only) aligned to 32 Byte blocks
3 | use MMX 16x16, 16x8, 8x8, 8x4 (8x16, used on chroma only) aligned to 64 Byte blocks, best for Pentium M
4 | use SSE2 16x16, 16x8 (no special alignment)
5 | use SSE2 16x16, 16x8, aligned to 64 Byte blocks (good option on Core)
6 | use SSE3 16x16, 16x8 (seems only to work faster on Pentium 4E & Core1)
7 | use SSSES3 16x16, 16x8, aligned to 64 Byte blocks (good option on Core2)
8 | use SSD mmx, works on any mode as 1
9 | use SATD mmx, works on any mode as 1
10 | use SATD SSE2, works ony any mode like 2
11 | use SATD SSSE3, works ony any mode like 2
12 | use SATD SSSE3 with PHADD on 8xY, works ony any mode like 2

Modes 8-12 are meant for debug testing only, use dct > 4 instead. Using sadx264 > 7 means: use selected instead of SAD for any luma and chroma SAD where possible! For SAD and SATD mix and luma only use dct. Use -1 or ≥ 13 to use old v1.9.4 SAD algo and completely deactivate the x264 SAD functions.

badSAD

SAD threshold to make more wide second search for bad vectors. Value is scaled to block size 8x8. Default is 10000 (disabled), recommended is about 1000–2000.

badrange

The range (radius in image pixel units) of wide search for bad blocks. Use positive value for UMH search and negative for Exhaustive search.

meander

Alternate blocks scan in rows from left to right and from right to left. Default is True since v2.5.1.

temporal

Use temporal predictors from previous frame motion vectors. Not compatible with `SetMTMode` (classic Avisynth) or other than MT_SERIALIZED mode for Avisynth+, and requires a linear access to work correctly. Note: Since 2.7.32 the filter registers itself automatically MT_SERIALIZED instead of MT_MULTI_INSTANCE under Avisynth+ when temporal=true is given.

trymany

Try to start searches around many predictors (besides finest level).

multi

When set to true, MAnalyse generates the motion vectors for all the reference frames −delta…−1 and +1…+delta. The resulting clip is made of single MAnalyse results interleaved in the delta order −1, +1, −2, +2, …, −delta, +delta, where negative values indicate backward searchs. This order is similar to the motion vector parameters in `MDegrain3`. The output clip is intended to be used directly in `MDegrainN`. Single motion vector clips can be extracted with a `SelectEvery(delta*2, n)`.

mt

Enables internal multi-threading (through avstp.dll).

scaleCSAD

Fine tune chroma part weight in SAD calculation (since 2.7.18.22)

Possible values for luma:chroma SAD ratio
-2: 4:0.5
-1: 4:1
0: 4:2 (default, same as the native ratio for YV12)
1: 4:4
2: 4:8

#### Truemotion parameters

There are few advanced parameters which set coherence of motion vectors for so called true motion estimation. Some matched blocks from other frame may be most similar to sample blocks of current frame by intensity criterion (SAD), but not correspond to true object motion. For example, they may belong to other similar object in different corner of the frame or belong to some periodic structure. "True motion" parameters try maintain the motion field more coherent, instead of some random vectors distribution. It is especially important for partial motion compensation and interpolation. Some parameters are experimental and may be removed (replaced) in next versions after testing. Please report your conclusions.

truemotion

This is a preset of these parameters values. It allows easy to switch default values of all "true motion" parameters at once. Set it true for true motion search (high vector coherence), set it false to search motion vectors with best SAD. Default is true since v1.4.10. In any case you can tune each parameter individually.

lambda

Set the coherence of the field of vectors. The higher, the more coherent. However, if set too high, some best motion vectors can be missed. Values around 400–2000 (for block size 8) are strongly recommended. Internally it is coefficient for SAD penalty of vector squared difference from predictor (neighbors), scaled by 256. Default is 0 for truemotion = false and 1000*blksize*blksizeV/64 for truemotion = true.

lsad

SAD limit for lambda using. Local lambda is decreased (smoothly since v1.10.2) if SAD value of vector predictor (formed from neighbor blocks) is greater than the limit. It prevents bad predictors using but decreases the motion coherence. Values above 1000 are recommended for true motion. Scaled to 8x8 blocksize internally (since v2.0.11). Default is 400 for truemotion = false and 1200 for truemotion = true.

pnew

Relative penalty (scaled to 256) to SAD cost for new candidate vector. New candidate vector must be better will be accepted as new vector only if its SAD with penalty (SAD + SAD*pnew/256) is lower then predictor cost (old SAD). It prevent replacing of quite good predictors by new vector with a little better SAD but different length and direction. Default is 0 for truemotion = false and 50 for truemotion = true.

plevel

Penalty factor lambda level scaling mode. Dependence from hierarchical level size:

0 | No scaling
1 | Linear
2 | Quadratic

Note that vector length is smaller at lower level. Default is 0 for truemotion = false and 1 for truemotion = true.

global

Estimate global motion (at every level) and use it as an additional predictor. Only pan shift is estimated (no zoom and rotation). Use false to disable, use true to enable. Default is like truemotion.

### MCompensate

    MCompensate (
    	clip  source,
    	clip  super,
    	clip  vectors,
    	bool  scbehavior (true),
    	float recursion (0),
    	int   thSAD (10000),
    	bool  fields (false),
    	int   thSCD1,
    	int   thSCD2,
    	bool  isse,
    	bool  planar,
    	bool  mt (true),
    	int   tr (0),
    	bool  center (true),
    	clip  cclip (undefined),
    	int   thSAD2 (undefined)
    )

Do a full motion compensation of the frame. It means that the blocks pointed by the motion vectors in the reference frame will be moved along the vectors to reach their places in the current frame.

Overlapped blocks processing is implemented as window block summation (like FFT3DFilter, overlap value up to blksize / 2) for blocking artefactes decreasing.

super

This is multilevel super clip prepared by `MSuper` function. Mandatory. From 2.7.37 may more bit depths and formats supported: 8-32 bits, YUV420-422-444, Planar RGB, and YUY2 planar Super clip format must match with the source, but can be different from the base format of vector clip.

vectors

This is clip with motion vectors data produced by `MAnalyse` function. Mandatory. One can use vectors made from a 8 bit clip, independently from source and super clip format.

scbehavior

Decide which frame will be kept on a scene change. If true, the frame is left unchanged. Else, the reference frame is copied into the current one. Same for right and bottom padded area.

recursion

This is percent weight of previously compensated frames used for new compensation in special recursive mode. Rest weight is taken (uniformly) from given reference frame (used in ordinary mode). recursion = 100 is full recursion similar to in-loop mode = 2 of old MVTools v0.9.x. Do not use recursive mode unless you know what do you do.

thSAD

This is the SAD threshold for safe (dummy) compensation. If block SAD is above thSAD, the block is bad, and we use source block instead of the compensated block. Default value of 10000 means it is practically disabled.

fields

if set to true and pel = 2, 4, then we add appropriate vertical shift (by halfpixel) of fields for fieldbased video. Try using it for deinterlacing (not for denoising).

mt

Enables internal multi-threading (through avstp.dll).

tr

Allows generating multiple compensations using a multi-vector clip. Set tr to the temporal radius (same as delta used in `MAnalyse` with multi = true). A value of 0 indicates that normal compensation should be used.

Number, order and content of frames generated with tr > 0 depend on the center and cclip values.

center

In multi-compensation mode (tr > 0), indicates that the compensated frames should be centered around the original frame, or actually the frame from cclip. This arrangement is dedicated to temporal filters needing the motion-compensated previous and next frames. Therefore the output frames are arranged this way:

center | true | false
--- | --- | ---
Output rate | tr × 2 + 1 | tr × 2
Result for input frame N | Compensated | N + tr | Compensated | N + 1
Compensated | N + tr − 1 | Compensated | N − 1
Compensated | … | Compensated | …
Compensated | N + 1 | Compensated | …
Original or cclip | N | Compensated | N + tr − 1
Compensated | N − 1 | Compensated | N − tr + 1
Compensated | … | Compensated | N + tr
Compensated | N − tr + 1 | Compensated | N − tr
Compensated | N − tr | —

Where “Compensated N + x” indicates a backward compensation, using picture data from the next frames, and “Compensated N − x” denotes forward compensation, using picture data from the previous frames.

cclip

When multi-compensation mode is activated (tr > 0) and center = true, the center frames are taken from this clip. If cclip is undefined, frames are taken from the source clip.

thSAD2

Define the SAD soft threshold for the furthest frames. The actual SAD threshold for each reference frame is a smooth interpolation between the original thSAD (close to the current frame) and thSAD2. Setting thSAD2 lower than thSAD allows large temporal radii and good compensation for low SAD blocks while reducing the global error and the risk of bluring when the result of `MCompensate` is passed to a temporal denoising filter.

### MFlow

    MFlow (
    	clip  source,
    	clip  super,
    	clip  vectors,
    	float time (100.0),
    	int   mode (0),
    	bool  fields (false),
    	int   thSCD1,
    	int   thSCD2,
    	bool  isse,
    	bool  planar,
    	clip  tclip (undefined)
    )

Do a motion compensation of the frame not by blocks (like `MCompensate`), but by pixels. Motion vector for every pixel is calculated by bilinear interpolation of motion vectors of current and neighbor blocks (according to pixel position). It means that the pixels pointed by the vector in the reference frame will be moved (flow) along the vectors to reach their places in the current frame. This flow motion compensation method does not produce any blocking artefactes, and is good for denoising, but sometimes can create very strange deformed pictures. True motion estimation is strongly recommended for this function. Motion compensation may be full or partial (at intermediate time). Important limitation: vectors with components above 127 will be reset to zero length. (PF 20190212: this sentence may not be valid since 2.5.11.22?)

super

Multilevel super clip prepared by MSuper function. Mandatory.

vectors

Clip with motion vectors data produced by MAnalyse function. Mandatory.

time

Percent of motion compensation. Defines time moment between reference and current frame. A value of 100 means full compensation.

mode

0 | Fetch pixels to every place of destination. It is main producing mode.
1 | Shift pixels from every place of source (reference).

It is debug (learning) mode with some empty spaces (with null intensity). It can be used for occlusion mask creation.

fields

If set to true and pel = 2, 4, then we add appropriate vertical shifts (by halfpixel) of fields for fieldbased video. Try using it for deinterlacing (not for denoising).

tclip

If set, the time parameter is ignored. Then the time for the motion composation is applied pixel-wise. Each component of each pixel of tclip gives the time to be applied to the corresponding source clip pixel. The time scale is 256, meaning that 0 doesn't compensate anything, and 255 is an almost full compensation.

### MMask

    MMask (
    	clip  source,
    	clip  vectors,
    	float ml (100),
    	float gamma (1.0),
    	int   kind (0),
    	int   Ysc (0),
    	int   thSCD1,
    	int   thSCD2,
    	bool  isse,
    	bool  planar
    )

Creates mask clip from source clip with motion vectors data. Mask is defined by blocks data, but is interpolated to fit full frame size. The mask is created both on the luma and on chroma planes. Mask values may be from 0 (min) to 255 (max).

kind

Defines kind of mask:

0 | Motion Creates motion mask from the motion vectors length. It builds a better mask than `MotionMask` function of MaskTools plugin because motion vectors are a lot more reliable than the algorithm of MotionMask. Mask value 0 means no motion at all (the length of the motion vector is null). The longer vector length, the larger mask value (saturated to 255), the scale is defined by ml.
1 | SAD Allows to build a mask of the SAD (sum of absolute differences) values instead of the vectors' length. It can be useful to find problem areas with bad motion estimation. Internal factor blksize*blksizeV/4 is used for normalization of scale ml.
2 | Occlusion Allows to build a occlusion mask (bad blocks due to rupture, tensile). Currently, some normalized sum of positive blocks motion differences is used. It can be scaled with ml.
3 | Horizontal Allows to build a mask of horizontal component of motion vector in pel units plus 128. Scaled factors are not used.
4 | Vertical Allows to build a mask of vertical component of motion vector in pel units plus 128. Scaled factors are not used.
5 | Colormap Motion colormap as x, y components of motion vector shown in U, V color planes (in pel units plus 128, scaled factors are not used).

ml

Defines the scale of motion mask. When the vector's length (or other kind value) is superior or equal to ml, the output value is saturated to 255. The lesser value results to lesser output.

gamma

Defines the exponent of relation output to input. 1.0 implies a linear relation, whereas 2.0 gives a quadratic relation.

Ysc

This is the value taken by the mask on scene change.

### MSCDetection

    MSCDetection (
    	clip source,
    	clip vectors,
    	int  Ysc (255 or max. value of the current bit depth),
    	int  thSCD1,
    	int  thSCD2,
    	bool isse
    )

Creates scene detection mask clip from motion vectors data. The mask is created both on the luma and on chroma planes. Output without scene change is 0.

Ysc

This is the value taken by the mask on scene change. *The default value is the maximum value of the given bit depth, e.g. 1023 for 10 bits, 65535 for 16 bits When specified it will be clamped to a valid 0 and 2^bitdepth-1 range. This parameter was mistakenly named as Yth in all plugins <=2.7.24

### MShow

    MShow (
    	clip super,
    	clip vectors,
    	int  scale (1),
    	int  sil (0),
    	int  tol (20000),
    	bool showsad (false),
    	int  number (-1),
    	int  thSCD1,
    	int  thSCD2,
    	bool isse,
    	bool planar
    )

Shows the motion vectors on padded source by super clip opening (since v2.0.11).

scale

Allows to enlarge the motion vectors, in order for example to gain in accuracy (when pel > 1 and scale = 1, you can't see a variation of less than one pixel).

sil

Allows to see a different level of analysis (when searching for motion vectors, a hierarchical analysis is done, and it may be interesting to see what happens at higher levels).

tol

This is a tolerance threshold. If the distortion induced by the motion vector is over tol the vector isn't shown.

showsad

Allows to show the mean (scaled to block 8x8) SAD after compensating the picture and quantity (thSCD2) of bad (thSCD1) blocks. False shows all vectors.

number

Allows to mark given block (with this number) as white. −1 means the feature is disabled.

### MDepan

    MDepan (
    	clip,
    	clip   vectors,
    	clip   mask (undefined),
    	bool   zoom (true),
    	bool   rot (true),
    	float  pixaspect (1.0),
    	float  error (15.0),
    	bool   info (false),
    	string log (undefined),
    	float  wrong (10),
    	float  zerow (0.05),
    	int    range (0),
    	int    thSCD1,
    	int    thSCD2,
    	bool   isse,
    	bool   planar
    )

Get the motion vectors, estimate global motion and put data to output frame in special format for `DePan` plugin (by Fizick).

Inter-frame global motion (pan, zoom, rotation) is estimated by iterative procedure, with good blocks only.

Blocks are rejected if they fill at least one of the following conditions: 1) near frame borders or by mask; 2) with big SAD (by thSCD1 parameter); 3) with motion different from neighbors or global.

For global motion estimation of interlaced source, you must separate fields (for both MAnalyse and MDepan).

mask

This clip, if defined, is used to set weight of blocks vectors equal to correspondent mask frame pixels values (use deep black to reject block). If the mask clip is not defined, then 4 blocks at every border are rejected (old pre v2.4.3 algorithm.)

zoom, rot

Switch zoom and rotation estimation.

pixaspect

Pixel aspect ratio (1.091 for standard PAL 4:3, 0.909 for standard NTSC 4:3).

error

is maximum mean motion difference. The frame estimated global motion is switched to null for big motion error or at scene change (by thSCD1, thSCD2 parameters).

info

Allows to type global motion info for debug.

log

Allows to set log file name in `DeShaker` and `Depan` format.

wrong

Defines limit to disable blocks very different from neighbors.

zerow

Defines weight of zero motion vectors (to decrease its influence). (works from 2.7.27)

range

Number of previous (and also next) frames (fields) near requested frame to estimate their motion.

### MFlowInter

    MFlowInter (
    	clip  source,
    	clip  super,
    	clip  mvbw,
    	clip  mvfw,
    	float time (50.0),
    	float mL (100.0),
    	bool  blend (true),
    	int   thSCD1,
    	int   thSCD2,
    	bool  isse,
    	bool  planar,
    	clip  tclip (undefined)
    )

Motion interpolation function. It is not the same (but similar) as `MVInterpolate` function of older MVTools version. It uses backward mvbw and forward mvfw motion vectors to create picture at some intermediate time moment between current and next (by delta) frame. It uses pixel-based (by `MFlow` method) motion compensation from both frames. Internal forward and backward occlusion masks (`MMask` kind = 2 method) and time weighted factors are used to produce the output image with minimal artefacts. True motion estimation is strongly recommended for this function.

super

Multilevel super clip prepared by MSuper function. Mandatory

mvbw, mvfw

Clips with backward and forward motion vectors data produced by the `MAnalyse` function. Mandatory.

time

Interpolation time position between frames, in percent. Default value of 50.0 is half-way.

mL

Mask scale parameter. Lower values are corresponded to more strong occlusion mask (as in `MMask` function, use it to tune and debug).

blend

Blend frames at scene change like `ConvertFps` if true, or repeat last frame like `ChangeFps` if false.

tclip

If set, the time parameter is ignored. Then the time for the motion interpolation is applied pixel-wise. Each component of each pixel of tclip gives the time to be applied to the corresponding source clip pixel. The time scale is 256, meaning that 0 corresponds to the current frame, and 255 is an almost the next frame (128 is exactly half-way). A single occlusion mask is calculated with the luma-time only, therefore it is recommended to keep the chroma-time synchronized with the luma.

### MFlowFps

    MFlowFps (
    	clip  source,
    	clip  super,
    	clip  mvbw,
    	clip  mvfw,
    	int   num (25),
    	int   den (1),
    	int   mask (2),
    	float ml (100.0),
    	bool  blend (true),
    	int   thSCD1,
    	int   thSCD2,
    	bool  isse,
    	bool  planar
    )

Will change the framerate (fps) of the clip (and number of frames). The function can be use for framerate conversion, slow-motion effect, etc. It uses backward mvbw and forward mvfw motion vectors to create interpolated pictures at some intermediate time moments between frames. The function uses pixel-based motion compensation (as `MFlow`, `MFlowInter`). Internal forward and backward occlusion masks (`MMask` kind = 2 method) and time weighted factors are used to produce the output image with minimal artefacts. True motion estimation is strongly recommended for this function.

super

Multilevel super clip prepared by `MSuper` function. Mandatory

mvbw, mvfw

Clips with backward and forward motion vectors data produced by the `MAnalyse` function. Mandatory.

num, den

Output clip fps numerator and denominator. Resultant fps = num / den. In particular for doubled NTSC fps=2*29.97 use num = 60000 and den = 1001, and for doubled NTSC FILM fps=2*23.976 use num = 48000 and den = 1001. When num or den is equal to 0, then doubled fps of input clip is assumed for output (since v1.8.1).

mask

Processing mask mode:

0 | Simple backward and forward occlusion masks (used in versions up to 1.4.x, fastest)
1 | Similar masks with additional switching to static zero vectors at occlusion areas (similar to v1.5.x)
2 | For using extra vectors from adjacent frames for decreasing objects halo at occlusion areas (v1.8, slowest).

ml

Mask scale parameter. The greater values are corresponded to more weak occlusion mask (as in `MMask` function, use it to tune and debug).

blend

Blend frames at scene change like `ConvertFps` if true, or repeat last frame like `ChangeFps` if false.

### MBlockFps

    MBlockFps (
    	clip,
    	clip  super,
    	clip  mvbw,
    	clip  mvfw,
    	int   num (25),
    	int   den (1),
    	int   mode (0),
    	float thres (0),
    	bool  blend (true),
    	int   thSCD1,
    	int   thSCD2,
    	bool  isse,
    	bool  planar
    )

The function uses block-based partial motion compensation to change the framerate (fps) of the clip (and number of frames). It uses backward mvbw and forward mvfw motion vectors to create interpolated pictures at some intermediate time moments between frames. Some internal forward and backward masks and time weighted factors are used to produce the output image. (Algorithm is based on `MVInter` function of old MVTools v1.9.12). It is usually faster than `MFlowFps` but may produce blocking and other artefacts. True motion estimation is strongly recommended for this function. Some pixels at right and bottom which are not entirely covered by blocks will be produced by frames blending.

super

Multilevel super clip prepared by `MSuper` function. Mandatory

mvbw, mvfw

Clips with backward and forward motion vectors data produced by the `MAnalyse` function. Mandatory.

num, den

Output clip fps numerator and denominator. Resultant fps = num / den. In particular for doubled NTSC fps=2*29.97 use num = 60000 and den = 1001, and for doubled NTSC FILM fps=2*23.976 use num = 48000 and den = 1001. When num or den is equal to 0, then doubled fps of input clip is assumed for output.

mode

Processing mode:

0 | Average of fetched forward and backward partial motion compensation (fastest).
1 | Static median.
2 | Dynamic median.
3 | Time weigthed combination of fetched forward blocks masked by shifted backward and fetched backward masked by shifted forward.
4 | Mode 3 mixed with simple static time average by occlusion mask of shifted blocks.
5 | Occlusion mask (for debug).

thres

Threshold for count of occlusions per block for mask binarization. A value of 0 is internally blksize*blksizeV/4.

blend

Blend frames at scene change like `ConvertFps` if true, or repeat last frame like `ChangeFps` if false.

### MFlowBlur

    MFlowBlur (
    	clip,
    	clip  super,
    	clip  mvbw,
    	clip  mvfw,
    	float blur (50.0),
    	int   prec (1),
    	int   thSCD1,
    	int   thSCD2,
    	bool  isse,
    	bool  planar
    )

Experimental simple motion blur function. It may be used for FILM-effect (to simulate finite shutter time). It uses backward mvbw and forward mvfw motion vectors to create and overlay many copies of partially compensated pixels at intermediate time moments in some blurring interval around current frame. It uses pixel-based motion compensation (as `MFlow`). True motion estimation is strongly recommended for this function.

super

Multilevel super clip prepared by `MSuper` function. Mandatory

mvbw, mvfw

Clips with backward and forward motion vectors data produced by the `MAnalyse` function. Mandatory.

blur

Blur time interval between frames, open shutter time in percent.

prec

Blur precision in pixel units. Maximal step between compensated blurred pixels. 1 is the most precise.

### MDeGrain1, MDeGrain2, MDegrain3, MDegrain4, MDegrain5, MDegrain6 and MDegrainN

    MDeGrain1 (
    	clip,
    	clip super,
    	clip mvbw,
    	clip mvfw,

    	int  thSAD (400),
    	int  thSADC (thSAD),
    	int  plane (4),
    	int  limit (255),
    	int  limitC (limit),
    	int  thSCD1,
    	int  thSCD2,
    	bool isse,
    	bool planar,
    	bool lsb (false),
    	bool out16 (false)
    )
    MDeGrain2 (
    	clip,
    	clip super,
    	clip mvbw,
    	clip mvfw,
    	clip mvbw2,
    	clip mvfw2,
    	int  thSAD (400),
    	int  thSADC (thSAD),
    	int  plane (4),
    	int  limit (255),
    	int  limitC (limit),
    	int  thSCD1,
    	int  thSCD2,
    	bool isse,
    	bool planar,
    	bool lsb (false),
    	bool out16 (false)
    )
    MDeGrain3...MDeGrain6 (
    	clip,
    	clip super,
    	clip mvbw,
    	clip mvfw,
    	clip mvbw2,
    	clip mvfw2,
    	clip mvbw3,
    	clip mvfw3,
    	[clip mvbw4,]
    	[clip mvfw4,]
    	[clip mvbw5,]
    	[clip mvfw5,]
    	[clip mvbw6,]
    	[clip mvfw6,]
    	int  thSAD (400),
    	int  thSADC (thSAD),
    	int  plane (4),
    	int  limit (255),
    	int  limitC (limit),
    	int  thSCD1,
    	int  thSCD2,
    	bool isse,
    	bool planar,
    	bool lsb (false),
    	bool out16 (false)

    )
    MDeGrainN (
    	clip,
    	clip super,
    	clip mvmulti,
    	int  tr,
    	int  thSAD (400),
    	int  thSADC (thSAD),
    	int  plane (4),
    	int  limit (255),
    	int  limitC (limit),
    	int  thSCD1,
    	int  thSCD2,
    	bool isse,
    	bool planar,
    	bool lsb (false),
    	int  thSAD2 (thSAD),
    	int  thSADC2 (thSADC),
    	bool mt (true),
    	bool out16 (false)
    )

Makes a temporal denoising with motion compensation. Blocks of previous and next frames are motion compensated and then averaged with current frame with weigthing factors depended on block differences from current (SAD). Functions support overlapped blocks mode.

Overlaped blocks processing is implemented as window block summation (like `FFT3DFilter`, overlap value up to blksize / 2) for blocking artefactes reduction.

`MDeGrain1` has temporal radius of 1 and uses vectors of previous mvfw and next mvbw frames.

`MDeGrain2` has temporal radius of 2 and uses vectors of two previous mvfw2, mvfw and two next mvbw, mvbw2 frames.

`MDeGrain3` .. `MDeGrain6` has temporal radius of 3..6 and uses vectors of previous mvfw6, ... mvfw3, mvfw2, mvfw and next mvbw, mvbw2, mvbw3 ... mvbw6 frames. It is slower, but produces a little better results (stronger denoising).

`MDeGrainN` has a temporal radius given by the tr parameter, and uses a special motion vector clip.

super

Multilevel super clip prepared by `MSuper` function. Mandatory. Its format has to match to the source clip's format. Since v2.7.25 source and super clip's bit depth can be different that of motion vectors! It is possible to Degrain a 16 or 32 bit clip (and Super) with motion vectors created from a 8 bit clip. Versions over 2.7.39 are giving full freedom: even subsampling can be different from the motion vector base clip's data.

mvbw, mvfw, mvbw2, mvfw2, mvbw3, mvfw3, mvmulti

Clips with backward and forward motion vectors data produced by the `MAnalyse` function. mvmulti is a multi-vector clip generated in multi = true mode. Mandatory.

thSAD

Defines the soft threshold of block sum absolute differences. Block with SAD above threshold thSAD have a zero weight for averaging (denoising). Block with low SAD has highest weight. Rest of weight is taken from pixels of source clip. The provided thSAD value is scaled to a 8x8 blocksize. Low values can result in staggered denoising, large values can rezult in ghosting and artefacts.

thSADC

Threshold for chroma planes. If not defined, the thSAD value is used for chroma. If defined then thSADCis used for chroma and thSAD is used for luma.

plane

parameter set procesed color plane:

0 | Luma
1 | Chroma U
2 | Chroma V
3 | Both chromas
4 | All

limit

Maximal change of pixel luma. This is a post-processing like the `DeGrainMedian` plugin and `LimitChange` function from the SSETools plugin, to prevent some artefacts). Value is 0 to 255. 255 does nothing. Other values are scaled proportionally for the given bit depth.

limitC

Maximal change of pixel chroma.

lsb

Note: since 2.7.26 "out16" is available for native 16bit output. The option generates 16-bit data from 8 bit inputs when set to true. The picture made of the most siginificant bytes (MSB) is stacked on the top of the least significant byte (LSB) block. Hence a twice taller resulting picture. You can extract the MSB or the LSB with a simple Crop() call. This mode helps recovering the full bitdepth of temporally dithered data.

tr

Temporal radius, > 0. Must match the mvmulti content, i.e. the delta parameter in `MAnalyse`.

thSAD2, thSADC2

Parameter is for MDegrainN Define the SAD soft threshold for the furthest frames. The actual SAD threshold for each reference frame is a smooth interpolation between the original thSAD (close to the current frame) and thSAD2. Setting thSAD2 lower than thSAD allows large temporal radii and good efficiency for low SAD blocks while reducing the risk of bluring.

mt

Enables internal multi-threading (through avstp.dll).

out16

Since 2.7.26. Generates 16-bit data from 8 bit inputs when set to true. It is like lsb=true but the output format is native 16bits. A bit faster than lsb=true. Cannot be mixed with lsb=true.

### MRecalculate

    MRecalculate (
    	clip super,
    	clip vectors,
    	int  thSAD (200),
    	int  smooth (1),
    	int  blksize,
    	int  blksizeV,
    	int  search,
    	int  searchparam,
    	int  lambda,
    	bool chroma,
    	bool truemotion,
    	int  pnew,
    	int  overlap,
    	int  overlapV,
    	string outfile,
    	int  dct,
    	int  divide,
    	int  sadx264,
    	bool isse,
    	int  tr
    	int  scaleCSAD (0)
    )

Refines and recalculates motion data of previously estimated (by `MAnalyse`) motion vectors with different super clip or new parameters set (e.g. lesser block size), after divide, etc. The two-stage method may be also useful for more stable (robust) motion estimation. The refining is at finest hierarchical level only. Interpolated vectors of old blocks are used as predictors for new vectors, with recalculation of SAD. Only bad quality new vectors with SAD above threshold thSAD will be re-estimated by search. thSAD value is scaled to 8x8 block size. Good vectors are not changed, but their SAD will be re-calculated and updated.

You must set the tr variable if you process "multi" motion vector clips.

Parameters not described below have the same meaning as in `MAnalyse`, but you can use other values. Their default settings are same as in `MAnalyse`.

smooth

This is method for dividing coarse blocks into smaller ones.

0 | Use motion of nearest block.
1 | Bilinear interpolation of 4 neighbors.

tr

This is the temporal radius for motion vector clips generated by `MAnalyse` with multi = true. Default 0 (normal vector clip).

### MScaleVect

    MScaleVect (
    	clip  vectors,
    	float scale (bits == 0 ? 2 : 1),
    	float scaleV (scale),
    	int   mode (0),
    	bool  flip (scale < 0 && scale == scaleV)
    	bool  adjustSubPel (false),
    	int   bits (0)
    )

Rescales motion vectors / blocksize. Main purpose is to allows vectors to be used on a differently sized clip or on a clip having different bit depth (2.7.24-) than they were analyzed from.

Example steps:

1. Use `MAnalyze` on a half-sized clip at block size 16
2. Use this plugin to scale the vectors by 2 to block size 32
3. 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 (can be easier to set hpad = 0 and vpad = 0 everywhere). See the example below. Similar functionality was available in MVTools through the function `MVIncrease`, but it was removed.

The function returns a new motion vector clip.

vectors

Motion vectors returned from `MAnalyse` or `MRecalculate`, in multi mode or not. Mandatory.

scale, scaleV

The amount to scale the vectors, scale is the horizontal scaling, scaleV is the vertical scaling. Exact meaning depends on mode. Default value is 2.0, except when bits is given (in this case 1.0)

mode

0 | Increase scale of vectors and blocksize. Only scale values of 1, 2, 4 or 8 are allowed. Mode 0 allows you to `MAnalyze` at a smaller size, then process (`MDeGrain`, `MFlowFPS`, whatever) at full size.
1 | Decrease scale of vectors and blocksize. Only scale values of 1, 2, 4 or 8 are allowed. Mode 1 allows you to `MAnalyze` at full size, but have some subsequent processes run at a smaller size.
2 | Only scale vectors, leave blocksize unchanged. Any floating point scale value is allowed (including negative). Mode 2 is for esoteric uses, for example approximating backward vectors from forward ones, or for extrapolation.

flip

Whether to flag forward vectors as backward vectors, and vice versa. Only applies to mode = 2. Default is true if scale is negative and equal to scaleV. I.e. if you reverse the vectors it will default to flip their direction.

adjustSubPel

Set to true in mode = 0, 1 to perform scaling by adjusting subpel rather than scaling vectors. scale must be equal to scaleV. Experimental.

bits

Change the bit depth that the motion vector clip is reporting. Possible values: 0 (default), 8, 10, 12, 14, 16. Value of 0 does not change bit depth. During the conversion SAD values for each block are scaled according to the bit-depth difference. The scaling factor is 2^(bits - source_bit_depth) with rounding when scaling down. E.g. analyze your clip in 8 bits (faster), then use vectors for a 16 bit super clip by setting bits=16

This parameter can be combined with x and y scaling. Warning: when this parameter exists and is nonzero then the default value of scale is 1.0 instead of 2.0.

#### Example

    clip = YourSource( "Your\Video" )

    # Half size clip
    clipScaled = clip.BicubicResize( clip.Width()/2, clip.Height()/2 )

    # Half size padding (may be easier to always set hpad and vpad to 0)
    superScaled = clipScaled.MSuper( pel=2, hpad=16/2,vpad=16/2 )

    # Analyze half-size clip - faster, uses less memory
    bVecScaled  = superScaled.MAnalyse( blksize=8, isb=true )
    fVecScaled  = superScaled.MAnalyse( blksize=8, isb=false )

    # Scale vectors increasing block size to 16 for use on full size clip
    bVec = bVecScaled.MScaleVect( 2 )
    fVec = fVecScaled.MScaleVect( 2 )

    # Full size clip, full size padding
    super = clip.MSuper( pel=2, hpad=16,vpad=16 )

    # Use scaled vectors to operate on full size clip
    clip.MFlowFPS( super, bVec, fVec, den=0 )

### MStoreVect

    MStoreVect (
    	clip   vectors, ...,
    	string vccs ("")
    )

Stores (multiple) motion vectors in a encodable clip. Allows you to encode vectors to a file (must use a lossless format, suggest Lagarith for RGBA). Convenient for splitting up very slow scripts (e.g. calculate vectors and save in pass 1, load vectors and process in stage 2). Can also use to process the same footage in multiple ways. Use `MRestoreVect` to get the motion vectors back out of the clip.

You can store as many sets of vectors as you wish in a single clip, as long as the clips have the same length. It's possible to store a multi-vector clip too. The clip can be in any of the supported colorspaces; its width and height will vary depending on the contained clips, but the height will always be divisible by 2.

The function returns a clip that contains the provided motion vectors.

vectors

MVTools vectors clip, you may pass as many clips as you wish.

vccs

Colorspace of the output clip. Only "RGB32", "RGB24" and "YUY2" are currently supported. Default (empty string) is RGB32.

#### Example

    clip = YourSource( "Your\Video" )
    super = clip.MSuper()
    bVec1 = super.MAnalyse( isb=true )
    fVec1 = super.MAnalyse( isb=false )
    vectors = MStoreVect( bVec1, fVec1 )
    # Losslessly encode the 'vectors' clip to a file (e.g. Lagarith)

### MRestoreVect

    MRestoreVect (
    	clip store,
    	int  index (0)
    )

Fetches a single motion vector clip from a special clip prepared earlier by `MStoreVect` (see above). Call multiple times if there are several clips stored.

The function returns a single motion vectors clip.

store

A clip created by `MStoreVect`.

index

The zero-based index of the vectors to restore, used when multiple vector clips were stored. I.e. index 0 recovers the first vectors stored in the clip, index 1 the second, etc.

#### Example

    clip = YourSource( "Your\Video" )

    # Created using MStoreVectors above, losslessly encoded
    vectors = AviSource( "MotionVectors.avi" )

    # See example above for MStoreVectors, gets the first of the two stored vector clips
    bVec1 = vectors.MRestoreVect( 0 )
    fVec1 = vectors.MRestoreVect( 1 )
    clip.MFlowFPS( super, bVec1, fVec1, den=0 )

## IV) Examples

To show the motion vectors ( forward ) :

    AVISource("c:\test.avi") # or MPEG2Source, DirectShowSource, some previous filter, etc
    Last=MSuper()                                           # Assigns implicit last with Super clip
    vectors = Last.MAnalyse(isb = false)                    # Implicit Last = super, 1st arg
    Last.MShow(vectors)                                     # Implicit Last = super, 1st arg

To show the backward one :

    AVISource("c:\test.avi") # or MPEG2Source, DirectShowSource, some previous filter, etc
    Last=MSuper()                                           # Assigns implicit last with Super clip
    vectors = Last.MAnalyse(isb = true)                     # Implicit Last = super, 1st arg
    Last.MShow(vectors)                                     # Implicit Last = super, 1st arg

To use MMask :

    AVISource("c:\test.avi") # or MPEG2Source, DirectShowSource, some previous filter, etc
    vectors = MSuper().MAnalyse(isb = false)
    MMask(vectors)

To use MDepan with Depan plugin for interlaced source (DepanStabilize function example):

    AVISource("c:\test.avi") # or MPEG2Source, DirectShowSource, some previous filter, etc
    AssumeTFF().SeparateFields() # set correct fields order
    vectors = MSuper().MAnalyse(isb = false)
    globalmotion = MDepan(vectors, pixaspect=1.094, thSCD1=400)
    DepanStabilize(data=globalmotion, cutoff=2.0, mirror=15, pixaspect=1.094)
    Weave()

To blur problem (blocky) areas of compensated frame with occlusion mask:

    AVISource("c:\test.avi") # or MPEG2Source, DirectShowSource, some previous filter, etc
    super = MSuper()
    vectors = MAnalyse(super, isb = false)
    compensation = MCompensate(super,vectors) # or use MFlow function here
    # prepare blurred frame with some strong blur or deblock function:
    blurred = compensation.DeBlock(quant=51) # Use DeBlock function here
    badmask = MMask(vectors, kind = 2, ml=50)
    overlay(compensation,blurred,mask=badmask) # or use faster MaskedMerge function of MaskTools

To recreate bad frames by interpolation with MFlowInter:

    AVISource("c:\test.avi") # or MPEG2Source, DirectShowSource, some previous filter, etc
    super = MSuper()
    backward_vectors = MAnalyse(super, isb = true, delta=2)
    forward_vectors = MAnalyse(super, isb = false, delta=2)
    inter = MFlowInter(super, backward_vectors, forward_vectors, time=50, ml=70)
    # Assume bad frames are 50 and 60
    trim(0,49) ++ inter.trim(49,-1) \
     ++ trim(51,59) ++ inter.trim(59,-1) ++ trim(61,0)

To change fps with MFlowFps:

    AVISource("c:\test.avi") # or MPEG2Source, DirectShowSource, some previous filter, etc
    # assume progressive PAL 25 fps source
    super = MSuper(pel=2)
    backward_vec = MAnalyse(super, isb = true)
    forward_vec = MAnalyse(super, isb = false)
    MFlowFps(super, backward_vec, forward_vec, num=50, den=1, ml=100) # get 50 fps

To double fps with MFlowFps for fastest (almost) real-time playing:

    AVISource("c:\test.avi") # or MPEG2Source, DirectShowSource, some previous filter, etc
    # assume progressive PAL 25 fps or NTSC Film 23.976 source
    super = MSuper(pel=1,hpad=0,vpad=0)
    backward_vec = MAnalyse(super, blksize=32, isb = true, chroma=false, searchparam=1,search=0)
    forward_vec = MAnalyse(super, blksize=32, isb = false, chroma=false, searchparam=1,search=0)
    MFlowFps(super, backward_vec, forward_vec, num=2*FramerateNumerator(last), \
       den=FramerateDenominator(last), mask=0)

To double fps with MFlowFps for 'best' results (but slower processing):

    AVISource("c:\test.avi") # or MPEG2Source, DirectShowSource, some previous filter, etc
    # assume progressive PAL 25 fps or NTSC Film 23.976 source
    super = MSuper(pel=2)
    backward_vec = MAnalyse(super, overlap=4, isb = true, search=3)
    # Use block overlap, halfpixel accuracy and Exhaustive search
    forward_vec = MAnalyse(super, overlap=4, isb = false, search=3)
    MFlowFps(super, backward_vec, forward_vec, num=2*FramerateNumerator(last), \
       den=FramerateDenominator(last))

To generate nice motion blur with MFlowBlur:

    AVISource("c:\test.avi") # or MPEG2Source, DirectShowSource, some previous filter, etc
    super = MSuper()
    backward_vectors = MAnalyse(super, isb = true)
    forward_vectors = MAnalyse(super, isb = false)
    MFlowBlur(super, backward_vectors, forward_vectors, blur=15)

To denoise with some external denoiser filter (which uses 3 frames: prev, cur, next):

    AVISource("c:\test.avi") # or MPEG2Source, DirectShowSource, some previous filter, etc
    super = MSuper()
    backward_vectors = MAnalyse(super, isb = true)
    forward_vectors = MAnalyse(super, isb = false)
    forward_compensation = MFlow(super, forward_vectors, thSCD1=500) # or use MCompensate
    backward_compensation = MFlow(super, backward_vectors, thSCD1=500)
    # create interleaved 3 frames sequences
    interleave(forward_compensation, last, backward_compensation)

    DeGrainMedian() # place your preferred temporal (spatial-temporal) denoiser here

    selectevery(3,1) # return filtered central (not-compensated) frames only

To use prefiltered clip for more reliable motion estimation, but compensate motion of not-prefiltered clip (denoising example)

    AVISource("c:\test.avi") # or MPEG2Source, DirectShowSource, some previous filter, etc
    # Use some denoiser (blur) or deflicker for prefiltering
    prefiltered = blur(1.0)
    super = MSuper(levels=1) # one level is enough for MCompensate
    superfilt = MSuper(prefiltered) # all levels for MAnalyse
    backward_vectors = MAnalyse(superfilt, isb = true)
    forward_vectors = MAnalyse(superfilt, isb = false)
    # use not-prefiltered (super) clip for motion compensation
    forward_compensation = MCompensate(super, forward_vectors)
    backward_compensation = MCompensate(super, backward_vectors)
    # create interleaved 3 frames sequences
    interleave(forward_compensation, last, backward_compensation)

    DeGrainMedian() # place your preferred temporal (spatial-temporal) denoiser here

    selectevery(3,1) # return filtered central (not-compensated) frames only

To denoise by MDegrain2 with overlapped blocks (blksize=8) and subpixel precision:

    AVISource("c:\test.avi") # or MPEG2Source, DirectShowSource, some previous filter, etc
    super = MSuper(pel=2, sharp=1)
    backward_vec2 = MAnalyse(super, isb = true, delta = 2, overlap=4)
    backward_vec1 = MAnalyse(super, isb = true, delta = 1, overlap=4)
    forward_vec1 = MAnalyse(super, isb = false, delta = 1, overlap=4)
    forward_vec2 = MAnalyse(super, isb = false, delta = 2, overlap=4)
    MDegrain2(super, backward_vec1,forward_vec1,backward_vec2,forward_vec2,thSAD=400)

To denoise by MDegrainN with a large radius:

    AVISource("c:\test.avi") # or MPEG2Source, DirectShowSource, some previous filter, etc
    tr = 6 # Temporal radius
    super = MSuper ()
    multi_vec = MAnalyse (super, multi=true, delta=tr)
    MDegrainN (super, multi_vec, tr, thSAD=400, thSAD2=150)

To denoise interlaced source by MDegrain1 with overlapped blocks (blksize=8) and subpixel precision:

    AVISource("c:\test.avi") # or MPEG2Source, DirectShowSource, some previous filter, etc
    fields=AssumeTFF().SeparateFields() # or AssumeBFF
    super = MSuper(fields)
    backward_vec2 = MAnalyse(super, isb = true, delta = 2, overlap=2)
    forward_vec2 = MAnalyse(super, isb = false, delta = 2, overlap=2)
    MDegrain1(fields, super, backward_vec2,forward_vec2,thSAD=400)
    Weave()

To denoise interlaced source with function MDegrain2i2:

    function MDegrain2i2(clip source, int "overlap", int "dct")
    {
    overlap=default(overlap,0) # overlap value (0 to 4 for blksize=8)
    dct=default(dct,0) # use dct=1 for clip with light flicker
    fields=source.SeparateFields() # separate by fields
    super = fields.MSuper()
    backward_vec2 = super.MAnalyse(isb = true, delta = 2, overlap=overlap, dct=dct)
    forward_vec2 = super.MAnalyse(isb = false, delta = 2, overlap=overlap, dct=dct)
    backward_vec4 = super.MAnalyse(isb = true, delta = 4, overlap=overlap, dct=dct)
    forward_vec4 = super.MAnalyse(isb = false, delta = 4, overlap=overlap, dct=dct)
    fields.MDegrain2(super, backward_vec2,forward_vec2,backward_vec4,forward_vec4,thSAD=400)
    Weave()
    }

    AVISource("video.avi")
    mdegrain2i2(4,0)

How to use external subpixel interpolation clip:

    # Load Eedi2 plugin (by tritical) with edge-directed interpolation function
    LoadPlugin("Eedi2.dll")
    AVISource("c:\test.avi") # or MPEG2Source, DirectShowSource, some previous filter, etc
    # create upsampled clip of source
    ups = EEDI2(field=1).LanczosResize(2*width(last), 2*height(last), src_left=0.25)
    super = MSuper(pel=2, pelclip=ups)
    bv = MAnalyse(super, isb = true, overlap=4)
    MCompensate(super, bv)

How to use with MT filter and special multithreaded AviSynth:

    # Load MT plugin by TSP
    LoadPlugin("MT.dll")
    avisource("some.avi")
    MT("""
    super = MSuper(pel=2, sharp=1)
    backward_vec2 = super.MAnalyse(isb = true, delta = 2, overlap=4)
    backward_vec1 = super.MAnalyse(isb = true, delta = 1, overlap=4)
    forward_vec1 = super.MAnalyse(isb = false, delta = 1, overlap=4)
    forward_vec2 = super.MAnalyse(isb = false, delta = 2, overlap=4)
    MDegrain2(super, backward_vec1,forward_vec1,backward_vec2,forward_vec2,thSAD=400)
    """,2) # two threads

Note: SetMTMode(2) mode of multithreaded AviSynth is also supported since MVTools v.1.8.4.1 (beta testing). MVtools version 2 should works more stable. Same example with SetMTMode:

    SetMTMode(5)
    FFmpegSource("some.avi") # avisource doesn't work with SetMTMode on my machines - TSchniede

    SetMTMode(2)
    super = MSuper(pel=2)
    backward_vec2 = MAnalyse(super, isb = true, delta = 2, overlap=4)
    backward_vec1 = MAnalyse(super, isb = true, delta = 1, overlap=4)
    forward_vec1 = MAnalyse(super, isb = false, delta = 1, overlap=4)
    forward_vec2 = MAnalyse(super, isb = false, delta = 2, overlap=4)
    MDegrain2(super, backward_vec1,forward_vec1,backward_vec2,forward_vec2,thSAD=400)

How to use prefiltered clip and recalculate motion data with original source (MFlowFPS example)

    AVISource("c:\test.avi") # or MPEG2Source, DirectShowSource, some previous filter, etc
    prefiltered = DeGrainMedian() # some smoothing
    super = MSuper(hpad=16, vpad=16, levels=1) # one level is enough for MRecalculate
    superfilt = MSuper(prefiltered, hpad=16, vpad=16) # all levels for MAnalyse
    backward = MAnalyse(superfilt, isb = true, blksize=16)
    forward = MAnalyse(superfilt, isb = false, blksize=16)
    # recalculate for original source clip and other block size
    forward_re = MRecalculate(super, forward, blksize=8, thSAD=100)
    backward_re = MRecalculate(super, backward, blksize=8, thSAD=100)
    MFlowFps(super, backward_re, forward_re, num=50, den=1)

How to use planar option for faster processing of YUY2 (MDegrain3 example):

    LoadPlugin("SSEToolsS.dll") # for conversion functions
    AVISource("c:\test.avi") # or MPEG2Source, DirectShowSource, some previous filter, etc
    Interleaved2Planar() # convert clip to planar
    super = MSuper(planar=true)
    bv1 = MAnalyse(super, isb = true, delta = 1, overlap=4)
    fv1 = MAnalyse(super, isb = false, delta = 1, overlap=4)
    bv2 = MAnalyse(super, isb = true, delta = 2, overlap=4)
    fv2 = MAnalyse(super, isb = false, delta = 2, overlap=4)
    bv3 = MAnalyse(super, isb = true, delta = 3, overlap=4)
    fv3 = MAnalyse(super, isb = false, delta = 3, overlap=4)
    MDegrain3(super,bv1,fv1,bv2,fv2,bv3,fv3,thSAD=400,planar=true)
    Planar2Interleaved() # convert back to normal interleave YUY2

## V) Disclaimer

This plugin is distributed under terms of the GNU GPL license, without any warranty. See `gpl.txt`. Some parts of the code are under the WTFPL, too.

Documentation is distributed under CreativeCommons BY-SA 3.0 license.

MVTools uses portions of code from the following projects:

- Resizer (`SimpleResize.cpp`) is from `SimpleResize` Avisynth plugin by Tom Barry.
  http://www.trbarry.com

- Fast DCT (`fdct_mmx.asm`) is from XVID MPEG-4 VIDEO CODEC.
  http://www.xvid.org

- DCT general transform (see `fftwlite.h`) is from FFTW library (as DLL call).
  http://www.fftw.org

- SATD (`pixel-32.asm, pixel.asm`) and alternative SADx264 (`sad-a.asm, x86inc.asm, x86inc-32.asm, cpu-32.asm`) are from x264 project (Loren Merritt, Laurent Aimar, Alex Izvorski et al).
  http://www.videolan.org/developers/x264.html
- Since 2.7.18.22 SAD functions from the x265 project are used (Loren Merritt, Fiona Glaser, Laurent Aimar, Alex Izvorski, Min Chen et al).
  https://github.com/videolan/x265/tree/master/source/common/x86

## VI) Revisions

2.7.41 (20190502)

- Fix: regression since 2.7.35: MSuper chroma for non-planar YUY2 (Thanks to mkauf)
- Project moved to Visual Studio 2019, v141_xp and v142 toolset
- (New: DepanStabilize: planar RGB support (8-16bit) - see also there
  Generate motion vectors with mvtools MDepan, use it for DepanStabilize. Input clip can be planar RGB.)

2.7.40 (20190212)

- Fix: MFlowInter possible crash with specific parameter and colorspace settings.
- Fix: MFlowInter possible overflow at 16 bit clips (artifacts)
- MFlow, MFlowInter, MFlowFPS, MFlowBlur, MBlockFPS: support all 8-16 and 32 bit float Y, YUV (4:2:0, 4:2:2, 4:4:4) and planar RGB color spaces.
  Input clip (and super) format now is fully independent from vector clip's base format (subsampling had to be the same before)
  E.g. make motion vector clips from a YV12 source and apply them on a 8-32 bit 4:4:4 input

2.7.39 (20190102)

- MSuper: fix 16 bits, pel=2, sharp=2, which caused bottom section artifacts for MDegrains for 8 bit vector origin and 16 bit real clip
- MDegrain1-6,N: Enhanced:
  Input clip (and super) format now is fully independent from vector clip's base format (subsampling had to be the same before)
  E.g. make motion vector clips from a YV12 source and apply them on a 8-32 bit 4:4:4 input

2.7.38 (20181209)

- MCompensate: Fix regression in latest v37: MCompensate w/ overlap=0 crash
- MAnalyze DCT: FFTW float: quicker postprocess of DCT'd blocks, now is correct for non power-of-2 block sizes e.g. 12x12 or 24x24 (no effect on 8x8 for which fast integer DCT is used)
- MAnalyze DCT: more consistent handling of post DCT internal normalization for non-square block sizes.

2.7.37 (20181128)

- MCompensate: limit thSAD, thSAD2, thSCD1 to valid range 0-(8x8x255) (e.g. given thSAD = 100000 will go back to 16320)
- Fix: MCompensate: use int64 to avoid effective thSAD and thSAD2 overflow typically happen at bigger block sizes or large thSAD parameter value.
- MCompensate: SSE2 (8bit) and SSE4 (10-16 bit) overlap result calculation
- Changed: SAD 8x8, 8x4, 4x4, 4x8 to use SSE2 instead of MMX registers
- Fix: MDegrain if overlap<>0: missing rounder in rightmost 8 pixels for non-mod8 width 8 bit clips
- Fix: MSuper artifacts at 10-32 bits and nPel==4
- New: MCompensate 32 bit float and planar RGB support (by using motion vectors made from 8-16 bit YUV clip). Input and super clip can be of a different format than the one used for motion vector creation. (Similar to MDegrain1-6)

2.7.36 (20181120)

- Fix: Allow overlap operation when there are only two blocks in either horizontal or vertical direction (was: division by 0 crash)
- Fix: Fallback to overlap=0 mode when block count is only 1 in either h or v direction (was: undefined behaviour)
  The cases above occured for small frame sizes, when frame size and overlap values resulted in less than 3 blocks in a direction.
- Misc: update html docs with overlap drawing and others.

2.7.35 (20181113)

- MFlowXXX: Slight speed gain by putting the out-of-frame vector check to resizer
- MAnalyze: Fix a possible internal overflow on larger blocksizes with small overlap e.g. BlkSize=32, OverlapX=0, OverlapY=4.
- MSuper: Planar RGB support
- MFlowFPS: Planar RGB support: generate vectors in YUV, use RGB input and super clip
- MFlowFPS: less memory for 4:4:4 and greyscale
- MFlowFPS: a bit faster 4:4:4, much faster greyscale
- MFlowFPS: support different bit depth for clip and the vectors (use vectors from 8 bit analysis for a 16 bit clip)

2.7.34 (20181108)

- MFlowInter: Use less memory, eliminates ten full-frame internal buffers

2.7.33 (20181021)

- MFlowXX: Fix random access violation caused by enlarged vectors pointing on out-of-frame positions

2.7.32 (20181018)

- MAnalyze: Enhance mt mode report for Avisynth+: MT_SERIALIZED instead of MT_MULTI_INSTANCE when temporal=true or using output file.
- MAnalyze: fix a possible internal overflow on larger blocksizes and lambda combinations. e.g. truemotion=true with blksize=32

2.7.31 (20180409)

- Fix: MFlow: SC detection after having the mv clip. Fixed in 2.5.11.22 but was missed during 2.6.0.5 merge.
- Fix: MFlow: crash in 16bit 4:2:0, mode=1
- Fix: MDegrain, out16=true: Green bottom lines when overlap blocks are not covering the full vertical area

2.7.30 (20180405)

- Fix: crash in MFlowInter (and possibly other MFlow...) v2.7.29 revelead this additional bug (which was not even 100% reproducible), this fix is basically the 2nd part of the solution.

2.7.29 (20180403)

- Fix: MFlowInter (and possibly other MFlow...) crash with specific combination of analyze parameters (e.g. blkSize=16,overlapv=4,divide=1). Bug existed since at least 2.5.11.22

2.7.28 (20180323)

- Fix: in MDegrain1-6/N allow Y8 input for out16 parameter

2.7.27 (20180318)

- Fix: MDepan: use zerow parameter. The parameter had no effect probably since it was introduced
- MDepan: report MT mode for Avisynth+. MT_MULTI_INSTANCE, except for logfile writing output mode (MT_SERIALIZED)

2.7.26 (20180314)

- MDegrain1-6 and N: new parameter bool "out16" = false. If set, 8 bit input results in native 16bit output (like lsb=true hack but this is native). Faster than lsb=true by up to 12% (i7-7700)
- Faster: special 10 bit SAD functions instead of the generic 10-16bit one. Depending on the block size, 4-17% gain for a typical MDegrain1-6 session

2.7.25 (20180227)

- Fix: x64: not-cleared mmx state in MSuper assembly code would cause crash later, e.g. in x264 encoding, depending on following filters.
- Fix: MSCDetection SC value parameter name to Ysc from Yth (must be an ancient typo), docs are OK, but the fix is mentioned in docs
- MSuper: import 8 bit sse2 interpolators from mvtools-vs. Extend them for 10-16bits (faster super clip). Some filters are still todo.
- MSuper: support 32bit float clips, which can be used later by MDegrains (but not for MAnalyse)
- MDegrains: allow degraining clip with different bit depth from vectors. Clip and Super must be the same bit depth. Their subsampling must match that of motion vector base clips
- MDegrains: consistently use limit and limitC, 255 do nothing, otherwise scale 0-254 value to the current bit-depth range
- Overlaps: more correct internal rounding for 8 bits:
  old: pixel = Sum( (tmp + 256) >> 6) >> 5
  new: pixel = (Sum( (tmp + 32) >> 6) + 16) >> 5
  Overlaps: round for 16bits
  old: pixel = Sum(tmp) >> 11
  new: pixel = (Sum(tmp) + 1024) >> 11
- Overlaps: 32bit float (but still use the original 11 bit window constants)
- Project: change from yasm to nasm.

2.7.24 (20171205)

- Fix: MFlowBlur: possible access violation crash when nPel>1
- New: MScaleVect parameter 'bits'. e.g. Analyze 8 bit clips, use their vectors for 16 bits
- Move project to VS2017

2.7.23 (20171012)

- Fix: MScaleVect wrong rounding of scaled motion vectors with negative components. e.g. proper scaling (-1;-2) to (-2;-4) instead of (-1,-3).

2.7.22 (20170830)

- Misc: Stop using version suffix .22
- Fix: [DCT 8x8@8bit] garbage on x64: internal assembly code did not save xmm6/xmm7
- Fix: [DCT 8x8@8bit] safe multithreading for integer DCT (8x8 block size, 8 bit video): assembly had a single working buffer.
- Fix: [MDegrain] did not release input motion vector clips in destructor, possible hang at script closing. Bug since 2.7.1.22 (when introducing MDegrain4/5)
- Mod: fftw conversion constant of sqrt(2)/2 is more accurate (was:0.707), 16 bit formats may benefit (by feisty2)
- Fix: SSE4 assembly instructions in x64, broke on non-SSE4 processors

2.7.21.22 (20170629)

- Fix: [MDegrainN] fix chroma plane processing, regression since 2.7.1.22

2.7.20.22 (20170526)

- Fix: [MMask] greyscale input resulted in AV when filter exiting

2.7.19.22 (20170525)

- New: [MMask] Support any planar input video formats e.g. greyscale, Planar RGB.
  Input clip can even be of different bit depth or format from vector's original format
  For kind==5 where U and V is filled, the greyscale option is not allowed
- Mod: [MMask] Faster: request source frame only for kind=5.
- Fix: [MxxxxFPS,MMask]: MakeVectorOcclusionMaskTime garbage in bottom blocks (30 hrs of debugging)
- Fix: [MMask] bottom padding garbage for padded frame dimension
- Fix: [MMask] proper 10+ bits scene change values (for default: 1023, 4095, 16383, 65535. Was: 65535)
  Parameter is still in 8-bit range
- Fix: [MRecalculate] prevent overflow during thSAD scaling in 16 bits or large block sizes (32, 48...)
- Fix: [DepanEstimate] Sometimes giving wrong motion instead of scene change detection
- Fix: [MAnalyze] Possible overflow in MAnalyze 8 bit, block size 48x48 and above.
  Overflow-safe predictor recalc for big block sizes
- New: [General] Add block size 12x3 for SAD, allow 6x24
  List of available block sizes
  64x64, 64x48, 64x32, 64x16
  48x64, 48x48, 48x24, 48x12
  32x64, 32x32, 32x24, 32x16, 32x8
  24x48, 24x24, 24x32, 24x12, 24x6
  16x64, 16x32, 16x16, 16x12, 16x8, 16x4, 16x2
  12x48, 12x24, 12x16, 12x12, 12x6, 12x3
  8x32, 8x16, 8x8, 8x4, 8x2, 8x1
  6x24, 6x12, 6x6, 6x3
  4x8, 4x4, 4x2
  3x6, 3x3
  2x4, 2x2
- Mod: [Internal] Reorganized 10-16 bit SAD simd intrinsics, faster 8-12% for BlkSize 12-32

2.7.18.22 (20170512)

- Fix: 10-16 bit: DCT buffer possible overflow
- Fix: DCT is fast again for non 8x8 blocksizes. Regression since 2.7.5.22.
- New: Chroma SAD is now always half of luma SAD, regardless of video format.
  Without this: YV24's luma:chroma SAD ratio is 4:8 instead of 4:2 (of YV12)
- New: MAnalyze, MRecalculate new parameter: "scaleCSAD" integer, default 0. Fine tune chroma SAD weight relative to luma SAD.
  ScaleCSAD values for luma:chroma SAD ratio
  -2: 4:0.5
  -1: 4:1
  0: 4:2 (default, same as the native ratio for YV12)
  1: 4:4
  2: 4:8
- New: Block sizes 64, 48, 24, 12, 6
  MAnalyze/MRecalculate new block sizes (SATD support mod4 sizes)
  List of available block sizes
  64x64, 64x48, 64x32, 64x16
  48x64, 48x48, 48x24, 48x12
  32x64, 32x32, 32x24, 32x16, 32x8
  24x48, 24x24, 24x32, 24x12, 24x6
  16x64, 16x32, 16x16, 16x12, 16x8, 16x4, 16x2
  12x48, 12x24, 12x16, 12x12, 12x6
  8x32, 8x16, 8x8, 8x4, 8x2, 8x1
  6x24, 6x12, 6x6, 6x3
  4x8, 4x4, 4x2
  3x6, 3x3
  2x4, 2x2
  Note: some smaller block sizes can only be available in 4:4:4 formats, due to block size division (chroma subsampling)
- New: All block sizes are supported in MDegrain1-6, MDegrainN, and MScaleVect
- New: Changed to 2017 version of asm files for 8 bit SAD/SATD functions from x265 project.
  Added not implemented asm code for 12, 24, 48 sizes
  For some block sizes AVX2 and SSE4 is supported (AVX2 if reported under AviSynth+) e.g. BlkSize 32 is faster now.
- New: MMask SAD Mask to give identical weights for other-than-YV12 formats, e.g. for YV24

2.7.17.22 (20170426)

- Fix: Regression in 2.7.16.22: MDegrain right pixel artifacts on non-modulo 16 widths
- Misc: MMask, mode SADMask output is normalized further by video subsampling (YV16/YV24 has larger SAD value due to bigger chroma part that classic YV12)

2.7.16.22 (20170423)

- Fix: MMask 10-16 bits
- Fix: MRecalculate 14-16 bits passed nSCD1=999999 internally which caused overflow (scene change problems later) Fix is done by clamping SCD1 to 8*8*(255-0) (maximum value of sum of SADs on a 8x8 block)
- Misc: MDegrainX 8 bits: internal 16 bit buffer to 8 bits: SSE2

2.7.15.22 (20170316)

- Fix: 16 bit SAD for non-AVX code path
- Misc: MDegrain1-6: add error on lsb_flag=true for non-8 bit sources

2.7.14.22 (20170206)

- Fix: MAnalyze divide=2 showed "vector clip is too small (inherited from 2.6.0.5, sanity check was done but length was not filled for divideextra data)"
- Fix: MFlow access violation in internal mv resizer when resizing factor was big (MCaWarpSharp3 4x supersampling case) (bug introduced in upstream 2.5.11.22)

2.7.13.22 (20170201)

- Fix: MDegrain1-6,N 10-16 bit thSCD scaling
- Fix: MVShow: tolerance scaling for 10-16 bits

2.7.12.22 (20170120)

- New: Faster SATD (dct=5..10) 8 bit: updated x264 function selectors, SSE2/4/AVX/AVX2, +10% speed for a whole typical MDegrain3 process on i7-3770
- New: Much Faster SATD (dct=5..10) 10-16 bit: SSE2/SSE4 instead of C, +50% speed for a whole typical MDegrain3 process (which is approx half speed of 8 bit)

2.7.11.22 (20170116)

- New: MDegrain6
- Mod: MDegrain1-6 SSE4 for 10-16 bit (was: C. 3-5% gain, wasn't bottleneck)

2.7.10.22 (20161228)

- Fix: for YV12 the debug info text chroma part was positioned at wrong place

2.7.9.22 (20161220)

- Apply 2.5.11.9-svp analysis speedup, mainly when chroma is involved

2.7.8.22 (20161218)

- Fix: YUY2 input access violation (regression after 2.7.0.22d)
- Fix: MDegrain: free up YUY2 planes only if not planar input (bug inherited from 2.5.11.22 MDegrain3) resulting in freeze at script exit

2.7.7.22 (20161214) - optimizing a bit

- speed: change some 8 bit SAD functions for the better
- speed: separating bottleneck 8 bit/16 bit code paths in order not to use slower int64 calculations for 8 bit, where there are no integer overflow problems
- speed: more __forceinlines for helping the compiler
- info: general speed gain of 5-15% compared to 2.7.6.22, much reduced speed gap compared to the "classic" YV12 8 bit mvtools2 versions

2.7.6.22 (20161204) - fixes and speedup

- fix: sumLumaChange underflow (used for dct=2,6,9) (regression during 16 bit support)
- fix: MeanLumaChange scale for 10-16 bits (used for dct=2,6,9)
- fix: Mask fix: 8 bit mask resizer bug in SIMD intrinsics - Thx real.finder (regression on inline asm -> SIMD transition)
- Fix: dctmode=1,2: pixel distance was not corrected for 16 bit pixel sizes
- speed: Let's help VS2015 with some __forceinline directives to recognize the truth.
- speed: Misc optimizations throughout the code (bit shifts instead of div or mul)
- speed: FFTW DCT: C code replaced with SIMD SSE2/SSE4 (FloatToBytes, BytesToFloat)
- speed: 16 bit SAD: a few optimizations in SSE2, AVX-coded SSE2 and AVX2 codepath
- VS2015 compiler: /MT -> /MD (from static to dynamic dlls - now it reallys need VS2015 redistributables)

2.7.5.22 (20161119)

- Milestone release:
- General support of 10-16 bit formats with Avisynth Plus (r2294 or newer recommended) with new MDegrain4 and MDegrain5 filters.
- Fix for MSCDetection: scene change filler pixel default value was always 0 (2.7.1.22 regression)
- MCompensate: possible bugfix bottom padding UV
- Fix SAD for 10-16 bit depths for horizontal block sizes >= 16
- Fix nSCD2 (Scene change threshold block count %) (2.7.1.22 regression)
- MBlockFPS: overlap fixes (right columns and bottom lines)
- MBlockFPS: overlap fix: missing copy buffer to output, thanks StainlessS

2.7.1.22 (20161020)

- Some additional fixes for YV24
- New: MDegrain4, MDegrain5
- Experimental native 10-16 bit support (MSuper, MAnalyze, MDegrain1-5, MDegrainN) including 16 bit SATD (slow C) and SSE2 optimized regular SAD for 8+, for 10+ bits you need at least Avisynth+ r2290)
- Inline assembly rewritten to intrinsics -> 64 bit build is possible in VS2015. (External assembly untouched)

2.7.0.22d (2016.08.16 by pinterf)

- Some additional fixes for YV24
- Allow greyscale input (Y8)
- dct modes >= 5 now use SATD again (so far it was in dead code, contrary to 2.5.13.1 remarks)
- fftw 3.3.5 support (changed function names, 3.3.4 still OK), see http://www.fftw.org/download.html

2.7.0.22c (2016.08.04 by pinterf)

- Support for other planar YUV formats than YV12: YV16, YV24
- Some more SSE2 for blockX/Y combinations required by the new color spaces

2.7.0.22 (2016.04.29 by pinterf)

- Merge Fizick’s 2.5.11.22 modification and fixes, x64 port of new asm part
- Dropped time clip support (could not resolve 2.5.11.22 changes)

2.7.0.1 (2016.03.31 by pinterf)

- AVS 2.6 API
- Fixed internal criticalsection crash
- Fixed x64 asm code

2.6.0.5 (2012.07.17 by Firesledge)

- MCompensate, MDegrainN: fixed a bug causing occasionally horizontal magenta stripes in multithreading mode.

2.6.0.4 (2012.06.14 by Firesledge)

- MCompensate: fixed artifacts related to overlap with tr > 3 in multithreading mode.

2.6.0.3 (2012.05.13 by Firesledge)

- MDegrainN: fixed artifacts related to overlap with tr > 3 in multithreading mode.

2.6.0.2 (2012.05.01 by Firesledge)

- MAnalyse: fixed a threading issue when using FFTW.

2.6.0.1 (2012.03.12 by Firesledge)

- MAnalyse: fixed potential crash in multithreading mode.
- MDegrainN: fixed systematic crash in multithreading mode.
- All MDegrain functions: fixed potential crash when thSAD is set to 0.

2.6.0.0 (2012.03.11 by Firesledge)

- MDegrainN: internally uses MDegrain1/2/3 when tr ≤ 3, for optimal speed.
- MCompensate: added multi-compensation mode for easy use with temporal filters.
- MAnalyse, MSuper, MCompensate, MDegrainN: added multithreading (but partially, not for all code paths) using AVSTP.
- MAnalyse: fixed a corruption of the global motion vector.
- Improved page setting for this documentation.

2.5.14.2 (2012.01.10 by Firesledge)

- Fixed MScaleVect with multi-vector clips.

2.5.14.1 (2011.12.13 by Firesledge)

- Fixed crashes in the MDegrain functions when using both planar=true and lsb=true.

2.5.14.0 (2011.11.28 by Firesledge and Vit)

- Added MStoreVect, MRestoreVect and MScaleVect from the Vit's MVExtras plugin.

2.5.13.1 (2011.11.09 by Firesledge)

- MAnalyse, MRecalculate: added an SATD approximation for blksize > 16 and dct ≥ 5. Previously, the SATD calculation was silently bypassed and always returned a null SAD value.
- Functions now check that the pel setting is the same in the superclip and the motion vectors, instead of crashing if not.

2.5.13.0 beta (2011.09.11 by Firesledge)

- MRecalculate: Can now process multi-vector clips.
- All functions: Added the -Vit-'s fix that could improve the multithreading stability.

2.5.12.1 beta (2011.09.10 by Firesledge)

- MAnalyse: Fixed the ghosting bug introduced in the previous version.

2.5.12.0 beta (2011.09.10 by Firesledge)

- MDegrainN added.
- MAnalyse: Added the "multi" mode for MDegrainN.
- MAnalyse: Documented the negative delta values and fixed some functions accordingly.
- MFlowInter: Fixed the YUY2 planar mode.

2.5.11.2 beta mod16b (2011.05.11 by Firesledge)

- Fixed a regression in MDegrain1/2/3, related to the mod16 versions. thSADC is now taken into account correctly (instead of using thSAD).

2.5.11.2 beta mod16a (2011.04.10 by Firesledge)

- Merged 2.5.11.2 and 2.5.11 mod16a versions.

2.5.11.2 beta (2011.03.20 by Fizick)

- MCompensate: fixed crash with too small npad, vpad (thanks to '-Vit-').

2.5.11.1 beta (2010.12.22 by Fizick)

- MAnalyse, MRecalculate: fixed pure Horizontal and Vertical search types (fix by 'Firesledge').

2.5.11 beta mod16a (2010.12.18 by Firesledge)

- Merged 2.5.11 and 2.5.10.1 mod16b versions.
- Fixed the new horizontal and vertical search recalculations.

2.5.11 beta (2010.10.17 by Fizick)

- MAnalyse, MRecalculate: added pure Horizontal and Vertical search types (requested by 'Null Null').
- MRecalculate: Fixed Hexagon and UMH search types (was processed as Logarithmic).

2.5.10.1 beta mod16a (2010.06.27 by Firesledge)

- Merged 2.5.10.1 and 2.5.10 mod16b versions.

2.5.10.1 beta (2010.06.25 by Fizick)

- MFlowInter: Fixed incorrect transmission of last parameters (blend, etc). Thanks to Laurent de Soras 'Firesledge'. Other interesting updates from his MVTools v2.5.10 beta mod16b (http://ldesoras.free.fr/src/dither-avsi-1.2.zip) are under consideration.
- MDepan: Fixed bug : if range=1 in MDepan, the debug text (with info=true) was only displayed in the first frame when loading the script. Thanks Boulder for report.
- MRecalculate: Fixed bug if pel values are different. Thanks Boulder for report.

2.5.10 beta mod16b (2010.06.20 by Firesledge)

- MFlow, MFlowInter: Added the "tclip" parameter.
- MDegrain1: Added the "lsb" parameter.
- MFlowInter: Fixed incorrect transmission of the last parameters.

2.5.10 beta mod16a (2010.04.04 by Firesledge)

- MDegrain2,3: Added the "lsb" parameter.

2.5.10 beta (2009.11.08 by Fizick)

- MAnalyse: try many predictors
- MAnalyse: replace third right-top predictor by right-bottom
- MAnalyse: exhaustive search at all coarse levels (always), removed full parameter

2.5.9 (2009.11.04 by Fizick)

- MAnalyse: restored lambda for coarsest level)
- MAnalyse: fixed full=0 default according to doc

2.5.8.1 (2009.10.26 by Fizick)

- MDegrain2: fixed limitC (thanks Terranigma for bug report)

2.5.8 (2009.10.18 by Fizick)

- MAnalyse: fixed some wrong vectors (thanks to shon26 for bug report)

2.5.7 (2009.10.09 by Fizick)

- MAnalyse: fix bug (crash for some frame sizes) (thanks to Mark bug report)

2.5.6 (2009.10.08 by Fizick)

- MAnalyse: fix bug (crash for pad>0 and some frame sizes) with levels (thanks to Mark bug report)

2.5.5 (2009.09.28 by Fizick)

- MAnalyse: fix bug (crash for hpad=0) with levels (thanks to Boulder and LaTo for bug report)
- MSuper: corrected interpolation at planes borders
- MDegrain1,2,3: added limitC parameter

2.5.4 (2009.09.27 by Fizick)

- MAnalyse: set default temporal=false according to doc (some problem with SetMTMode(2) was reported by MAG79)

2.5.3 (2009.09.08 by Fizick)

- MAnalyse: added temporal predictor of motion vector
- MRecalculate: fixed broken v2.5.2

2.5.2 (2009.08.11 by Fizick)

- MSuper: separable width and height reducing with assembler iSSE optimization
- MAnalyse: limit levels value

2.5.1 (2009.08.07 by Fizick)

- MAnalyse: Added meander parameter for blocks scan in rows from left to right and from right to left
- Small optimization of YUY2 conversion

2.5.0 (2009.08.01 by Fizick)

- MSuper: More full size of sublevels
- MAnalyse: Increased number of sublevels (for more long vectors)
- MAnalyse: Replaced parameter name level by levels, changed meaning of its positive and negative values
- MAnalyse: Disabled lambda for most coarse level
- MAnalyse: Full search with large radius at smallest level

2.4.7 (2009.07.28 by Fizick)

- MBlockFPS: finally fixed bug for non-zero pad, non-integer number of blocks

2.4.6 (2009.07.26 by Fizick)

- MBlockFPS: fixed bug (at right and bottom, repored by Shon26) for non-zero pad, non-integer number of blocks
- Fixed possible bug with pixels interpolation at low hierarhical levels
- More correct size of sublevels (even luma for YV12)
- MShow: change draw vector style to gradient

2.4.5 (2009.07.11 by Fizick)

- Added block size 32x32
- Replaced avisynth.h with v2.5.8MT by SEt

2.4.4 (2009.07.08 by Fizick)

- Merged all code mods by SEt, but:
- Replaced avisynth.h v2.5.5 by v2.5.8

2.4.2_mod2 (2009.06.30 by Pavel Skakov aka SEt)

- Corrected threading problems, minor optimizations (avisynth.h from avisynth2.5.8MT beta, init vectors as 0)

2.4.2_mod (2009.06.22 by Pavel Skakov aka SEt)

Some source/project settings cleanup and optimized primary for MDegrain1/2/3 - depending on your settings you'll probably see 2-15% speedup, results are bit-identical to original 2.4.2:
- added Average2 iSSE version for pel=4,
- Degrain1/2/3 MMX and SSE2 versions,
- small optimization of copy8x8 mmx and Horizontal_Wiener SSE,
- fixed cpu detection

2.4.3 beta (2009.04.26 by Fizick)

- MDepan: added mask (requested by djonline) and planar parameters.

2.4.2 (2009.04.07 by Fizick)

- MAnalyze: Fixed valid vector range for case of padding lesser than block size, with program crash (thanks to FuPP for bug report).

2.4.1 beta (2009.01.24 by Fizick)

- MDegrain: Fixed weight for high threshold and big block size.

2.4.0 beta (2009.01.09 by Fizick)

- MDegrain: Changed degrain weight method to more strong, some internal rewriting.
- Fixed documentation.

2.3.1 (2008.12.14 by Fizick)

- MSuper: added more smoothing reducing filters rfilter=2,3,4, by default 2.
- MAnalyse: fixed bug with plevel parameter (version 2.3.0).

2.3.0 (2008.12.06 by Fizick)

- Renamed all functions from MVxxx to Mxxx (some renaming was requested by LaTo, Mystery Keeper, Sagekilla). Error messages is still not updated.
- MAnalyse: added pglobal parameter (with small changes), changed default level=1.

2.2.2 (2008.11.30 by Fizick)

- MVShow: changes SAD by reduced to block size 8x8, added quantity of bad blocks.
- MVCompensate: fixed bug at scene changes (thanks to AVIL for bug report about YUY2).
- MVAnalyse: fixed chroma=false (thanks to LaTo for bug report).
- Renamed to mvtools2.dll (requested by Naito).

2.2.1 (2008.11.27 by Fizick)

- MVAnalyse: fixed wrong scaling of LSAD to block size (thanks to Shon for bug report).
- MVCompensate: removed mode parameter, added recursion.

2.1.2 (2008.11.23 by Fizick)

- MVAnalyse: removed option mc. Reduced size of block data (increment version of vector stream).
- MVDegrain: fixed bug with block size 32x16

2.1.1 (2008.11.18 by Fizick)

- MVBlockFps: fixed left border bug

2.1.0 (2008.11.08 by Fizick)

- MVFlowFps, MVBlockFps, MVFlowInter: added blend parameter for ChangeFps-like mode at scene changes
- MVFlowFps, MVBlockFps: more safe for big nominator and denominator.

2.0.11.2 (2008.11.06 by Fizick)

- MVDegrain2,3: fixed crashes at scene changes for YUY2

2.0.11.1 (2008.11.05 by Fizick)

- MVAnalyse: added second wide search for bad blocks (badSAD, badrange parameters).
- MVAnalyse: added Hexagon and Uneven Multi Hexagon (UMH) search types. Changed (not intentionally :) the default method from Logarithmic to Hexagon.
- MVAnalyse: fixed exhaustive search to static center.
- MVAnalyse: lsad is now scaled to blksize 8.
- MVShow: use super clip, padded output, added number block option.

2.0.9.2 (2008.11.03 by Fizick)

- Some performance improving

2.0.9.1 (2008.10.20 by Fizick)

- More memory-optimal MVFlowXXX functions for pel=1
- Disabled plugin debug mode
- Added Russian documentation

2.0.9.0 alpha (2008.10.13 by Fizick)

- Implemented more functions without idx: MVSCDetection, MVDepan, MVFlowInter, MVBlockFps, MVFlowBlur, MVDegrain3, MVRecalculate
- Fixed crashes with MVSuper(chroma=false)
- Some small changes and fixes for v2.0 of course :)
- Documentation for v2.0

2.0.7.0 alpha (2008.10.02 by Fizick)

- Implemented functions without idx: MVSuper, MVAnalyse, MVFlowFps, MVFlow, MVCompensate, MVShow, MVMask, MVDegrain1, MVDegrain2
- All functions (besides MVAnalyse) got planar parameter for YUY2 planar input and output. Default = false (i.e. normal interleaved YUY2), slower.
- All (mandatory) clip parameters lost their names, and mvbw=vb is not correct syntax now. Use unnamed syntax instead.

2.0.0.3 alpha (2008.09.28 by Fizick)

- First 2.0 branch public alpha with MVSuper function to kill idx.
- MVAnalyse and MVDegrain1 are implemented only.

1.11.4.4 (2008.10.15 by Fizick)

- Restore old internal cache size growing as before v1.11.4.2 (some crashes reported).

1.11.4.3 (2008.10.08 by Fizick)

- MVDenoise: fixed error of v.1.11.4 with luma correction.
- MVCompensate: fix potential memory leakage (in constructor).

1.11.4.2 (2008.09.26 by Fizick)

- MVAnalyse: cut unused compensation memory space from vector clip (mc parameter).
- Decreased internal cache size growing.
- All MVFlow functions: fixed old bug with pixels for pel=4.
- MVAnalyse: added rfilter parameter (smooth method).
- MVBlockFps: added YUY2 and pelclip support.
- Tiny stability fixes for MT.

1.11.0.1 beta (2008.09.08 by Fizick)

- New MVBlockFps for simple fps change (almost realtime :-).
- MVAnalyse: more smooth method of frame hierarchical level reducing (like ReduceBy2) for smoothing at every level.
- MVAnalyse: Added pzero parameter of zero vector cost for more coherent motion vectors (now switched ON by default, set to 0 if you need in old algo).
- MVAnalyse: Decreased pelsearch internal clipping from pel to 1 (asked by somebody for speed).
- MVFlowFps,MVFlowFps2, MVFlowInter: removed thSAD parameter.
- All functions: Removed mmx parameter.

1.10.2.1 (2008.08.28 by Fizick)

- MVDegrain1-3: fixed old rounding error resulted in some chroma tint (some thanks to Didee for bugreport, but it could be more persevering in official MVTools forum thread :)
- Made doc about pelclip more accurate (hopely).

1.10.2.0 beta (2008.08.27 by Fizick)

- Debugged and renamed MVRefine back to new MVRecalculate :).
- MVAnalyse: changed LSAD threshold from hard by soft for a little more coherent motion at bad areas.
- MVAnalyse: fixed old bug for (rarely used) different horizontal and vertical overlap sizes.

1.10.1.0 not public (2008.08.22 by Fizick)

- Change MVRecalculate by more general function (MVRefine) which can re-estimate vectors.

1.10.0.0 not public (2008.08.18 by Fizick)

- Added MVRecalculate function to update SAD (as requested by Didee).
- Fixed possible memory leaks (thanks to josey_wells for note)
- Other changes of v1.9.6-1.9.7 branch by josey_wells are still not merged - too many work to analyse new code and numerous cosmetic rewriting, so based on v1.9.5.7

1.9.6.x-1.9.7.x series branch (2008.08.01-2008.08.26 by josey_wells)

- Added MVAnalyseMulti, MVDegrain, MVMultiExtract functions with internal multitheading (that does not require any special AviSynth, SetMTMode or MT)
- Some bug fixes (memory leaks), code consolidation (rewriting) for stability and performance improvements. Also there is a multitude of changes due to the addition of threading class, semaphore class, critical section class, thread files for MVDegrain, MVAnalyseMulti as well as factoring out common code for MVDegrain into a single base class moving out common code etc. There are no changes of algorithms. See messages at forum since August 2008 for download, syntax and discussion.

1.9.5.7 public beta (2008.07.03 by Fizick)

- Fixed Overlap_2xY_mmx
- Added (incomplete?) list of used projects to doc.

1.9.5.6 (2008.07.02 by TSchniede)

- Improved my, added Overlap_2xY_mmx, optimized CheckMV2 and LumaSAD.

1.9.5.5 (2008.06.28 by TSchniede)

- Improved default 2xY SAD and added new faster 2xY SAD.

1.9.5.4 (2008.06.27 by TSchniede)

- Ported CPU detection from x264.
- Now using x264 SAD autoddetect is default
- Merge with 1.9.5.1, re-enabled 32x16 mode (only default functions)

1.9.5.3 (2008.06.26 by TSchniede)

- Imported SSD and SATD functions.
- access using sadx264 > 7 or dct > 4.

1.9.5.2 (2008.06.24 by TSchniede)

- Buffered source block in aligned area before calculating SAD.
- This fixes crashes if source block was unaligned due to overlaped blocks.
- Worst case was < 1% slower, most of the time it further increases performance.

1.9.5.1 public beta (2008.06.21 by Fizick)

- Merge v.1.9.5 changes by TSchniede.

1.9.5 (2008.06.21 by TSchniede), based on v.1.9.3

- MVAnalyse: added sadx264 option.
- Internal modifications - aligned memory of luma&chroma planes and modified MVTools to the interface of the SAD functions used in x264.
- minor bugfix (deactivate DebugPrint possible)

1.9.4.1 beta (2008.06.12 by Fizick, released 21.06.2008)

- Fixed bug for pel=4 with sharp=2 (thanks to Pustovetov for report and fix).
- MVCompensate: added block size 16x2 (bug reported by AVIL).

1.9.4 not public beta (2008.06.08 by Fizick)

- MVAnalyse and other: added block size 32x16 (requested by MAG79).

1.9.3.1 (2008.06.05 by Fizick)

- MVIncrease: was broken (as noted by MAG79).

1.9.3 (2008.04.20 by Fizick)

- MVAnalyse: fixed bug for pelclip (broken since v1.8.5).
- MVDegrain: added thSADC as chroma threshold (request by Terranigma).

1.9.2 (2008.01.29, all bugs were found by josey_wells)

- MVDegrain3: fixed bug in code for 16x8 block; fix typo (MVDegrain2 instead of MVDegrain3).
- MVAnalyse: fixed old bug in NStepSearch.

1.9.1 beta (2007.12.15 by Fizick)

- MVAnalyse: Increased speed (by 20%) of global motion estimation (other algo).
- MVAnalyse: Added assembler optimization for small blocksizes SAD (speed by 50%).
- MVMask: Added kind=5 motion colormap as x,y components of motion vector shown in U, V color planes.

1.9.0 (2007.12.04 by Fizick)

- Added MVDegrain3.

1.8.6 (2007.12.02 by Fizick)

- Added components x,y motion vector mask kind=3,4 to MVMask (requested by Terka).

1.8.5.1 (2007.11.12 by we:)

- Merge v1.8.4.3 and v1.8.5 changes, added MT example.

1.8.4.3 (2007.10.05 by Tsp)

- Implemented internal cache buffer miss detection with buffer growing (as suggested by IanB).

1.8.5 (2007.11.05 by Fizick)

- Added pelsearch parameter as search parameter (radius) at finest level (request by Terranigma).
- Decreased internal buffer to decrease memory usage, with some changes in critical sections.
- Added block size 16x2 (requested by ab_99).

1.8.4.2 (2007.10.25 by Tsp)

- Added critical section in frame refining to fix rare bug in multi-threaded processing.

1.8.4.1 (2007.10.23 by Tsp)

- Implemented thread-safe internal buffer access for correct multithreaded processing with SetMTmode(2) in Avisynth MT version (for multi CPU).

1.8.4 (2007.08.22 by Fizick)

- "divide" now works with "overlap".

1.8.3 (2007.08.17-20 by Fizick)

- MVFlowFps: renamed "mode" parameter to "mask".
- MVFlowFps2: added "mask" parameter.
- MVFlowFPS, MVFlowFPS2: Restored default values num=25, den=1 (as was in version 1.7 and early)
- MVDegrain1, MVGegrain2 - added "limit" parameter.

1.8.2 beta (2007.07.30 by Fizick)

- MVAnalyse: corrected (increased) search radius at finest level for pel>1.
- Added pel=4 option for quarter pixel precision.
- Renamed clip2x parameter to pelclip.

1.8.1 beta (2007.06.28 by Fizick)

- MVAnalyse: added postrocessing motion vectores by dividing blocks into subblocks to decrease zone of motion vectors interpolation.
- MVFlowFps: added "mode" parameter to select processing method at occlusion areas (and speed).
- Some internal changes (padding in MVAnalysisData, header to vector stream frames, etc).

1.8.0 beta (2007.06.22 by Fizick)

- MVFlowInter, MVFlowFPS, MVFlowFPS2, MVMask: improved occlusion mask by extent
- MVFlowInter, MVFlowFPS: decreased objects halo at occlusion areas by using motion vectors of adjacent frames
- MVFlowInter, MVFlowFPS: disabled SAD mask and thSAD parameter
- MVShow: fixed drawn positon of vectors
- MVFlowFPS, MVFlowFPS2: Changed default output fps to double of input (default num, den = 0)
- Added error messages on missed vector clips

1.7.0 beta (2007.06.05 by Fizick)

- MVAnalyse: added blksizeV and overlapV parameters for non-square blocks 8x4 and 16x8.

1.6.4 (2007.05.30 by Fizick)

- MVAnalyse: modified vectors order for Enhausted search (expanding squares).
- MVAnalyse: fixed bug with dct=3.
- MVFlowFps, MVFlowFPS2, MVFlowInter: now blend frames with bad motion estimaton (at scenechanges, flashes).
- MVFlowFps, MVFlowFPS2: fixed bug with thSAD parameter (and correspondent mask).

1.6.3 (2007.05.06 by Fizick)

- MVDepan: more compatible with DepanEstimate (range parameter, etc).

1.6.2 (2006.11.11 by Fizick)

- MVAnalyse: changed DCT=2 mode to global luma dependent.

1.6.1 beta (2006.10.25 by Fizick)

- MVAnalyse: added experimental DCT mode to improve motion estimation at luma flicker and fades (fast for blksize=8 only).

1.5.8 beta (2006.10.14 by Fizick)

- Many functions: added clip2x parameter to use 2X upsampled clip instead of internal subpixel interpolation for pel=2
- MVFlowFps, MVFlowFps2: added thSAD parameter; use local blending of neighbour frames pixels in regions with bad motion vectors
- MVFlowFps, MVFlowFps2: may use motion vectors for any frames delta
- MVFlowFps, MVFlowFps2: fixed a bug for video with big nominators and denominators (thanks to Trixter for report)
- MVCompensate: added experimental fields parameter to compensate fields shift of fieldbased video for pel=2
- MVAnalyse: changed pnew parameter to relative of SAD

1.5.3 beta (2006.10.01 by Fizick)

- MVAnalyse: improved zero motion estimation for fieldbased video for pel=2
- Merged v1.4.12-1.4.13 changes
- Temporary restored MVIncrease, MVChangeCompensation, MVDenoise (with compensation stored in vector clip)

1.5.1 beta (2006.09.05 by Fizick)

- Merged v1.4.11 changes

1.5.0 beta (2006.08.23 by Fizick)

- Corrected vector predictors interpolation (from coarse to fine scale) for overlap>0.
- MVFlowInter: added thSAD parameter.
- MVFlowInter: local blending of neighbour frames pixels in regions with bad motion vectors.
- Removed compensation storage in vector clip
- Removed functions MVIncrease, MVChangeCompensation, MVDenoise (it used compensation in vector clip, and did not support overlapping).
- Removed mode=2 loop option of MVCompensation, mode=0 is processed as mode=1 now.
- Added thSAD parameter to MVCompensation for safe (dummy) compensation as requested by Didee

1.4.13 (2006.09.28 by Fizick)

- Fixed bug with possible wrong frames pointers in core (MVClip.Update), hided by caching (thanks to IanB for advice)

1.4.12 (2006.09.25 by Fizick)

- Seems fixed bug with frames caching in MVDenoise (and possible in MVDegrain) (thanks to il9ad for report)

1.4.11 (2006.09.06 by Fizick)

- Corrected vector predictors interpolation (from coarse to fine scale) for overlap>0.
- Fixed bug with pitch for overlap=0, YV12 in MVDegrain1 (thanks to Boulder for report)

1.4.10 (2006.08.18 by Fizick)

- Corrected right and bottom borders processing in MVCompensate for arbitrary frame sizes.
- Changed defaults in MVAnalyse: pel=2, truemotion=true, sharp=2.

1.4.9 (2006.08.14 by Fizick)

- Fixes a bug in MMX optimization of overlap mode in MVDeGrain, MVCompensate for YUY2 with blksize=8 (thanks to TSchniede for report).

1.4.8 (2006.07.31 by Fizick)

- Added some MMX optimization of overlap mode in MVDeGrain, MVCompensate.
- Fixed a bug with last (not processed) rows in MVDeGrain.

1.4.7 (2006.07.25 by Fizick)

- Decreased overlap gridness in MVDeGrain1, MVDeGrain2, MVCompensate.
- Added example with MVDeGrain1 for interlaced.

1.4.6 (2006.07.24 by Fizick)

- Decreased denoising in MVDeGrain1, MVDeGrain2.
- Plane parameter in MVDeGrain1, MVDeGrain2 now works :)

1.4.5 (2006.07.22 by Fizick)

- Added plane parameter to MVDeGrain1, MVDeGrain2.

1.4.4 (2006.07.19 by Fizick)

- Corrected default thSAD=400 in MVDeGrain1, MVDeGrain2.
- Fixed a bug with V color plane in MVChangeCompensate.

1.4.3 (2006.07.17 by Fizick)

- Decrease overlap gridness in MVDeGrain1, MVDeGrain2.

1.4.2 (2006.07.16 by Fizick)

- Fixed a memory access bug in MVDeGrain1, MVDeGrain2. Thanks to krieger2005 for report.

1.4.1 (2006.06.23 by Fizick)

- Changed MVDeGrain1, MVDeGrain2 mode to SAD weigthing.
- Chanded thSCD1 default from 300 to 400.

1.4.0 (2006.06.19 by Fizick)

- Added MVDeGrain1, MVDeGrain2 limited averaging denoisers.
- Corrected thSAD scale in MVDenoise.
- Corrected documentation about SAD.

1.3.1 (2006.06.11 by Fizick)

- Added bicubic subpixel interpolation method for pel=2 (with iSSE optinization for sharp=1,2).
- Assembler iSSE speed optimization for overlapped block compensation.

1.3.0 (2006.06.05 by Fizick)

- Implemented overlapped block motion compensation to MVCompensation(mode=1).
- Changed default to mode=1 in MVCompensation as the most universal.
- Added sharp subpixel interpolation method for pel=2.
- Fixed bug for blksize=16 with YUY2.
- (To-do list: assembler SSE speed optimization for new compensation and interpolation methods.)

1.2.6 beta (2006.05.21 by Fizick)

- Added option to write motion vectors data to log file as requested by Endre.

1.2.5 (2006.05.08 by Fizick)

- Decreased zero vector weight, iteration accuracy in MVDepan

1.2.4 (2006.04.07 by Fizick)

- Fixed bug v.1.2.3 with info mode in MVDepan

1.2.3 (2006.03.31 by Fizick)

- Implemented MVDepan for interlaced source separated by fields;
- added optional MVDepan log file.

1.2.2 beta (2006.03.01 by Fizick)

- Fixed frame shift bug of v1.2.1 with mmx YUY2 conversion (thanks to WorBry for bug report)

1.2.1 beta (2006.02.20 by Fizick)

- Fixed bug of v1.2,
- Speed restored,
- mmx YUY2 conversion (from avisynth 2.6 function by sh0dan)
- But it seems, overlap mode still does not work properly

1.2 beta (2006.02.17 by Fizick)

- YUY2 format support (besides MVIncrease), no optimization

1.1.1 (2006.02.16 by Fizick)

- Removed DeBlock and Corrector filters (will be separate plugins)
- Documented old MVSCDetection function.
- Cleaned project from unused source files.

1.1 (non-public build 2006.01.09 by Fizick)

- Quite large revision (beta). New option for overlapped block motion estimation in MVAnalyse for usage in MVFlow, MVFlowInter, MVFlowFps for improved motion compensation.
- Lookup tables for motion interpolation.
- Small correction of displacement value in MVFlowFps2.

1.0.3 (Released 2005.12.30 by Fizick)

- Fixed bug with displacement in MVFlowInter, MVFlowFps (introduced in v1.0.2).

1.0.2 (Released 2005.12.28 by Fizick)

- Corrected value of displacement in MVFlow (a little).

1.0.1 (Released 2005.12.24 by Fizick)

- Fixed memory leakage bug in MVAnalyse with global motion (thanks to AI for report).
- Removed penalty for zero vector predictor in MVAnalyse (was introduced in v1.0).
- Changed chroma=true as default in MVAnalyse.

1.0 (Released 2005.11.29 by Fizick)

- I'm tired of long version numbers :). But the plugin is stil experimental :(.
- Restored zero vector predictor in MVAnalyse.
- Changed blur time scale in MVFlowBlur (100 is fully open shutter now) as Mug Funky requested.

0.9.13.3 (Released 2005.11.27 by Fizick)

- Added global motion (simple method) vector predictor to MVAnalyse.
- Vector search is skipped (for speed) if good predictor was found (with SAD < pnew).
- Parameter scale in MVShow works properly now.
- Disabled some debug and profiling info output (for speed increasing).
- Changed default prec=1 (was 2) in MVFlowBlur.

0.9.13.2 (Released 2005.11.22 by Fizick)

- Fixed bug in MVFlowFps, MVFlowFps2 for non-integer fps.

0.9.13.1 (Released 2005.11.21 by Fizick)

- Fixed bug in MVFlowFps, MVFlowFps2, MVFlowInter, MVFlowBlur (introduced in v0.9.13).
- Removed plen parameter from MVAnalyse as not useful.

0.9.13 (Released 2005.11.20 by Fizick)

- Added truemotion preset to MVAnalyse.
- Added experimental MVFlowFps2.
- Change interpolated vector rounding method in all MVFLow... functions.
- Edited documentation a little.

0.9.12.4 (Released 2005.11.15 by Fizick)

- Changed type of ml parameter in MVMask, MVFlowInter, MVFlowFps from int to float.
- Added bound check of ml, time, blur parameters.
- Small possible bug fixed (emms).
- Partially updated documentation. But I am not sure that sh0dan requested exactly such updating :). It is still not user guide but functions reference.

0.9.12.3 (Released 2005.11.14 by Fizick)

- Fixed bug for chroma for width not divisible by 16 in MVMask (introduced in v0.9.11).
- Some speed optimizing of MVFlowFps.
- Reset size of internal frames buffer to original value 10. Try various versions.

0.9.12.2 (Released 2005.11.13 by Fizick)

- Added experimental precise but slow MVFlowBlur function as scharfis_brain requested.
- Temporary changed size of internal frames buffer to 5.

0.9.12.1 (Released 2005.11.12 by Fizick)

- Added experimental MVFlowFps function.
- Disabled MVInter function.
- Temporary changed size of internal frames buffer from 10 to 3 for memory usage decreasing. Speed must be tested for complex scripts.

0.9.12 (Released 2005.11.09 by Fizick)

- Added MVFlowInter function. MVInter function will be removed in next release (it is worse).
- Changed scale of ml parameter for kind=2 of MVMask to more optimal default.
- Fixed small bug in Bilinear.asm (strange pixels near right border for pel=2).

0.9.11.1 (Released 2005.11.06 by Fizick)

- Added half-pel support to MVFlow.
- Increased max quant from 51 to 60 in DeBlock for very strong deblocking .
- Corrected documentation.

0.9.11 (Released 2005.11.04 by Fizick)

- Improved MVMask: Replaced boolean showsad parameter to integer kind, added occlusion mask option. Changed bilinear resize code to more correct and fast SimpleResize.

0.9.10.1 (Released 2005.11.01 by Fizick)

- Fixed bug with chroma and luma small changes in MVInter (rounding error).
- Vector interpolation in MVFlow and mask in MVInter are correct now (due to fixing bug in SimpleResize).

0.9.10 (Released 2005.10.31 by Fizick)

- Added some true motion (smoothed) estimation options to MVAnalyse
- Added function MVFlow for per-pixel motion compensation
- Added function MVInter for motion interpolation (very experimental)

0.9.9.1 (Released 2005.01.20 by Manao)

- No need anymore of stlport_vcxxxx.dll

0.9.9

- Filter added : Corrector
- Filter added : MVIncrease
- New available blocksize : 16
- New parameter in MVAnalyse : chroma
- Changes in the core

0.9.8.5

- `MVCompensate` changed : a new parameter, idx, which works as idx in `MVAnalyse`, and which allows speed up when compensating the same frames several times.

0.9.8.4

- ME takes into account the chroma now, as requested by tsp.

0.9.8.3

- Added `Corrector` function, as requested by scharfi.

0.9.8.2

- New function `MVDepan` (added by Fizick) for Depan plugin.

0.9.8.1

- Several bugfixes

0.9.8

- Yet another little changes in the filters' syntax. The core changed a lot, in order to gain speed were it was possible. However, by default, the speed gain won't be visible, you'll need to configure correctly the analysis filter through its "idx" parameter in order to gain speed ( in the mode "pel" = 2 ).
- Bugfixes in MVDenoise, and chroma denoising in MVDenoise.
- Now, the filters down the filter's chain tell to the analysis filter if they need the compensation, so you don't have to worry about that at the analysis stage.

0.9.7

- Yet again, a lot of rewriting. Interpolating filters are disabled ( for the moment ), all the other filters work and should be considered as stable. Syntax has changed a lot, and will change again before reaching 1.0 ( if it's reached one day ). Changes mainly affect `MVAnalyse`. New filter : `MVChangeCompensate`.

0.9.6.2

- Fixed bug in `MVMask` parameters.

0.9.6.1

- Lot of bugfixes for the existing filters. MVMask, MVShow, MVCompensate, MVDenoise and MVSCDetection, and MVAnalyse should work . Other may crash unexpectedly.
- Now, for the three new filters. Two have nothing to do with motion compensation, but I didn't want to put them in separate binaries, since they'll mainly be used with filters from this package. The third one uses vectors, and integrates somehow the two others.
- QDeQuant(clip c, int quant, int level) : takes a clip and quantizes it, using an approximation of the H264 DCT. It filters the three planes ( 4x4 blocks for each of them, so the chroma isn't processed as in H264 ). It's not exactly the H264 DCT because at q1, it's lossless, and a q51 it's not that bad, but you can raise quant over 51. Level is the reference level of the picture. By default it's zero, but it can be set, for example, to 128. The picture is then treates as if pixels were ranging from -128 to 127, hence avoiding errors around 128.
- Deblock(clip c, int quant, int aOffset, int bOffset ) : takes a clip, and deblock it using H264 deblocking, as if the picture was made only of inter blocks. This time, quant ranges from 0 to 51 as in H264, and has the same impact. aOffset and bOffset allow to raise / lower the quant when deciding for some internal thresholds. They are set by default to 0. Be warned that the filter should do nothing at quant lesser 16, if aOffset and bOffset are both zero. It's a wanted behavior ( thus it respect the partially the norm ).
- EncDenoise(clip c, clip vectors, bool scbehavior, int quant, int aOffset, int bOffset, int thSCD1, int thSCD2) : it merges Deblock, QDeQuant and MVCompensate, taking from them the name and behavior of their parameters. It basically does a h264 encode as if all blocks were 8x8 inter blocks. Reference frame is the previous frame output by the filter ( if it is the correct one, else it's the previous frame of the source ), mvs are those given by mvanalyse on the source. The reference frame is compensated by the vectors, then the residual difference is quantized / dequantized and added to the result of the motion compensation. Finally, the frame is deblocked, and serves as reference for the next one.

0.9.5.3

- Mainly a bugfixe ( several filters were affected by a silly bug , and MVCompensate now do padded motion compensation, and compensate also the chroma ( though it rounds the vector to odd coordinates to do so )
- A new feature, as asked by Fizick, for mvcompensate : "scbehavior", a boolean set to true by default, will allow you to keep the previous frame over a scenechange if you set it to false.

0.9.5.2

- MVMask has two new parameters : showsad (bool) which allows to build the mask of the SAD values instead of the mask of the vectors' length. Ysc allows you to set the value taken by the mask on scene changes
- MVCompensate : behavior modification on scene changes. Now, the current frame is left untouched if a scene change was detected.
- New filter : MVSCDetection, with one parameter, Ysc, which works as previouslymscdetection.
- MVInterpolate, MVConvertFPS and MVBlur are enabled, but may be buggy ( though I wasn't able to make MVConvertFPS crash )

0.9.5

- Huge rewritting of the core engine. Vectors are now searched with a precision up to the pixel ( because no other filters can use yet more precise vectors, except MVShow ). The search engine is now fast ( which doesn't mean necessarily that the filters which use it are fast )
- A new parameter for MVAnalyse : lambda. See the documentation of the filter to see how it works
- MVDenoise works better.

0.9.4

- Vectors can be saved to a file. In order to do so, add the parameter filename="C:\foo.bar" to the filter MVAnalyse. If the file doesn't exist, vectors will be saved into it. If it exists, vectors will be read from it. But, be warned :
  - The file for a whole movie will be around 500 MB
  - Saving / reading from a file need for the moment a linear access to the frames, so it has to be used only when encoding the movie, not when doing random access in it.
  - The speed gain is not as great as one may hope, because SADs can't be saved ( it would take too much space ) and so have to be recomputed.
- The filter MVDenoise now works on 5 frames, and its parameters are now "thT" and "sadT" ( have a look in the documentation to see how they work ). It works nice ( very good for heavy denoising )
- The scene change detection thresholds have slightly changed. Now, a block has changed if its SAD it over thSCD1. The default for thSCD1 is 300, and for thSCD2 it is 130. It orks well ( better than the previous SCD engine ).

0.9.3

- Last cleanings in the search of the motion vectors. It should be slightly faster
- More search parameters can be set by the user, especially the search algorithm. See the documentation
- Server / client implemented. You now first have to use MVAnalyse, and then the filter you want. Look at the documentation and at the examples I'll give alter.
- MVCompensate is separated from MVShow ( it's more logic that way ). For the moment, it doesn't move the chroma ( same behavior as MVShow in the latest releases )
- Some cleaning in MVBlur / MVInterpolate / MVConvertFPS, but still some work to do. Now, MVBlur blurs around the frame, not between the frame and the previous one.
- Half of the work is done for writing vectors to a file. But the resulting file will be large ( around 500 MB - 1 GB I guess ).
- MVDenoise is slightly faster ( at least it should )
- Copies are optimized inside the filter, thanks to avisynth's copy functions.
- MVShow can display the mean SAD of the compensation ( using showsad = true )

0.9.2.1

- MVInterpolate makes its come back.
- MVConvertFPS should work on the last few frames of the clip

0.9.2

- MVInterpolate doesn't exist anymore.
- MVBlur and MVConvertFPS have been improved. They also have got new parameters, have a look at the documentation.
- MVShow gets back its compensate mode ( MVShow(cm = true) )

0.9.1 - 2004.05.12

- First version renamed to MVTools.

0.1-0.6 Released 2004.01.24 - 2004.04.01 by Manao

- First public versions MotionVectors (Motion.dll).

## VII) Download

This MVTools2 branch is available from https://github.com/pinterf/mvtools/tree/mvtools-pfmod

The base MVTools2 branch can be found in the Dither package: http://ldesoras.free.fr/prod.html

with x64 version at http://avisynth.nl/index.php/External_filters#64-bit_filters

Original MVTools2 branch can be downloaded at http://avisynth.org.ru/

Older version 1.X documentation and download link are at http://avisynth.org.ru/mvtools/mvtools.html

Older MVTools v.0.9.9.1 can be downloaded from Manao's site