Optimizes encoder NaN detection and clipping by only running them when needed

NaN detection should now be able to catch values that would create NaNs
further down.
4 files changed