Debian Codegraph @

core/libs/dngwriter/extra/dng_sdk/dng_xmp.h

raw
1 /*****************************************************************************/
2 // Copyright 2006-2019 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 #ifndef __dng_xmp__
10 #define __dng_xmp__
11
12 /*****************************************************************************/
13
14 #include "dng_flags.h"
15
16 /*****************************************************************************/
17
18 #if qDNGUseXMP
19
20 /*****************************************************************************/
21
22 #include "dng_classes.h"
23 #include "dng_types.h"
24 #include "dng_xmp_sdk.h"
25
26 /*****************************************************************************/
27
28 class dng_xmp
29 {
30
31 protected:
32
33 // Sync option bits.
34
35 enum
36 {
37 ignoreXMP = 1, // Force XMP values to match non-XMP
38 preferXMP = 2, // Prefer XMP values if conflict
39 preferNonXMP = 4, // Prefer non-XMP values if conflict
40 removeXMP = 8, // Remove XMP value after syncing
41 requireXMP = 16 // Require XMP tag even if default
42 };
43
44 dng_memory_allocator &fAllocator;
45
46 dng_xmp_sdk *fSDK;
47
48 public:
49
50 dng_xmp (dng_memory_allocator &allocator);
51
52 dng_xmp (const dng_xmp &xmp);
53
54 virtual ~dng_xmp ();
55
56 virtual dng_xmp * Clone () const;
57
58 dng_memory_allocator & Allocator () const
59 {
60 return fAllocator;
61 }
62
63 void Parse (dng_host &host,
64 const void *buffer,
65 uint32 count);
66
67 dng_memory_block * Serialize (bool asPacket = false,
68 uint32 targetBytes = 0,
69 uint32 padBytes = 4096,
70 bool forJPEG = false,
71 bool compact = true) const;
72
73 // Kludge: Due to a bug in Premere Elements 9, we need to pass non-compact XMP
74 // to the host, until we drop support for this Premere version. This bug
75 // is fixed in Premere Elements 10 and later.
76
77 dng_memory_block * SerializeNonCompact () const
78 {
79 return Serialize (false,
80 0,
81 4096,
82 false,
83 false);
84 }
85
86 void PackageForJPEG (AutoPtr<dng_memory_block> &stdBlock,
87 AutoPtr<dng_memory_block> &extBlock,
88 dng_string &extDigest) const;
89
90 void MergeFromJPEG (const dng_xmp &xmp);
91
92 bool HasMeta () const;
93
94 void RequireMeta ()
95 {
96 fSDK->RequireMeta ();
97 }
98
99 void * GetPrivateMeta ();
100
101 bool Exists (const char *ns,
102 const char *path) const;
103
104 bool HasNameSpace (const char *ns) const;
105
106 bool IteratePaths (IteratePathsCallback *callback,
107 void *callbackData,
108 const char *ns = NULL,
109 const char *path = NULL,
110 bool justChildren = false) const;
111
112 void DuplicateSubtree (const dng_xmp &source,
113 const char *sourceNS,
114 const char *sourceRoot,
115 const char *destNS = NULL,
116 const char *destRoot = NULL);
117
118 void DuplicateNameSpace (const dng_xmp &source,
119 const char *ns);
120
121 void Remove (const char *ns,
122 const char *path);
123
124 void RemoveProperties (const char *ns);
125
126 void RemoveEmptyStringOrArray (const char *ns,
127 const char *path);
128
129 void RemoveEmptyStringsAndArrays (const char *ns = 0);
130
131 void Set (const char *ns,
132 const char *path,
133 const char *text);
134
135 bool GetString (const char *ns,
136 const char *path,
137 dng_string &s) const;
138
139 void SetString (const char *ns,
140 const char *path,
141 const dng_string &s);
142
143 bool GetStringList (const char *ns,
144 const char *path,
145 dng_string_list &list,
146 dng_abort_sniffer *sniffer = NULL) const;
147
148 void SetStringList (const char *ns,
149 const char *path,
150 const dng_string_list &list,
151 bool isBag = false);
152
153 void SetStructField (const char *ns,
154 const char *path,
155 const char *fieldNS,
156 const char *fieldName,
157 const dng_string &s);
158
159 void SetStructField (const char *ns,
160 const char *path,
161 const char *fieldNS,
162 const char *fieldName,
163 const char *s);
164
165 void DeleteStructField (const char *ns,
166 const char *path,
167 const char *fieldNS,
168 const char *fieldName);
169
170 bool GetStructField (const char *ns,
171 const char *path,
172 const char *fieldNS,
173 const char *fieldName,
174 dng_string &s) const;
175
176 void SetAltLangDefault (const char *ns,
177 const char *path,
178 const dng_string &s);
179
180 void SetLocalString (const char *ns,
181 const char *path,
182 const dng_local_string &s);
183
184 bool GetAltLangDefault (const char *ns,
185 const char *path,
186 dng_string &s,
187 bool silent = false) const;
188
189 bool GetLocalString (const char *ns,
190 const char *path,
191 dng_local_string &s) const;
192
193 bool GetBoolean (const char *ns,
194 const char *path,
195 bool &x) const;
196
197 void SetBoolean (const char *ns,
198 const char *path,
199 bool x);
200
201 bool Get_int32 (const char *ns,
202 const char *path,
203 int32 &x) const;
204
205 void Set_int32 (const char *ns,
206 const char *path,
207 int32 x,
208 bool usePlus = false);
209
210 bool Get_uint32 (const char *ns,
211 const char *path,
212 uint32 &x) const;
213
214 void Set_uint32 (const char *ns,
215 const char *path,
216 uint32 x);
217
218 bool Get_real64 (const char *ns,
219 const char *path,
220 real64 &x) const;
221
222 void Set_real64 (const char *ns,
223 const char *path,
224 real64 x,
225 uint32 places = 6,
226 bool trim = true,
227 bool usePlus = false);
228
229 bool Get_urational (const char *ns,
230 const char *path,
231 dng_urational &r) const;
232
233 void Set_urational (const char *ns,
234 const char *path,
235 const dng_urational &r);
236
237 bool Get_srational (const char *ns,
238 const char *path,
239 dng_srational &r) const;
240
241 void Set_srational (const char *ns,
242 const char *path,
243 const dng_srational &r);
244
245 bool GetFingerprint (const char *ns,
246 const char *path,
247 dng_fingerprint &print) const;
248
249 void SetFingerprint (const char *ns,
250 const char *path,
251 const dng_fingerprint &print,
252 bool allowInvalid = false);
253
254 void SetVersion2to4 (const char *ns,
255 const char *path,
256 uint32 version);
257
258 dng_fingerprint GetIPTCDigest () const;
259
260 void SetIPTCDigest (dng_fingerprint &digest);
261
262 void ClearIPTCDigest ();
263
264 void IngestIPTC (dng_metadata &metadata,
265 bool xmpIsNewer = false);
266
267 void RebuildIPTC (dng_metadata &metadata,
268 dng_memory_allocator &allocator,
269 bool padForTIFF);
270
271 virtual void SyncExif (dng_exif &exif,
272 const dng_exif *originalExif = NULL,
273 bool doingUpdateFromXMP = false,
274 bool removeFromXMP = false);
275
276 void ValidateStringList (const char *ns,
277 const char *path);
278
279 void ValidateMetadata ();
280
281 void UpdateDateTime (const dng_date_time_info &dt);
282
283 void UpdateMetadataDate (const dng_date_time_info &dt);
284
285 void UpdateExifDates (dng_exif &exif,
286 bool removeFromXMP = false);
287
288 bool HasOrientation () const;
289
290 dng_orientation GetOrientation () const;
291
292 void ClearOrientation ();
293
294 void SetOrientation (const dng_orientation &orientation);
295
296 void SyncOrientation (dng_negative &negative,
297 bool xmpIsMaster);
298 // FIX_ME_API: Backwards compatibility
299
300 void SyncOrientation (dng_metadata &metadata,
301 bool xmpIsMaster);
302
303 void ClearImageInfo ();
304
305 void SetImageSize (const dng_point &size);
306
307 void SetSampleInfo (uint32 samplesPerPixel,
308 uint32 bitsPerSample);
309
310 void SetPhotometricInterpretation (uint32 pi);
311
312 void SetResolution (const dng_resolution &res);
313
314 void ComposeArrayItemPath (const char *ns,
315 const char *arrayName,
316 int32 itemNumber,
317 dng_string &s) const;
318
319 void ComposeStructFieldPath (const char *ns,
320 const char *structName,
321 const char *fieldNS,
322 const char *fieldName,
323 dng_string &s) const;
324
325 int32 CountArrayItems (const char *ns,
326 const char *path) const;
327
328 void AppendArrayItem (const char *ns,
329 const char *arrayName,
330 const char *itemValue,
331 bool isBag = true,
332 bool propIsStruct = false);
333
334 static dng_string EncodeFingerprint (const dng_fingerprint &f,
335 bool allowInvalid = false);
336
337 static dng_fingerprint DecodeFingerprint (const dng_string &s);
338
339 #if qDNGXMPDocOps
340
341 void DocOpsOpenXMP (const char *srcMIME);
342
343 void DocOpsPrepareForSave (const char *srcMIME,
344 const char *dstMIME,
345 bool newPath = true);
346
347 void DocOpsUpdateMetadata (const char *srcMIME);
348
349 #endif
350
351 protected:
352
353 static void TrimDecimal (char *s);
354
355 static dng_string EncodeGPSVersion (uint32 version);
356
357 static uint32 DecodeGPSVersion (const dng_string &s);
358
359 static dng_string EncodeGPSCoordinate (const dng_string &ref,
360 const dng_urational *coord);
361
362 static void DecodeGPSCoordinate (const dng_string &s,
363 dng_string &ref,
364 dng_urational *coord);
365
366 static dng_string EncodeGPSDateTime (const dng_string &dateStamp,
367 const dng_urational *timeStamp);
368
369 static void DecodeGPSDateTime (const dng_string &s,
370 dng_string &dateStamp,
371 dng_urational *timeStamp);
372
373 bool SyncString (const char *ns,
374 const char *path,
375 dng_string &s,
376 uint32 options = 0);
377
378 void SyncStringList (const char *ns,
379 const char *path,
380 dng_string_list &list,
381 bool isBag = false,
382 uint32 options = 0);
383
384 bool SyncAltLangDefault (const char *ns,
385 const char *path,
386 dng_string &s,
387 uint32 options = 0);
388
389 void Sync_uint32 (const char *ns,
390 const char *path,
391 uint32 &x,
392 bool isDefault = false,
393 uint32 options = 0,
394 uint32 defaultValue = 0);
395
396 void Sync_uint32_array (const char *ns,
397 const char *path,
398 uint32 *data,
399 uint32 &count,
400 uint32 maxCount,
401 uint32 options = 0);
402
403 void Sync_urational (const char *ns,
404 const char *path,
405 dng_urational &r,
406 uint32 options = 0);
407
408 void Sync_srational (const char *ns,
409 const char *path,
410 dng_srational &r,
411 uint32 options = 0);
412
413 void SyncIPTC (dng_iptc &iptc,
414 uint32 options);
415
416 void SyncFlash (uint32 &flashState,
417 uint32 &flashMask,
418 uint32 options);
419
420 void SyncExifDate (const char *ns,
421 const char *path,
422 dng_date_time_info &exifDateTime,
423 bool canRemoveFromXMP,
424 bool removeFromXMP,
425 const dng_time_zone &fakeTimeZone);
426
427 virtual void SyncApproximateFocusDistance (dng_exif &exif,
428 const uint32 readOnly);
429
430 virtual void SyncLensName (dng_exif &exif);
431
432 virtual void GenerateDefaultLensName (dng_exif &exif);
433
434 private:
435
436 // Hidden assignment operator.
437
438 dng_xmp & operator= (const dng_xmp &xmp);
439
440 };
441
442 /*****************************************************************************/
443
444 #endif // qDNGUseXMP
445
446 /*****************************************************************************/
447
448 #endif // __dng_xmp__
449
450 /*****************************************************************************/