https://github.com/AviSynth/AviSynth...nvert.cpp#L742
I wouldn't like these conversions
on 8bit to 16bit
dstp0[x] = srcp0[x] << 8;
on 16bit to 8bit
dstp[x] = min((srcp0[x] >> 8) + ((srcp0[x] & 0x00FF) >> 7), 255);
on float to integer
dstp0[x] = static_cast<pixel_t>(srcp0[x] * factor + 0.5f);
I think these are general way.
- on high precision to low precision, rounding is better than truncation because less error.
- bit shift and saturate is easier to optimize than multiplication and division.