Coverage Report

Created: 2025-07-23 06:38

/src/dng_sdk/source/dng_1d_function.cpp
Line
Count
Source (jump to first uncovered line)
1
/*****************************************************************************/
2
// Copyright 2006 Adobe Systems Incorporated
3
// All Rights Reserved.
4
//
5
// NOTICE:  Adobe permits you to use, modify, and distribute this file in
6
// accordance with the terms of the Adobe license agreement accompanying it.
7
/*****************************************************************************/
8
9
/* $Id: //mondo/dng_sdk_1_4/dng_sdk/source/dng_1d_function.cpp#1 $ */ 
10
/* $DateTime: 2012/05/30 13:28:51 $ */
11
/* $Change: 832332 $ */
12
/* $Author: tknoll $ */
13
14
/*****************************************************************************/
15
16
#include "dng_1d_function.h"
17
18
#include "dng_utils.h"
19
20
/*****************************************************************************/
21
22
dng_1d_function::~dng_1d_function ()
23
72.1k
  {
24
  
25
72.1k
  }
26
27
/*****************************************************************************/
28
29
bool dng_1d_function::IsIdentity () const
30
0
  {
31
  
32
0
  return false;
33
  
34
0
  }
35
36
/*****************************************************************************/
37
38
real64 dng_1d_function::EvaluateInverse (real64 y) const
39
0
  {
40
  
41
0
  const uint32 kMaxIterations = 30;
42
0
  const real64 kNearZero      = 1.0e-10;
43
  
44
0
  real64 x0 = 0.0;
45
0
  real64 y0 = Evaluate (x0);
46
  
47
0
  real64 x1 = 1.0;
48
0
  real64 y1 = Evaluate (x1);
49
  
50
0
  for (uint32 iteration = 0; iteration < kMaxIterations; iteration++)   
51
0
    {
52
    
53
0
    if (Abs_real64 (y1 - y0) < kNearZero)
54
0
      {
55
0
      break;
56
0
      }
57
    
58
0
    real64 x2 = Pin_real64 (0.0, 
59
0
                x1 + (y - y1) * (x1 - x0) / (y1 - y0),
60
0
                1.0);
61
    
62
0
    real64 y2 = Evaluate (x2);
63
    
64
0
    x0 = x1;
65
0
    y0 = y1;
66
    
67
0
    x1 = x2;
68
0
    y1 = y2;
69
    
70
0
    }
71
  
72
0
  return x1;
73
  
74
0
  }
75
  
76
/*****************************************************************************/
77
78
bool dng_1d_identity::IsIdentity () const
79
0
  {
80
  
81
0
  return true;
82
  
83
0
  }
84
    
85
/*****************************************************************************/
86
87
real64 dng_1d_identity::Evaluate (real64 x) const
88
1.26M
  {
89
  
90
1.26M
  return x;
91
  
92
1.26M
  }
93
    
94
/*****************************************************************************/
95
96
real64 dng_1d_identity::EvaluateInverse (real64 x) const
97
0
  {
98
  
99
0
  return x;
100
  
101
0
  }
102
    
103
/*****************************************************************************/
104
105
const dng_1d_function & dng_1d_identity::Get ()
106
341
  {
107
  
108
341
  static dng_1d_identity static_function;
109
  
110
341
  return static_function;
111
  
112
341
  }
113
114
/*****************************************************************************/
115
116
dng_1d_concatenate::dng_1d_concatenate (const dng_1d_function &function1,
117
                    const dng_1d_function &function2)
118
                    
119
8.69k
  : fFunction1 (function1)
120
8.69k
  , fFunction2 (function2)
121
  
122
8.69k
  {
123
  
124
8.69k
  }
125
  
126
/*****************************************************************************/
127
128
bool dng_1d_concatenate::IsIdentity () const
129
0
  {
130
  
131
0
  return fFunction1.IsIdentity () &&
132
0
       fFunction2.IsIdentity ();
133
  
134
0
  }
135
    
136
/*****************************************************************************/
137
138
real64 dng_1d_concatenate::Evaluate (real64 x) const
139
35.6M
  {
140
  
141
35.6M
  real64 y = Pin_real64 (0.0, fFunction1.Evaluate (x), 1.0);
142
  
143
35.6M
  return fFunction2.Evaluate (y);
144
  
145
35.6M
  }
146
147
/*****************************************************************************/
148
149
real64 dng_1d_concatenate::EvaluateInverse (real64 x) const
150
0
  {
151
  
152
0
  real64 y = fFunction2.EvaluateInverse (x);
153
  
154
0
  return fFunction1.EvaluateInverse (y);
155
  
156
0
  }
157
  
158
/*****************************************************************************/
159
160
dng_1d_inverse::dng_1d_inverse (const dng_1d_function &f)
161
  
162
6
  : fFunction (f)
163
  
164
6
  {
165
  
166
6
  }
167
  
168
/*****************************************************************************/
169
170
bool dng_1d_inverse::IsIdentity () const
171
0
  {
172
  
173
0
  return fFunction.IsIdentity ();
174
  
175
0
  }
176
  
177
/*****************************************************************************/
178
179
real64 dng_1d_inverse::Evaluate (real64 x) const
180
24.5k
  {
181
  
182
24.5k
  return fFunction.EvaluateInverse (x);
183
  
184
24.5k
  }
185
186
/*****************************************************************************/
187
188
real64 dng_1d_inverse::EvaluateInverse (real64 y) const
189
0
  {
190
  
191
0
  return fFunction.Evaluate (y);
192
  
193
0
  }
194
  
195
/*****************************************************************************/