• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • graphics API Reference
  • KDE Home
  • Contact Us
 

digikam

  • extragear
  • graphics
  • digikam
  • core
  • libs
  • dngwriter
  • extra
  • dng_sdk
dng_opcode_list.cpp
Go to the documentation of this file.
1 /*****************************************************************************/
2 // Copyright 2008-2009 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_3/dng_sdk/source/dng_opcode_list.cpp#1 $ */
10 /* $DateTime: 2009/06/22 05:04:49 $ */
11 /* $Change: 578634 $ */
12 /* $Author: tknoll $ */
13 
14 /*****************************************************************************/
15 
16 #include "dng_opcode_list.h"
17 
18 #include "dng_globals.h"
19 #include "dng_host.h"
20 #include "dng_memory_stream.h"
21 #include "dng_negative.h"
22 #include "dng_tag_values.h"
23 #include "dng_utils.h"
24 
25 /*****************************************************************************/
26 
27 dng_opcode_list::dng_opcode_list (uint32 stage)
28 
29  : fList ()
30  , fAlwaysApply (false)
31  , fStage (stage)
32 
33  {
34 
35  }
36 
37 /******************************************************************************/
38 
39 dng_opcode_list::~dng_opcode_list ()
40  {
41 
42  Clear ();
43 
44  }
45 
46 /******************************************************************************/
47 
48 void dng_opcode_list::Clear ()
49  {
50 
51  for (size_t index = 0; index < fList.size (); index++)
52  {
53 
54  if (fList [index])
55  {
56 
57  delete fList [index];
58 
59  fList [index] = NULL;
60 
61  }
62 
63  }
64 
65  fList.clear ();
66 
67  fAlwaysApply = false;
68 
69  }
70 
71 /******************************************************************************/
72 
73 uint32 dng_opcode_list::MinVersion (bool includeOptional) const
74  {
75 
76  uint32 result = dngVersion_None;
77 
78  for (size_t index = 0; index < fList.size (); index++)
79  {
80 
81  if (includeOptional || !fList [index]->Optional ())
82  {
83 
84  result = Max_uint32 (result, fList [index]->MinVersion ());
85 
86  }
87 
88  }
89 
90  return result;
91 
92  }
93 
94 /*****************************************************************************/
95 
96 void dng_opcode_list::Apply (dng_host &host,
97  dng_negative &negative,
98  AutoPtr<dng_image> &image)
99  {
100 
101  for (uint32 index = 0; index < Count (); index++)
102  {
103 
104  dng_opcode &opcode (Entry (index));
105 
106  if (opcode.AboutToApply (host, negative))
107  {
108 
109  opcode.Apply (host,
110  negative,
111  image);
112 
113  }
114 
115  }
116 
117  }
118 
119 /*****************************************************************************/
120 
121 void dng_opcode_list::Append (AutoPtr<dng_opcode> &opcode)
122  {
123 
124  if (opcode->OpcodeID () == dngOpcode_Private)
125  {
126  SetAlwaysApply ();
127  }
128 
129  opcode->SetStage (fStage);
130 
131  fList.push_back (NULL);
132 
133  fList [fList.size () - 1] = opcode.Release ();
134 
135  }
136 
137 /*****************************************************************************/
138 
139 dng_memory_block * dng_opcode_list::Spool (dng_host &host) const
140  {
141 
142  if (IsEmpty ())
143  {
144  return NULL;
145  }
146 
147  if (AlwaysApply ())
148  {
149  ThrowProgramError ();
150  }
151 
152  dng_memory_stream stream (host.Allocator ());
153 
154  stream.SetBigEndian ();
155 
156  stream.Put_uint32 ((uint32) fList.size ());
157 
158  for (size_t index = 0; index < fList.size (); index++)
159  {
160 
161  stream.Put_uint32 (fList [index]->OpcodeID ());
162  stream.Put_uint32 (fList [index]->MinVersion ());
163  stream.Put_uint32 (fList [index]->Flags ());
164 
165  fList [index]->PutData (stream);
166 
167  }
168 
169  return stream.AsMemoryBlock (host.Allocator ());
170 
171  }
172 
173 /*****************************************************************************/
174 
175 void dng_opcode_list::FingerprintToStream (dng_stream &stream) const
176  {
177 
178  if (IsEmpty ())
179  {
180  return;
181  }
182 
183  stream.Put_uint32 ((uint32) fList.size ());
184 
185  for (size_t index = 0; index < fList.size (); index++)
186  {
187 
188  stream.Put_uint32 (fList [index]->OpcodeID ());
189  stream.Put_uint32 (fList [index]->MinVersion ());
190  stream.Put_uint32 (fList [index]->Flags ());
191 
192  if (fList [index]->OpcodeID () != dngOpcode_Private)
193  {
194 
195  fList [index]->PutData (stream);
196 
197  }
198 
199  }
200 
201  }
202 
203 /*****************************************************************************/
204 
205 void dng_opcode_list::Parse (dng_host &host,
206  dng_stream &stream,
207  uint32 byteCount,
208  uint64 streamOffset)
209  {
210 
211  Clear ();
212 
213  TempBigEndian tempBigEndian (stream);
214 
215  stream.SetReadPosition (streamOffset);
216 
217  uint32 count = stream.Get_uint32 ();
218 
219  #if qDNGValidate
220 
221  if (gVerbose)
222  {
223 
224  if (count == 1)
225  {
226  printf ("1 opcode\n");
227  }
228 
229  else
230  {
231  printf ("%u opcodes\n", count);
232  }
233 
234  }
235 
236  #endif
237 
238  for (uint32 index = 0; index < count; index++)
239  {
240 
241  uint32 opcodeID = stream.Get_uint32 ();
242 
243  AutoPtr<dng_opcode> opcode (host.Make_dng_opcode (opcodeID,
244  stream));
245 
246  Append (opcode);
247 
248  }
249 
250  if (stream.Position () != streamOffset + byteCount)
251  {
252 
253  ThrowBadFormat ("Error parsing opcode list");
254 
255  }
256 
257  }
258 
259 /*****************************************************************************/
dng_opcode::OpcodeID
uint32 OpcodeID() const
Definition: dng_opcodes.h:131
dng_opcode
Definition: dng_opcodes.h:93
dng_opcode_list::AlwaysApply
bool AlwaysApply() const
Definition: dng_opcode_list.h:56
ThrowBadFormat
void ThrowBadFormat(const char *sub_message=NULL)
Convenience function to throw dng_exception with error code dng_error_bad_format .
Definition: dng_exceptions.h:182
dng_memory_stream
A dng_stream which can be read from or written to memory.
Definition: dng_memory_stream.h:33
dng_opcode_list::dng_opcode_list
dng_opcode_list(uint32 stage)
Definition: dng_opcode_list.cpp:27
dng_stream
Base stream abstraction.
Definition: dng_stream.h:42
uint64
unsigned long long uint64
Definition: dng_types.h:65
dng_stream::Put_uint32
void Put_uint32(uint32 x)
Put an unsigned 32-bit integer to stream and advance write position.
Definition: dng_stream.cpp:506
dng_host
The main class for communication between the application and the DNG SDK.
Definition: dng_host.h:50
dng_host.h
Class definition for dng_host, initial point of contact and control between host application and DNG ...
dng_opcode_list::Clear
void Clear()
Definition: dng_opcode_list.cpp:48
dng_tag_values.h
AutoPtr::Release
T * Release()
Return the owned pointer of this AutoPtr, NULL if none. The AutoPtr gives up ownership and takes NULL...
Definition: dng_auto_ptr.h:109
dng_host::Make_dng_opcode
virtual dng_opcode * Make_dng_opcode(uint32 opcodeID, dng_stream &stream)
Factory method for parsing dng_opcode based class.
Definition: dng_host.cpp:328
dng_opcode_list::Append
void Append(AutoPtr< dng_opcode > &opcode)
Definition: dng_opcode_list.cpp:121
dng_opcode_list.h
dng_opcode_list::MinVersion
uint32 MinVersion(bool includeOptional) const
Definition: dng_opcode_list.cpp:73
dng_opcode_list::SetAlwaysApply
void SetAlwaysApply()
Definition: dng_opcode_list.h:61
dng_opcode_list::FingerprintToStream
void FingerprintToStream(dng_stream &stream) const
Definition: dng_opcode_list.cpp:175
dng_stream::SetReadPosition
void SetReadPosition(uint64 offset)
Seek to a new position in stream for reading.
Definition: dng_stream.cpp:190
dng_memory_stream.h
Stream abstraction to/from in-memory data.
TempBigEndian
Definition: dng_stream.h:591
dng_host::Allocator
dng_memory_allocator & Allocator()
Getter for host's memory allocator.
Definition: dng_host.cpp:64
dngVersion_None
Definition: dng_tag_values.h:345
image
#define image
Definition: var_defines.h:38
dng_opcode_list::Count
uint32 Count() const
Definition: dng_opcode_list.h:66
dng_negative.h
dng_opcode_list::~dng_opcode_list
~dng_opcode_list()
Definition: dng_opcode_list.cpp:39
dng_opcode_list::Apply
void Apply(dng_host &host, dng_negative &negative, AutoPtr< dng_image > &image)
Definition: dng_opcode_list.cpp:96
dng_opcode_list::IsEmpty
bool IsEmpty() const
Definition: dng_opcode_list.h:46
dng_stream::Position
uint64 Position() const
Getter for current offset in stream.
Definition: dng_stream.h:187
dng_opcode::AboutToApply
bool AboutToApply(dng_host &host, dng_negative &negative)
Definition: dng_opcodes.cpp:116
dng_opcode::Apply
virtual void Apply(dng_host &host, dng_negative &negative, AutoPtr< dng_image > &image)=0
dng_memory_block
Class to provide resource acquisition is instantiation discipline for image buffers and other larger ...
Definition: dng_memory.h:261
dng_globals.h
Definitions of global variables controling DNG SDK behavior.
dng_stream::SetBigEndian
void SetBigEndian(bool bigEndian=true)
Setter for whether data in stream is big endian.
Definition: dng_stream.cpp:134
dng_opcode_list::Spool
dng_memory_block * Spool(dng_host &host) const
Definition: dng_opcode_list.cpp:139
AutoPtr< dng_image >
dng_negative
Main class for holding DNG image data and associated metadata.
Definition: dng_negative.h:160
dng_opcode_list::Entry
dng_opcode & Entry(uint32 index)
Definition: dng_opcode_list.h:71
ThrowProgramError
void ThrowProgramError(const char *sub_message=NULL)
Convenience function to throw dng_exception with error code dng_error_unknown .
Definition: dng_exceptions.h:110
Max_uint32
uint32 Max_uint32(uint32 x, uint32 y)
Definition: dng_utils.h:121
dng_stream::Get_uint32
uint32 Get_uint32()
Get an unsigned 32-bit integer from stream and advance read position.
Definition: dng_stream.cpp:486
dng_opcode::SetStage
void SetStage(uint32 stage)
Definition: dng_opcodes.h:166
dng_utils.h
uint32
unsigned long uint32
Definition: dng_types.h:63
dngOpcode_Private
Definition: dng_opcodes.h:33
NULL
#define NULL
Definition: NptConstants.h:39
dng_opcode_list::Parse
void Parse(dng_host &host, dng_stream &stream, uint32 byteCount, uint64 streamOffset)
Definition: dng_opcode_list.cpp:205
This file is part of the KDE documentation.
Documentation copyright © 1996-2019 The KDE developers.
Generated on Thu Dec 5 2019 04:36:58 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

digikam

Skip menu "digikam"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages
-->

graphics API Reference

Skip menu "graphics API Reference"
  • digikam
  • KDiagram
  •     KChart
  •     KGantt
  • KPhotoAlbum
  •   AndroidRemoteControl
  • Krita
  •   libs
  •     KritaBasicFlakes
  •     brush
  •     KritaUndo2
  •     KritaFlake
  •     image
  •     KritaPlugin
  •     Krita
  •     KritaOdf
  •     KritaPigment
  •     KritaStore
  •     ui
  •     KritaWidgets
  •     KritaWidgetUtils
  •   plugins
  •     Assitants
  •     Extensions
  •     Filters
  •         KritaText
  •         KritaTextLayout
  •     Generators
  •     Formats
  •             src
  •     PaintOps
  •       libpaintop
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal