imgproc: IPP compilation fix and minor cleanup

This PR fixes a couple of IPP compilation issues in imgproc, and cleans up a small amount of code duplication in `sumpixels`.

It also fixes a bug where, if using IPP, `_sqsum.needed()` and `sqdepth != CV_64F`, then `sqsum` would not be filled despite being needed.