Made constant expressions float so calculations are clearer.
Extract some more things into constants.
Fixed using stride instead of width for yplane.