/* * All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or * its licensors. * * For complete copyright and license terms please see the LICENSE at the root of this * distribution (the "License"). All use of this software is governed by the License, * or, if provided, by the license below or the license accompanying this file. Do not * remove or modify any license notices. This file is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * */ // Original file Copyright Crytek GMBH or its affiliates, used under license. #pragma once #include "FIR-Windows.h" namespace ImageProcessing { /* #################################################################################################################### */ template static inline DataType abs (const DataType& ths) { return (ths < 0 ? -ths : ths); } template static inline void minmax (const DataType& ths, DataType& mn, DataType& mx) { mn = (mn > ths ? ths : mn); mx = (mx < ths ? ths : mx); } template static inline DataType minimum(const DataType& ths, const DataType& tht) { return (ths < tht ? ths : tht); } template static 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 ImageProcessing