LCOV - code coverage report
Current view: top level - Dynamic - GainColoredExpanderFilter.cpp (source / functions) Hit Total Coverage
Test: coverage.info.cleaned Lines: 31 31 100.0 %
Date: 2021-02-18 20:07:22 Functions: 8 8 100.0 %

          Line data    Source code
       1             : /**
       2             :  * \file GainColoredExpanderFilter.cpp
       3             :  */
       4             : 
       5             : #include "GainColoredExpanderFilter.h"
       6             : #include <ATK/Core/Utilities.h>
       7             : #include <ATK/Utility/fmath.h>
       8             : 
       9             : #include <cmath>
      10             : #include <cstdint>
      11             : #include <stdexcept>
      12             : 
      13             : namespace ATK
      14             : {
      15             :   template<typename DataType_>
      16          11 :   GainColoredExpanderFilter<DataType_>::GainColoredExpanderFilter(gsl::index nb_channels, size_t LUTsize, size_t LUTprecision)
      17          11 :   :Parent(nb_channels, LUTsize, LUTprecision)
      18             :   {
      19          11 :   }
      20             : 
      21             :   template<typename DataType_>
      22           4 :   void GainColoredExpanderFilter<DataType_>::set_softness(DataType_ softness)
      23             :   {
      24           4 :     if (softness < 0)
      25             :     {
      26           1 :       throw ATK::RuntimeError("Softness factor must be positive value");
      27             :     }
      28           3 :     this->softness = softness;
      29           3 :     start_recomputeLUT();
      30           3 :   }
      31             :   
      32             :   template<typename DataType_>
      33           1 :   DataType_ GainColoredExpanderFilter<DataType_>::get_softness() const
      34             :   {
      35           1 :     return softness;
      36             :   }
      37             : 
      38             :   template<typename DataType_>
      39           3 :   void GainColoredExpanderFilter<DataType_>::set_color(DataType_ color)
      40             :   {
      41           3 :     this->color = color;
      42           3 :     start_recomputeLUT();
      43           3 :   }
      44             :   
      45             :   template<typename DataType_>
      46           1 :   DataType_ GainColoredExpanderFilter<DataType_>::get_color() const
      47             :   {
      48           1 :     return color;
      49             :   }
      50             :   
      51             :   template<typename DataType_>
      52           4 :   void GainColoredExpanderFilter<DataType_>::set_quality(DataType_ quality)
      53             :   {
      54           4 :     if (quality <= 0)
      55             :     {
      56           1 :       throw ATK::RuntimeError("Quality factor must be a strictly positive value");
      57             :     }
      58           3 :     this->quality = quality;
      59           3 :     start_recomputeLUT();
      60           3 :   }
      61             :   
      62             :   template<typename DataType_>
      63           1 :   DataType_ GainColoredExpanderFilter<DataType_>::get_quality() const
      64             :   {
      65           1 :     return quality;
      66             :   }
      67             : 
      68             :   template<typename DataType_>
      69     1442230 :   DataType_ GainColoredExpanderFilter<DataType_>::computeGain( DataType_ value ) const
      70             :   {
      71     1442230 :     if(value == 0)
      72             :     {
      73          81 :       return 0;
      74             :     }
      75     1442150 :     DataType diff = -10 * fmath::log10(value);
      76     1442150 :     DataType additional_color = color * fmath::exp(- diff * diff * quality);
      77     1442160 :     return static_cast<DataType>(fmath::pow(10, -(std::sqrt(diff*diff + softness) + diff) / 40 * (ratio - 1))) + additional_color;
      78             :   }
      79             : 
      80             : #if ATK_ENABLE_INSTANTIATION
      81             :   template class GainColoredExpanderFilter<float>;
      82             :   template class GainFilter<GainColoredExpanderFilter<float>>;
      83             : #endif
      84             :   template class GainColoredExpanderFilter<double>;
      85             :   template class GainFilter<GainColoredExpanderFilter<double>>;
      86             : }

Generated by: LCOV version TK-3.3.0-4-gdba42eea