pylorak/avisynth — pull request #14 by innocenat (2013-11-18 12:45:42+00:00)
Title: x64 support in core filters, part 2

This is the second part of x64 support in core filters

### Important changes

Overlay functions are now SSE2-optimized, along with new SSE2/MMX routines for some modes that only have C routine. Note this is still not completed, and a lot of Overlay modes are still C only like in original Avisynth.

Vertical resizers are bit-perfect with original code, but horizontal resizer introduced some rouding differences. This is because horizontal resizer now call vertical resizer on tranposed frame instead of having separated routines.

Due to SSSE3/SSE4.1 optimizations, minimal required version of Visual Studio is 2008.

### Notes on performance

Overlay performance is better on tested machine (Nehalem).

Resizers performance varies between CPU due the original Softwire codes use loop unrolling to exact filter size, which is not feasable to do without some kind of dynamic compilation. So performance of the new resizers code depends a lot on CPU and its branch prediction performance.

On two machines tested, the desktop Nehalem CPU outperforms original code in almost every cases except for 8-tap downsizing (spline64 and lanczos4), but the mobile Sandy Bridge is slower than original code for every filter large than 2-tap (larger than Bilinear). During the test on the Sandy Bridge, upon (hacked) unrolling for filter size, the performace is little better than original code.

Horizontal resizers may perform worse on pre-SSE2 CPU, as right now transpose code has only SSE2 optimization. But otherwised tested on Sandy Bridge it performs better in every case.

### To do

* Slight refactoring when we accept some kind of a coding guidelines. Right now the codebase is not consistent at all.
* Perhaps optimizing the true horizontal more to see if it can be faster (i.e. with SSE4.1 horizontal add)
* MMX/SSE2 optimization for the rest of Overlay mode.