martin-marek / hdr-plus-swift

📸Night mode on any camera. Based on HDR+.
https://burst.photo
GNU General Public License v3.0
210 stars 11 forks source link

FIX: White level would become invalid when using 16-bit output option. #57

Closed Alex-Vasile closed 3 months ago

Alex-Vasile commented 3 months ago

The current code did not check that the white level resulting from factor_16bit*white_level[ref_idx] would be in the range of [0, 2^16 -1]. On the Canon R5 MkII this calculation resulted in a white level of 65,536 (i.e. 2^16) which is too big to fit inside a uint16. The actual scaling code inside convert_float_to_uint16 properly clamps to uin16 range, but the values sent to texture_to_dng did not, resulting in a produced DNG being written which cannot be opened, not even by the dng convertor since it fails validation.