/* * Copyright (c) Contributors to the Open 3D Engine Project. * For complete copyright and license terms please see the LICENSE at the root of this distribution. * * SPDX-License-Identifier: Apache-2.0 OR MIT * */ #pragma once #include "FIR-Windows.h" namespace ImageProcessingAtom { /* #################################################################################################################### */ template inline DataType abs (const DataType& ths) { return (ths < 0 ? -ths : ths); } template inline void minmax (const DataType& ths, DataType& mn, DataType& mx) { mn = (mn > ths ? ths : mn); mx = (mx < ths ? ths : mx); } template inline DataType minimum(const DataType& ths, const DataType& tht) { return (ths < tht ? ths : tht); } template inline DataType maximum(const DataType& ths, const DataType& tht) { return (ths > tht ? ths : tht); } /* #################################################################################################################### */ template class FilterWeights { public: FilterWeights() : weights(nullptr) { } ~FilterWeights() { delete[] weights; } public: // window-position int first, last; // do we encounter positive as well as negative weights bool hasNegativeWeights; /* weights, summing up to -(1 << 15), * means weights are given negative * that enables us to use signed short * multiplication while occupying 0x8000 */ T* weights; }; /* #################################################################################################################### */ void calculateFilterRange (unsigned int srcFactor, int& srcFirst, int& srcLast, unsigned int dstFactor, int dstFirst, int dstLast, double blurFactor, class IWindowFunction* windowFunction); template FilterWeights* calculateFilterWeights(unsigned int srcFactor, int srcFirst, int srcLast, unsigned int dstFactor, int dstFirst, int dstLast, signed short int numRepetitions, double blurFactor, class IWindowFunction* windowFunction, bool peaknorm, bool& plusminus); template<> FilterWeights* calculateFilterWeights(unsigned int srcFactor, int srcFirst, int srcLast, unsigned int dstFactor, int dstFirst, int dstLast, signed short int numRepetitions, double blurFactor, class IWindowFunction* windowFunction, bool peaknorm, bool& plusminus); } //end namespace ImageProcessingAtom