1a1fdb2965956d3cbc62e6f8b29405bdeef79dca3Piotr Diop/* 2a1fdb2965956d3cbc62e6f8b29405bdeef79dca3Piotr Diop * Copyright (c) 2011-2015, Intel Corporation 3a1fdb2965956d3cbc62e6f8b29405bdeef79dca3Piotr Diop * All rights reserved. 4a1fdb2965956d3cbc62e6f8b29405bdeef79dca3Piotr Diop * 5a1fdb2965956d3cbc62e6f8b29405bdeef79dca3Piotr Diop * Redistribution and use in source and binary forms, with or without modification, 6a1fdb2965956d3cbc62e6f8b29405bdeef79dca3Piotr Diop * are permitted provided that the following conditions are met: 7a1fdb2965956d3cbc62e6f8b29405bdeef79dca3Piotr Diop * 8a1fdb2965956d3cbc62e6f8b29405bdeef79dca3Piotr Diop * 1. Redistributions of source code must retain the above copyright notice, this 9a1fdb2965956d3cbc62e6f8b29405bdeef79dca3Piotr Diop * list of conditions and the following disclaimer. 10a1fdb2965956d3cbc62e6f8b29405bdeef79dca3Piotr Diop * 11a1fdb2965956d3cbc62e6f8b29405bdeef79dca3Piotr Diop * 2. Redistributions in binary form must reproduce the above copyright notice, 12a1fdb2965956d3cbc62e6f8b29405bdeef79dca3Piotr Diop * this list of conditions and the following disclaimer in the documentation and/or 13a1fdb2965956d3cbc62e6f8b29405bdeef79dca3Piotr Diop * other materials provided with the distribution. 14a1fdb2965956d3cbc62e6f8b29405bdeef79dca3Piotr Diop * 15a1fdb2965956d3cbc62e6f8b29405bdeef79dca3Piotr Diop * 3. Neither the name of the copyright holder nor the names of its contributors 16a1fdb2965956d3cbc62e6f8b29405bdeef79dca3Piotr Diop * may be used to endorse or promote products derived from this software without 17a1fdb2965956d3cbc62e6f8b29405bdeef79dca3Piotr Diop * specific prior written permission. 18a1fdb2965956d3cbc62e6f8b29405bdeef79dca3Piotr Diop * 19a1fdb2965956d3cbc62e6f8b29405bdeef79dca3Piotr Diop * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20a1fdb2965956d3cbc62e6f8b29405bdeef79dca3Piotr Diop * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21a1fdb2965956d3cbc62e6f8b29405bdeef79dca3Piotr Diop * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22a1fdb2965956d3cbc62e6f8b29405bdeef79dca3Piotr Diop * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 23a1fdb2965956d3cbc62e6f8b29405bdeef79dca3Piotr Diop * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24a1fdb2965956d3cbc62e6f8b29405bdeef79dca3Piotr Diop * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25a1fdb2965956d3cbc62e6f8b29405bdeef79dca3Piotr Diop * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 26a1fdb2965956d3cbc62e6f8b29405bdeef79dca3Piotr Diop * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27a1fdb2965956d3cbc62e6f8b29405bdeef79dca3Piotr Diop * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28a1fdb2965956d3cbc62e6f8b29405bdeef79dca3Piotr Diop * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29a1fdb2965956d3cbc62e6f8b29405bdeef79dca3Piotr Diop */ 30a1fdb2965956d3cbc62e6f8b29405bdeef79dca3Piotr Diop 31a1fdb2965956d3cbc62e6f8b29405bdeef79dca3Piotr Diop#pragma once 32a1fdb2965956d3cbc62e6f8b29405bdeef79dca3Piotr Diop 33a1fdb2965956d3cbc62e6f8b29405bdeef79dca3Piotr Diop#include "LinearParameterAdaptation.h" 349368eea42a1afb01dd44110582f997115b50e742François Gaffie#include <cmath> 359368eea42a1afb01dd44110582f997115b50e742François Gaffie#include <limits> 36a1fdb2965956d3cbc62e6f8b29405bdeef79dca3Piotr Diop 37a1fdb2965956d3cbc62e6f8b29405bdeef79dca3Piotr Diop/** 38a1fdb2965956d3cbc62e6f8b29405bdeef79dca3Piotr Diop * This class is used to perform a logarithmic adapation of type: 39a1fdb2965956d3cbc62e6f8b29405bdeef79dca3Piotr Diop * (slopeNumerator / slopeDenominator) * log(parameter) + offset 40a1fdb2965956d3cbc62e6f8b29405bdeef79dca3Piotr Diop * Since log(x) == -INFINITY , we can define FloorValue as a 41a1fdb2965956d3cbc62e6f8b29405bdeef79dca3Piotr Diop * x -> 0 42a1fdb2965956d3cbc62e6f8b29405bdeef79dca3Piotr Diop * a lower bound limit for the adaptation 43a1fdb2965956d3cbc62e6f8b29405bdeef79dca3Piotr Diop */ 44a1fdb2965956d3cbc62e6f8b29405bdeef79dca3Piotr Diopclass CLogarithmicParameterAdaptation : public CLinearParameterAdaptation 45a1fdb2965956d3cbc62e6f8b29405bdeef79dca3Piotr Diop{ 46a1fdb2965956d3cbc62e6f8b29405bdeef79dca3Piotr Dioppublic: 47a1fdb2965956d3cbc62e6f8b29405bdeef79dca3Piotr Diop CLogarithmicParameterAdaptation(); 48a1fdb2965956d3cbc62e6f8b29405bdeef79dca3Piotr Diop 49a1fdb2965956d3cbc62e6f8b29405bdeef79dca3Piotr Diop /** 50a1fdb2965956d3cbc62e6f8b29405bdeef79dca3Piotr Diop * Conversions must satisfy the following: f(f'(a)) = a 51a1fdb2965956d3cbc62e6f8b29405bdeef79dca3Piotr Diop * Let f=fromUserValue and f'=toUserValue 52a1fdb2965956d3cbc62e6f8b29405bdeef79dca3Piotr Diop * if y = f(log(x)/log(base)), then 53a1fdb2965956d3cbc62e6f8b29405bdeef79dca3Piotr Diop * f'(y) * log(base) = log (x) 54a1fdb2965956d3cbc62e6f8b29405bdeef79dca3Piotr Diop * exp(f'(y)*log(base)) = x 55a1fdb2965956d3cbc62e6f8b29405bdeef79dca3Piotr Diop */ 56a1fdb2965956d3cbc62e6f8b29405bdeef79dca3Piotr Diop virtual int64_t fromUserValue(double dValue) const; 57a1fdb2965956d3cbc62e6f8b29405bdeef79dca3Piotr Diop virtual double toUserValue(int64_t iValue) const; 58a1fdb2965956d3cbc62e6f8b29405bdeef79dca3Piotr Diop 599368eea42a1afb01dd44110582f997115b50e742François Gaffie virtual void showProperties(std::string &strResult) const; 609368eea42a1afb01dd44110582f997115b50e742François Gaffie 619368eea42a1afb01dd44110582f997115b50e742François Gaffie virtual bool fromXml(const CXmlElement &xmlElement, CXmlSerializingContext &serializingContext); 62a1fdb2965956d3cbc62e6f8b29405bdeef79dca3Piotr Diop 63a1fdb2965956d3cbc62e6f8b29405bdeef79dca3Piotr Diopprivate: 64a1fdb2965956d3cbc62e6f8b29405bdeef79dca3Piotr Diop /** 65a1fdb2965956d3cbc62e6f8b29405bdeef79dca3Piotr Diop * _dLogarithmBase characterizes the new logarithm logB(x) with 66a1fdb2965956d3cbc62e6f8b29405bdeef79dca3Piotr Diop * the following property: logB(x) = log(x) / log(_dLogarithmBase). 67a1fdb2965956d3cbc62e6f8b29405bdeef79dca3Piotr Diop * log being the base-e logarithm. 689368eea42a1afb01dd44110582f997115b50e742François Gaffie * 699368eea42a1afb01dd44110582f997115b50e742François Gaffie * std::exp(1) == e^1 == e == natural logarithm base 709368eea42a1afb01dd44110582f997115b50e742François Gaffie * Make sure there is no precision lose by using std::exp overload that 719368eea42a1afb01dd44110582f997115b50e742François Gaffie * return the same type as _dLogarithmBase 72a1fdb2965956d3cbc62e6f8b29405bdeef79dca3Piotr Diop */ 739368eea42a1afb01dd44110582f997115b50e742François Gaffie double _dLogarithmBase{std::exp(decltype(_dLogarithmBase){1})}; 74a1fdb2965956d3cbc62e6f8b29405bdeef79dca3Piotr Diop /** 75a1fdb2965956d3cbc62e6f8b29405bdeef79dca3Piotr Diop * _dFloorValue reflects the lower bound for volume attenuation 76a1fdb2965956d3cbc62e6f8b29405bdeef79dca3Piotr Diop */ 779368eea42a1afb01dd44110582f997115b50e742François Gaffie double _dFloorValue{-std::numeric_limits<double>::infinity()}; 78a1fdb2965956d3cbc62e6f8b29405bdeef79dca3Piotr Diop}; 79