Coverage Report

Created: 2026-06-02 06:13

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/dng_sdk/source/dng_orientation.cpp
Line
Count
Source
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_orientation.cpp#1 $ */ 
10
/* $DateTime: 2012/05/30 13:28:51 $ */
11
/* $Change: 832332 $ */
12
/* $Author: tknoll $ */
13
14
#include "dng_orientation.h"
15
16
/*****************************************************************************/
17
18
void dng_orientation::SetTIFF (uint32 tiff)
19
7.38k
  {
20
  
21
7.38k
  switch (tiff)
22
7.38k
    {
23
    
24
6.41k
    case 1:
25
6.41k
      {
26
6.41k
      fAdobeOrientation = kNormal;
27
6.41k
      break;
28
0
      }
29
    
30
238
    case 2:
31
238
      {
32
238
      fAdobeOrientation = kMirror;
33
238
      break;
34
0
      }
35
      
36
138
    case 3:
37
138
      {
38
138
      fAdobeOrientation = kRotate180;
39
138
      break;
40
0
      }
41
      
42
122
    case 4:
43
122
      {
44
122
      fAdobeOrientation = kMirror180;
45
122
      break;
46
0
      }
47
      
48
120
    case 5:
49
120
      {
50
120
      fAdobeOrientation = kMirror90CCW;
51
120
      break;
52
0
      }
53
      
54
38
    case 6:
55
38
      {
56
38
      fAdobeOrientation = kRotate90CW;
57
38
      break;
58
0
      }
59
      
60
133
    case 7:
61
133
      {
62
133
      fAdobeOrientation = kMirror90CW;
63
133
      break;
64
0
      }
65
      
66
180
    case 8:
67
180
      {
68
180
      fAdobeOrientation = kRotate90CCW;
69
180
      break;
70
0
      }
71
      
72
0
    case 9:
73
0
      {
74
0
      fAdobeOrientation = kUnknown;
75
0
      break;
76
0
      }
77
      
78
0
    default:
79
0
      {
80
0
      fAdobeOrientation = kNormal;
81
0
      }
82
83
7.38k
    }
84
    
85
7.38k
  }
86
87
/*****************************************************************************/
88
89
uint32 dng_orientation::GetTIFF () const
90
15.8k
  {
91
  
92
15.8k
  switch (fAdobeOrientation)
93
15.8k
    {
94
    
95
15.4k
    case kNormal:
96
15.4k
      {
97
15.4k
      return 1;
98
0
      }
99
    
100
72
    case kMirror:
101
72
      {
102
72
      return 2;
103
0
      }
104
      
105
92
    case kRotate180:
106
92
      {
107
92
      return 3;
108
0
      }
109
      
110
61
    case kMirror180:
111
61
      {
112
61
      return 4;
113
0
      }
114
      
115
45
    case kMirror90CCW:
116
45
      {
117
45
      return 5;
118
0
      }
119
      
120
23
    case kRotate90CW:
121
23
      {
122
23
      return 6;
123
0
      }
124
      
125
38
    case kMirror90CW:
126
38
      {
127
38
      return 7;
128
0
      }
129
      
130
70
    case kRotate90CCW:
131
70
      {
132
70
      return 8;
133
0
      }
134
      
135
0
    case kUnknown:
136
0
      {
137
0
      return 9;
138
0
      }
139
      
140
0
    default:
141
0
      break;
142
143
15.8k
    }
144
    
145
0
  return 1;
146
    
147
15.8k
  }
148
    
149
/*****************************************************************************/
150
151
bool dng_orientation::FlipD () const
152
4.43k
  {
153
  
154
4.43k
  return (fAdobeOrientation & 1) != 0;
155
  
156
4.43k
  }
157
    
158
/*****************************************************************************/
159
160
bool dng_orientation::FlipH () const
161
4.43k
  {
162
  
163
4.43k
  if (fAdobeOrientation & 4)
164
50
    return (fAdobeOrientation & 2) == 0;
165
    
166
4.38k
  else
167
4.38k
    return (fAdobeOrientation & 2) != 0;
168
    
169
4.43k
  }
170
    
171
/*****************************************************************************/
172
173
bool dng_orientation::FlipV () const
174
2.21k
  {
175
  
176
2.21k
  if (fAdobeOrientation & 4)
177
25
    return FlipD () == FlipH ();
178
    
179
2.19k
  else
180
2.19k
    return FlipD () != FlipH ();
181
    
182
2.21k
  }
183
184
/*****************************************************************************/
185
186
dng_orientation dng_orientation::operator- () const
187
0
  {
188
  
189
0
  uint32 x = GetAdobe ();
190
  
191
0
  if ((x & 5) == 5)
192
0
    {
193
    
194
0
    x ^= 2;
195
    
196
0
    }
197
    
198
0
  dng_orientation result;
199
200
0
  result.SetAdobe (((4 - x) & 3) | (x & 4));
201
  
202
0
  return result;
203
204
0
  }
205
    
206
/*****************************************************************************/
207
208
dng_orientation dng_orientation::operator+ (const dng_orientation &b) const
209
0
  {
210
  
211
0
  uint32 x = GetAdobe ();
212
  
213
0
  uint32 y = b.GetAdobe ();
214
  
215
0
  if (y & 4)
216
0
    {
217
    
218
0
    if (x & 1)
219
0
      x ^= 6;
220
0
    else
221
0
      x ^= 4;
222
    
223
0
    }
224
    
225
0
  dng_orientation result;
226
227
0
  result.SetAdobe (((x + y) & 3) | (x & 4));
228
  
229
0
  return result;
230
  
231
0
  }
232
    
233
/*****************************************************************************/