SSIM: handle negative ranges properly
Originally uncovered and fixed as a problem at all in
04661f4bcdf84195a75e4e91a542b9e6e8bd8e37 (via !11367), this commit "solved" the
issue by clamping the SSIM values to be in `[0,1]` instead of `[-1,1]`. This
fixed the `hist` out-of-bounds accesses for negative values, but skews the
results in an unknown way. Instead, if the values have a negative range, shift
the values up and rescale to fit into the histogram range. This has an unknown
effect on what is actually being computed, but without comments guiding the
rationale of the original code, it is hard to tell.
Discovered as part of !11675.
Also contains minor fixes found while testing the code (missing optional test dependency logic and minor CMake cleanups).
Cc: @jaswant.panchumarti
Backport: release
Edited by Ben Boeckel