trying to sanitize values read from file

CID:27946
brute-force assertion that leaf_count > 0

CID:27860
make sure that (ushort)*(ushort) is written into (ulong)

by using an intermediate ushort variable, and type-casting the operands

CID:53709,27875
CID:53710,53711
manual type promotion to prevent integer overflow

again trying to fix CID:27876
fixing another potential integer overflow

CID:53711
using size_t rather than int32 for lengths
removed trailing spaces
in YUV-space we deal with U16 rather than U32

so we cannot calculate both Y0 & Y1.

CID:27796,27808
make sure that dot_(h)size is at least 1

fixes crashes with small dot-sizes (resulting in devision-by-zero)
using standard RGB2GREY conversion factors

they tend to saturate less...