Bugfix: calculate proper size for memset()

The proper idiom is:

  memset(ptr, val, sizeof(*ptr));

These files were using:

  memset(ptr, val, sizeof(ptr));
bugfix: motion.c: calculate proper allocation size

The proper idiom for calculating the size for memory allocation is:

  ptr = malloc(sizeof(*ptr));

The sizeof() dereferences the pointer's type, and allocates enough
memory to store an instance of that type. motion.c was using this idiom:

  ptr = malloc(sizeof(ptr));

This is incorrect, but thankfully fairly harmless in practice since the
pointer type is usually quite large. Change this to the proper idiom.
Merge pull request #41 from aklomp/mrdave-sizeof

Fix incorrect sizeof() calculations in malloc and memset
alg_noise_tune: split off into separate file to enable testing
alg_noise_tune: add test pattern framework
alg_noise_tune: change ints to unsigned for 10% speed improvement
alg_noise_tune: add optimized SSE2 routine
alg_update_reference_frame: factor out existing function
alg_update_reference_frame: add test harness
alg_update_reference_frame: factor test masks out of branch condition

Taking the tests out of the branch condition results in a 50% speedup
with GCC when compiled with -O3.
alg_update_reference_frame: add SSE2 algorithm demo/test

This file implements the masking algorithm we will use in the SSE2 code.
It demonstrates identical output when compared to the plain function.
It's a lot slower than the regular routine when used on individual
pixels, but is speedier when vectorized.

Instead of branching, we use masks to composite the output values. The
masks were found by breaking down the branch conditions into boolean
operations, and repeatedly applying De Morgan's laws to simplify them.
Since SSE has the 'andnot' operator, optimize for that form.
cnt->imgs.ref_dyn: specify type as uint16_t, not generic int

To convert the algorithms to SSE2, we need to know exactly which width
and type of int we're dealing with. Make this an uint16_t; the type
looks large enough for a counter that updates every frame. At 10 hz, it
will take almost 2 hours for the counter to saturate; enough time to
finally accept a static object.
alg_update_reference_frame: add optimized SSE2 routine
alg_update_reference_frame: test harness: directly compare functions

Directly run two functions on the same input and check whether they give
the same output; don't just rely on printing a few numbers to the screen
and eyeballing the results.