|
1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // This feature is documented in ICL_Design_EXIF.doc |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file |
|
20 @publishedAll |
|
21 @released |
|
22 */ |
|
23 |
|
24 #include <iclexifimageframe.h> |
|
25 #include "ImageClientMain.h" |
|
26 |
|
27 _LIT(KImageFramePluginPanicCategory, "JPEGImageFramePlugin"); |
|
28 |
|
29 // Global panic function |
|
30 GLDEF_C void Panic(TIclPanic aError) |
|
31 { |
|
32 User::Panic(KImageFramePluginPanicCategory, aError); |
|
33 } |
|
34 |
|
35 |
|
36 // |
|
37 // CJpegImageFrameDecoder // |
|
38 // |
|
39 |
|
40 /** |
|
41 A factory function that constructs a JPEG CImageFrame decoder as an extension of the ICL EXIF decoder. |
|
42 |
|
43 A leave occurs if there is insufficient memory available. |
|
44 |
|
45 @return A pointer to the new JPEG CImageFrame decoder. |
|
46 */ |
|
47 EXPORT_C CJPEGImageFrameDecoder* CJPEGImageFrameDecoder::NewL() |
|
48 { |
|
49 CJPEGImageFrameDecoder* self; |
|
50 self = new (ELeave) CJPEGImageFrameDecoder; |
|
51 CleanupStack::PushL(self); |
|
52 self->CJPEGExifDecoder::ConstructL(); |
|
53 CleanupStack::Pop(self); |
|
54 return self; |
|
55 } |
|
56 |
|
57 |
|
58 /** |
|
59 Constructor for the CJPEGImageFrameDecoder class. |
|
60 */ |
|
61 EXPORT_C CJPEGImageFrameDecoder::CJPEGImageFrameDecoder() |
|
62 { |
|
63 } |
|
64 |
|
65 /** |
|
66 Destructor for the CJPEGImageFrameDecoder class. |
|
67 */ |
|
68 EXPORT_C CJPEGImageFrameDecoder::~CJPEGImageFrameDecoder() |
|
69 { |
|
70 } |
|
71 |
|
72 /** |
|
73 Basic decode convert call for destinations of type CImageFrame. |
|
74 |
|
75 @pre |
|
76 The destination CImageFrame, must be created before the call to ConvertFrame() is made. |
|
77 |
|
78 aDestFrame must be large enough to contain the decoded frame. |
|
79 CJPEGImageFrameDecoder::RecommendedBufferSize() can be used to obtain the required buffer size in the CImageFrame. |
|
80 |
|
81 This convert call is a standard asynchronous operation. It takes a pointer to the TRequestStatus object |
|
82 of the waiting active object in the main application which will be signalled when the operation is completed. |
|
83 |
|
84 If the operation completes with KErrUnderflow, then there is insufficient |
|
85 information in the source file or descriptor. In this situation, ContinueConvertFrame() should be |
|
86 called repeatedly until the source file or descriptor has accumulated enough information |
|
87 for ContinueConvertFrame() to complete with KErrNone. |
|
88 |
|
89 @param aRequestStatus |
|
90 Pointer to the TRequestStatus object that is signalled on completion. |
|
91 Contains an error code. |
|
92 KErrNone if frame was decoded successfully, |
|
93 otherwise another of the system-wide error codes. |
|
94 @param aDestFrame |
|
95 A CImageFrame that will contain the decoded frame. |
|
96 */ |
|
97 EXPORT_C void CJPEGImageFrameDecoder::ConvertFrame(TRequestStatus* aRequestStatus, CImageFrame& aDestFrame) |
|
98 { |
|
99 // Call ConvertFrame with Frame Number equal to 0 |
|
100 ConvertFrame(aRequestStatus, aDestFrame, 0); |
|
101 } |
|
102 |
|
103 /** |
|
104 Basic decode convert call for destinations of type CImageFrame when frame number is specified. |
|
105 |
|
106 @pre |
|
107 The destination CImageFrame, must be created before the call to ConvertFrame() is made. |
|
108 |
|
109 aDestFrame must be large enough to contain the decoded frame. |
|
110 CJPEGImageFrameDecoder::RecommendedBufferSize() can be used to obtain the required buffer size in the CImageFrame. |
|
111 |
|
112 This convert call is a standard asynchronous operation. It takes a pointer to the TRequestStatus object |
|
113 of the waiting active object in the main application which will be signalled when the operation is completed. |
|
114 |
|
115 If the operation completes with KErrUnderflow, then there is insufficient |
|
116 information in the source file or descriptor. In this situation, ContinueConvertFrame() should be |
|
117 called repeatedly until the source file or descriptor has accumulated enough information |
|
118 for ContinueConvertFrame() to complete with KErrNone. |
|
119 |
|
120 @param aRequestStatus |
|
121 Pointer to the TRequestStatus object that is signalled on completion. |
|
122 Contains an error code. |
|
123 KErrNone if frame was decoded successfully, |
|
124 otherwise another of the system-wide error codes. |
|
125 @param aDestFrame |
|
126 A CImageFrame that will contain the decoded frame. |
|
127 @param aFrameNumber |
|
128 The number of the frame in a multi-frame image to decode. |
|
129 */ |
|
130 EXPORT_C void CJPEGImageFrameDecoder::ConvertFrame(TRequestStatus* aRequestStatus, CImageFrame& aDestFrame, TInt aFrameNumber) |
|
131 { |
|
132 CJPEGImageFrameDecoderPlugin* plugin; |
|
133 plugin = static_cast<CJPEGImageFrameDecoderPlugin*>(Plugin()); |
|
134 plugin->SetConvertParameters (aDestFrame, aFrameNumber); |
|
135 |
|
136 CustomAsync(aRequestStatus, KOptionConvertFrameUidValue); |
|
137 } |
|
138 |
|
139 /** |
|
140 Continue decoding for destinations of type CImageFrame after new image data was added to |
|
141 the source file or descriptor and a previous call to ConvertFrame() or |
|
142 ContinueConvertFrame() returned KErrUnderflow. |
|
143 |
|
144 @param aRequestStatus |
|
145 Request status. This returns an error code on completion. |
|
146 KErrNone if frame was successfully decoded, |
|
147 KErrUnderflow if the frame was partially decoded, |
|
148 KErrNotReady if the destination is not valid, |
|
149 otherwise another of the system-wide error codes. |
|
150 */ |
|
151 EXPORT_C void CJPEGImageFrameDecoder::ContinueConvertFrame(TRequestStatus* aRequestStatus) |
|
152 { |
|
153 CustomAsync(aRequestStatus, KOptionContinueConvertFrameUidValue); |
|
154 } |
|
155 |
|
156 /** |
|
157 Returns the size (in bytes) of the buffer required to decode the image supplied to the decoder. |
|
158 The size returned will be the required size when using the plugin's default format code. |
|
159 |
|
160 The client should supply the buffer size in the aMaxBufferSize parameter of CImageFrame::NewL() when creating the |
|
161 destination CImageFrame before calling CJPEGImageFrameDecoder::ConvertFrame(). |
|
162 |
|
163 @param aBufferSize |
|
164 On return contains recommended buffer size to be used, in bytes. |
|
165 Size is 0 if the codec cannot decode the image. |
|
166 |
|
167 @return A boolean indicating whether or not the codec supports decoding of that image. |
|
168 */ |
|
169 EXPORT_C TBool CJPEGImageFrameDecoder::RecommendedBufferSize(TInt& aBufferSize) |
|
170 { |
|
171 return RecommendedBufferSize(KNullUid, aBufferSize); |
|
172 } |
|
173 |
|
174 /** |
|
175 Returns the size (in bytes) of the buffer required to decode the image supplied to the decoder using a particular format. |
|
176 |
|
177 The client should supply the buffer size in the aMaxBufferSize parameter of CImageFrame::NewL() when creating the |
|
178 destination CImageFrame before calling CJPEGImageFrameDecoder::ConvertFrame(). |
|
179 |
|
180 @param aFormatCode |
|
181 The UID of a format code that the client intends to use to decode the image. |
|
182 @param aBufferSize |
|
183 On return contains recommended buffer size to be used, in bytes. |
|
184 Size is 0 if the codec cannot decode the image to the specified format. |
|
185 |
|
186 @return A boolean indicating whether or not the codec can decode the image to the requested format. |
|
187 */ |
|
188 EXPORT_C TBool CJPEGImageFrameDecoder::RecommendedBufferSize(TUid aFormatCode, TInt& aBufferSize) |
|
189 { |
|
190 CJPEGImageFrameDecoderPlugin* plugin; |
|
191 plugin = static_cast<CJPEGImageFrameDecoderPlugin*>(Plugin()); |
|
192 plugin->SetFormatCode(aFormatCode); |
|
193 |
|
194 TRAPD(error, CustomSyncL(KOptionRecommendBufferSizeUidValue)); |
|
195 if (error!=KErrNone) |
|
196 { |
|
197 aBufferSize = 0; |
|
198 return EFalse; |
|
199 } |
|
200 else |
|
201 { |
|
202 aBufferSize = plugin->RecommendedBufferSize(); |
|
203 return ETrue; |
|
204 } |
|
205 } |
|
206 |
|
207 |
|
208 // |
|
209 // CJPEGImageFrameEncoder // |
|
210 // |
|
211 |
|
212 /** |
|
213 A factory function that constructs a JPEG CImageFrame encoder as an extension of the ICL EXIF encoder. |
|
214 |
|
215 A leave occurs if there is insufficient memory available. |
|
216 |
|
217 @return A pointer to the new JPEG CImageFrame encoder. |
|
218 */ |
|
219 EXPORT_C CJPEGImageFrameEncoder* CJPEGImageFrameEncoder::NewL() |
|
220 { |
|
221 CJPEGImageFrameEncoder* self; |
|
222 self = new (ELeave) CJPEGImageFrameEncoder; |
|
223 CleanupStack::PushL(self); |
|
224 self->CJPEGExifEncoder::ConstructL(); |
|
225 CleanupStack::Pop(self); |
|
226 return self; |
|
227 } |
|
228 |
|
229 /** |
|
230 Constructor for the CJPEGImageFrameEncoder class. |
|
231 */ |
|
232 EXPORT_C CJPEGImageFrameEncoder::CJPEGImageFrameEncoder() |
|
233 { |
|
234 } |
|
235 |
|
236 /** |
|
237 Destructor for the CJPEGImageFrameEncoder class. |
|
238 */ |
|
239 EXPORT_C CJPEGImageFrameEncoder::~CJPEGImageFrameEncoder() |
|
240 { |
|
241 } |
|
242 |
|
243 /** |
|
244 Basic encode convert call for sources of type CImageFrame. |
|
245 |
|
246 This convert call is a standard asynchronous operation. It takes a pointer to the TRequestStatus object |
|
247 of the waiting active object in the main application which will be signalled when the operation is completed. |
|
248 |
|
249 @param aRequestStatus |
|
250 Pointer to the TRequestStatus object that is signalled on completion. |
|
251 Contains an error code. |
|
252 KErrNone if frame was decoded successfully, |
|
253 otherwise another of the system-wide error codes. |
|
254 @param aSrcFrame |
|
255 A CImageFrame wrapping the image data to encode. |
|
256 */ |
|
257 EXPORT_C void CJPEGImageFrameEncoder::ConvertFrame(TRequestStatus* aRequestStatus, const CImageFrame& aSrcFrame) |
|
258 { |
|
259 |
|
260 CJPEGImageFrameEncoderPlugin* plugin; |
|
261 plugin = static_cast<CJPEGImageFrameEncoderPlugin*>(Plugin()); |
|
262 plugin->SetConvertParameters (aSrcFrame, NULL); |
|
263 |
|
264 CustomAsync(aRequestStatus, KOptionConvertFrameUidValue); |
|
265 } |
|
266 |
|
267 /** |
|
268 Basic encode convert call for sources of type CImageFrame. |
|
269 |
|
270 This convert call is a standard asynchronous operation. It takes a pointer to the TRequestStatus object |
|
271 of the waiting active object in the main application which will be signalled when the operation is completed. |
|
272 |
|
273 Allows the client to provide the frame image data in the same way as standard |
|
274 CImageEncoder::Convert() calls. |
|
275 |
|
276 The aFrameImageData parameter in this call provides additional jpeg image data that can be used |
|
277 by the plugin to provide transcoding to a different format to the one used in the source CImageFrame. |
|
278 How this information is used is plugin implementation specific. |
|
279 |
|
280 @param aRequestStatus |
|
281 Pointer to the TRequestStatus object that is signalled on completion. |
|
282 Contains an error code. |
|
283 KErrNone if frame was decoded successfully, |
|
284 otherwise another of the system-wide error codes. |
|
285 @param aSrcFrame |
|
286 A CImageFrame wrapping the image data to encode. |
|
287 @param aFrameImageData |
|
288 The frame image data. |
|
289 */ |
|
290 EXPORT_C void CJPEGImageFrameEncoder::ConvertFrame(TRequestStatus* aRequestStatus, const CImageFrame& aSrcFrame, const CFrameImageData* aFrameImageData) |
|
291 { |
|
292 |
|
293 CJPEGImageFrameEncoderPlugin* plugin; |
|
294 plugin = static_cast<CJPEGImageFrameEncoderPlugin*>(Plugin()); |
|
295 plugin->SetConvertParameters (aSrcFrame, aFrameImageData); |
|
296 |
|
297 CustomAsync(aRequestStatus, KOptionConvertFrameUidValue); |
|
298 } |
|
299 |
|
300 |
|
301 // |
|
302 // CJPEGImageFrameDecoderPlugin // |
|
303 // |
|
304 |
|
305 /** |
|
306 Constructor for the CJPEGImageFrameDecoderPlugin class. |
|
307 */ |
|
308 EXPORT_C CJPEGImageFrameDecoderPlugin::CJPEGImageFrameDecoderPlugin() |
|
309 { |
|
310 iFormatCode = KNullUid; |
|
311 } |
|
312 |
|
313 /** |
|
314 Destructor for the CJPEGImageFrameDecoderPlugin class. |
|
315 */ |
|
316 EXPORT_C CJPEGImageFrameDecoderPlugin::~CJPEGImageFrameDecoderPlugin() |
|
317 { |
|
318 } |
|
319 |
|
320 /** |
|
321 Returns the destination CImageFrame stored in this plugin extension. |
|
322 |
|
323 @return A reference to the destination CImageFrame. |
|
324 */ |
|
325 EXPORT_C CImageFrame& CJPEGImageFrameDecoderPlugin::DstImageFrame() |
|
326 { |
|
327 return *iDstImageFrame; |
|
328 } |
|
329 |
|
330 /** |
|
331 Returns the frame number (in a multi-frame image to be decoded) stored in this plugin extension. |
|
332 |
|
333 @return A frame number. |
|
334 */ |
|
335 EXPORT_C TInt CJPEGImageFrameDecoderPlugin::FrameNumber() const |
|
336 { |
|
337 return iFrameNumber; |
|
338 } |
|
339 |
|
340 /** |
|
341 Returns a format code stored in this plugin extension. |
|
342 This format code can be used to calculate the recommended buffer size needed to decode the image |
|
343 and it may not be the format code finally used for decoding. |
|
344 |
|
345 @see imageframeformats.hrh |
|
346 |
|
347 @return A format code UID. |
|
348 */ |
|
349 EXPORT_C TUid CJPEGImageFrameDecoderPlugin::FormatCode() const |
|
350 { |
|
351 return iFormatCode; |
|
352 } |
|
353 |
|
354 /** |
|
355 Stores in this plugin extension the recommended buffer size to use when decoding the image contained |
|
356 in a file or descriptor. |
|
357 |
|
358 @param aBufferSize |
|
359 The recommended buffer size to use, in bytes. |
|
360 */ |
|
361 EXPORT_C void CJPEGImageFrameDecoderPlugin::SetRecommendedBufferSize(TInt aBufferSize) |
|
362 { |
|
363 iRecommendedBufferSize = aBufferSize; |
|
364 } |
|
365 |
|
366 /** |
|
367 @internalTechnology |
|
368 |
|
369 Sets the destination CImageFrame and the Frame Number in the CImageFrame decoder plugin extension |
|
370 */ |
|
371 void CJPEGImageFrameDecoderPlugin::SetConvertParameters(CImageFrame& aDestFrame, TInt aFrameNumber) |
|
372 { |
|
373 iDstImageFrame = &aDestFrame; |
|
374 iFrameNumber = aFrameNumber; |
|
375 } |
|
376 |
|
377 /** |
|
378 @internalTechnology |
|
379 |
|
380 Sets the format code in the CImageFrame decoder plugin extension |
|
381 */ |
|
382 void CJPEGImageFrameDecoderPlugin::SetFormatCode(TUid aFormatCode) |
|
383 { |
|
384 iFormatCode = aFormatCode; |
|
385 } |
|
386 |
|
387 /** |
|
388 @internalTechnology |
|
389 |
|
390 Returns the recommended buffer size stored in the CImageFrame decoder plugin extension. |
|
391 */ |
|
392 TInt CJPEGImageFrameDecoderPlugin::RecommendedBufferSize() |
|
393 { |
|
394 return iRecommendedBufferSize; |
|
395 } |
|
396 |
|
397 /** |
|
398 @internalTechnology |
|
399 |
|
400 Intended for future proofing - will panic if called. |
|
401 |
|
402 @panic EReservedCall |
|
403 */ |
|
404 EXPORT_C void CJPEGImageFrameDecoderPlugin::Reserved1() |
|
405 { |
|
406 Panic(EReservedCall); |
|
407 } |
|
408 |
|
409 /** |
|
410 @internalTechnology |
|
411 |
|
412 Intended for future proofing - will panic if called. |
|
413 |
|
414 @panic EReservedCall |
|
415 */ |
|
416 EXPORT_C void CJPEGImageFrameDecoderPlugin::Reserved2() |
|
417 { |
|
418 Panic(EReservedCall); |
|
419 } |
|
420 |
|
421 /** |
|
422 @internalTechnology |
|
423 |
|
424 Intended for future proofing - will panic if called. |
|
425 |
|
426 @panic EReservedCall |
|
427 */ |
|
428 EXPORT_C void CJPEGImageFrameDecoderPlugin::Reserved3() |
|
429 { |
|
430 Panic(EReservedCall); |
|
431 } |
|
432 |
|
433 |
|
434 // |
|
435 // CJPEGImageFrameEncoderPlugin // |
|
436 // |
|
437 |
|
438 /** |
|
439 Constructor for the CJPEGImageFrameEncoderPlugin class. |
|
440 */ |
|
441 EXPORT_C CJPEGImageFrameEncoderPlugin::CJPEGImageFrameEncoderPlugin() |
|
442 { |
|
443 } |
|
444 |
|
445 /** |
|
446 Destructor for the CJPEGImageFrameEncoderPlugin class. |
|
447 */ |
|
448 EXPORT_C CJPEGImageFrameEncoderPlugin::~CJPEGImageFrameEncoderPlugin() |
|
449 { |
|
450 } |
|
451 |
|
452 /** |
|
453 Returns the source CImageFrame to encode stored in this plugin extension. |
|
454 |
|
455 @return A reference to the source CImageFrame. |
|
456 */ |
|
457 EXPORT_C const CImageFrame& CJPEGImageFrameEncoderPlugin::SrcImageFrame() const |
|
458 { |
|
459 return *iSrcImageFrame; |
|
460 } |
|
461 |
|
462 /** |
|
463 Returns the frame image data stored in this plugin extension. |
|
464 |
|
465 @return A reference to the frame image data. |
|
466 */ |
|
467 EXPORT_C const CFrameImageData& CJPEGImageFrameEncoderPlugin::FrameImageData() const |
|
468 { |
|
469 return *iFrameImageData; |
|
470 } |
|
471 |
|
472 /** |
|
473 @internalTechnology |
|
474 |
|
475 Sets the source CImageFrame and FrameImageData in the encoder plugin extension |
|
476 */ |
|
477 void CJPEGImageFrameEncoderPlugin::SetConvertParameters(const CImageFrame& aSrcFrame, const CFrameImageData* aFrameImageData) |
|
478 { |
|
479 iSrcImageFrame = &aSrcFrame; |
|
480 iFrameImageData = aFrameImageData; |
|
481 } |
|
482 |
|
483 /** |
|
484 @internalTechnology |
|
485 |
|
486 Intended for future proofing - will panic if called. |
|
487 |
|
488 @panic EReservedCall |
|
489 */ |
|
490 EXPORT_C void CJPEGImageFrameEncoderPlugin::Reserved1() |
|
491 { |
|
492 Panic(EReservedCall); |
|
493 } |
|
494 |
|
495 /** |
|
496 @internalTechnology |
|
497 |
|
498 Intended for future proofing - will panic if called. |
|
499 |
|
500 @panic EReservedCall |
|
501 */ |
|
502 EXPORT_C void CJPEGImageFrameEncoderPlugin::Reserved2() |
|
503 { |
|
504 Panic(EReservedCall); |
|
505 } |
|
506 |
|
507 /** |
|
508 @internalTechnology |
|
509 |
|
510 Intended for future proofing - will panic if called. |
|
511 |
|
512 @panic EReservedCall |
|
513 */ |
|
514 EXPORT_C void CJPEGImageFrameEncoderPlugin::Reserved3() |
|
515 { |
|
516 Panic(EReservedCall); |
|
517 } |