Thread: Avisynth+
View Single Post
Old 6th July 2016, 22:54   #2026  |  Link
Chikuzen
typo lover
 
Chikuzen's Avatar
 
Join Date: May 2009
Posts: 595
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.
__________________
my repositories

Last edited by Chikuzen; 7th July 2016 at 02:28.
Chikuzen is offline