1 // Copyright (c) 2007-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 the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #ifndef IMAGECONVERSIONEXTENSION_H
17 #define IMAGECONVERSIONEXTENSION_H
20 class MImageConvExtension;
21 class MImageConvOperation;
22 class MImageConvScaler;
23 class MImageConvStreamedDecode;
24 class MImageConvStreamedEncode;
27 class CFrameImageData;
36 Image Conversion Library extensions. When applied together there is an implicit order for operations:
39 3. Rotate / mirror over axis.
43 Operation extension for Image Conversion Library. Allows rotation and mirror over axis.
45 class TImageConvOperation
47 friend class CImageDecoder;
48 friend class CImageEncoder;
54 Operations or transforms on an image.
58 /** Rotate source 90 degrees clockwise.
60 ERotation90DegreesClockwise = 0x01,
61 /** Rotate source 180 degrees clockwise.
63 ERotation180DegreesClockwise = 0x02,
64 /** Rotate source 270 degrees clockwise.
66 ERotation270DegreesClockwise = 0x04,
67 /** Mirror source about the horizontal axis.
69 EMirrorHorizontalAxis = 0x08,
70 /** Mirror source about the vertical axis.
72 EMirrorVerticalAxis = 0x10
76 Get the codec plugin's capabilities.
78 @return Bitmask combination of TOperation. Bit is set if decoder plugin supports the operation.
80 IMPORT_C TUint Capabilities() const;
83 Set up an operation be applied to the source. May be called more than once
84 to set up a stack of operations, but it is not possible to add more than one
85 operation in a single call.
86 The operations are applied to the image in the same order as they are added.
88 @param aOperation The operation to add to the current stack of operations.
90 @leave if more than one TOperation enum is passed for each individual call
92 IMPORT_C void AddOperationL(TOperation aOperation);
95 Remove all operations previously set.
97 IMPORT_C void ClearOperationStack();
101 IMPORT_C TImageConvOperation();
102 void SetExtension(MImageConvExtension* aExtension);
105 MImageConvOperation* iExtension;
106 TInt iReserved; // future proof
111 Represents scaling capabilities of the code plugin.
119 IMPORT_C TScalerCaps();
124 @param aMaxUpscaleLimit Maximum upscaling possible.
125 @param aMaxDownscaleLimit Maximum downscaling possible.
126 @param aPreserveAspectRatioIsNeeded ETrue if only support preservation of aspect ratio.
128 IMPORT_C TScalerCaps(TInt aMaxUpscaleLimit,TInt aMaxDownscaleLimit,TBool aPreserveAspectRatioIsNeeded);
131 Maximum upscaling possible.
132 @return value >= 1 : 1 means cannot upscale, 2 means twice original size
134 IMPORT_C TInt MaxUpscaleLimit() const;
137 Maximum downscaling possible.
138 @return value <= -1 : -1 means cannot downscale, -2 means half original size
140 IMPORT_C TInt MaxDownscaleLimit() const;
143 Type of scaling which is supported.
145 @return ETrue if can only do 1/2, 1/4, 1/8 etc downscale (limit depends on iMaxDownscaleLimit)
146 2, 4, 8 etc upscale (limit depends on iMaxUpscaleLimit)
147 EFalse if can do arbitrary scaling between iMaxDownscaleLimit and iMaxUpscaleLimit
149 IMPORT_C TBool PowerOfTwoScalingOnly() const;
152 Returns ETrue if the codec must preserve aspect ratio during scaling.
154 @return ETrue if scaling is only possible if preservation of aspect ratio is requested.
155 EFalse if scaling without preserving aspect ratio is possible.
157 IMPORT_C TBool MustPreserveAspectRatio() const;
160 Compatibility - internal use only
163 IMPORT_C TUint Size() const;
166 Compatibility - internal use only
169 IMPORT_C TUint Version() const;
172 TInt iMaxUpscaleLimit; // >= 1 : 2 means twice original size
173 TBool iMustPreserveAspectRatio; // If ETrue then can only do scaling whilst preserving aspect ratio
174 TInt iMaxDownscaleLimit; // <= -1 : -2 means 1/2 original size
175 TBool iPowerOfTwoScalingOnly;
176 TUint iSizeVersion; // bits 31 to 8 size, 7 to 0 contain version
177 TInt iReserved; // future proof
182 Scaling extension for Image Conversion Library. Supports both arbitrary or 'power of two' 1/2, 1/4, 1/8 scaling
184 class TImageConvScaler
186 friend class CImageDecoder;
191 Quality used during scaling.
195 EMinimumQuality, // = 0
201 Get the codec plugin's capabilities.
203 @param aCaps Returns scaling capabilities of the codec plugin.
205 IMPORT_C void GetCapabilities(TScalerCaps& aCaps) const;
208 Request scaling to the desired size using the quality specified and specifying if the aspect ratio is to
210 Ensure that CImageDecoder::GetDestinationSize is used to obtain the size of destination bitmap passed
211 to CImageDecoder::Convert if scaling is set up by calling this method.
213 @param aDesiredSize Proposed size of the scaled image. Note that this may not necessarily be the size
214 returned by a subsequent call to CImageDecoder::GetDestinationSize and is dependant upon the operations
215 (such as scaling, cropping and rotation) requested and also the capabilities of the plugin (which can be
216 queried using TImageConvScaler::GetCapabilities).
218 Example: If a plugin is only capable of power of two scaling, with an original image size of 600x400,
219 then calling this SetScalingL function with a desired size of 500x300 will result in a subsequent call to
220 CImageDecoder::GetDestinationSize returning a size of 300x200 (that is, a scaling coefficient of -2).
222 @param aQuality Desired quality of the image. Allows codec to lower quality targets to
225 @param aLockAspectRatio Set to ETrue if the aspect ratio of the original image is to be preserved.
227 @leave KErrNotSupported if an invalid size is passed.
228 @leave KErrNotSupported if aLockAspectRatio is EFalse and codec only supports preservation of aspect ratio.
230 @see CImageDecoder::Convert
231 @see CImageDecoder::GetDestinationSize
232 @see TImageConvScaler::GetCapabilities
234 IMPORT_C void SetScalingL(const TSize& aDesiredSize, TImageConvScaler::TScalerQuality aQuality, TBool aLockAspectRatio);
237 Define the scaling to be applied to the image according to the given coefficient at the requested quality.
238 Ensure that CImageDecoder::GetDestinationSize is used to obtain the size of destination bitmap to be passed
239 to CImageDecoder::Convert.
241 @param aScalingCoeff Scale to apply to the source. 2 means twice the original size, -2 half the size.
242 Do not confuse this with ReductionFactor where 2 indicates 1/2 size.
244 @param aScalingQuality Desired quality of the image. Allows codec to lower quality targets to
247 @leave KErrNotSupported if codec cannot perform the requested scale.
249 @see CImageDecoder::Convert
251 IMPORT_C void SetScalingL(TInt aScalingCoeff, TImageConvScaler::TScalerQuality aScalingQuality);
254 IMPORT_C TImageConvScaler();
255 void SetExtension(MImageConvExtension* aExtension);
258 MImageConvScaler* iExtension;
259 TInt iReserved; // future proof
263 'Block' streaming extension capabilities.
265 class TDecodeStreamCaps
268 /** Navigation possibilities within stream.
272 /** Blocks are returned from first to last */
273 ENavigationSequentialForward = 0x01,
275 /** Blocks are returned in a random order but moving only from first to last e.g. 1, 5, 18...*/
276 ENavigationRandomForward = 0x02,
278 /** Blocks are returned in a random order but moving only from last to first e.g. 18, 5, 1...*/
279 ENavigationRandomBackwards = 0x04,
281 /** Blocks are returned randomly e.g. 18, 5, 20, ...*/
282 ENavigationRandom = 0x08,
284 /** Blocks are returned from last to first */
285 ENavigationSequentialBackwards = 0x10
291 IMPORT_C TDecodeStreamCaps();
296 @param aMaxBlocksPerRequest Maximum number of blocks that can be returned from the stream to client in a
298 @param aMinBlockSizeInPixels Minimum size in pixels of a block returned from the stream to the client in
300 @param aOptimalBlocksPerRequest Optimum number of blocks returned from the stream to the client in
301 a single request to get maximum performance benefit.
302 @param aStreamSizeInBlocks Number of blocks of size MinBlockSizeInPixels() in the stream.
303 @param aNavigation Navigation capabilities.
305 IMPORT_C TDecodeStreamCaps(TInt aMaxBlocksPerRequest, const TSize& aMinBlockSizeInPixels,
306 TInt aOptimalBlocksPerRequest, TInt aStreamSizeInBlocks,
307 TDecodeStreamCaps::TNavigation aNavigation);
310 The maximum number of blocks that can be returned from the stream to client in a
313 @return Maximum number of blocks that can be returned from the stream to client in a
316 IMPORT_C TInt MaxBlocksPerRequest() const;
319 The Minimum size in pixels of a block returned from the stream to the client in
322 @return Minimum size in pixels of a block returned from the stream to the client in
323 a single request. Sequence numbers and StreamSizeInBlocks() refer to this size of block.
325 IMPORT_C const TSize& MinBlockSizeInPixels() const;
328 Optimum number of blocks returned from the stream to the client in
329 a single request to get maximum performance benefit.
331 @return Optimum number of blocks returned from the stream to the client in
332 a single request to get maximum performance benefit.
333 This can be used to determine the optimum value of the number of blocks of min block size per request.
335 IMPORT_C TInt OptimalBlocksPerRequest() const;
338 Number of blocks of size MinBlockSizeInPixels() in the stream.
340 @return Number of blocks of size MinBlockSizeInPixels() in the stream.
342 IMPORT_C TInt StreamSizeInBlocks() const;
345 Navigation capabilities.
347 @return Navigation capabilities.
349 Full random access to the stream if Navigation() returns
350 ENavigationSequentialForward | ENavigationRandomForward | ENavigationRandomBackwards
352 IMPORT_C TDecodeStreamCaps::TNavigation Navigation() const;
355 Compatibility - internal use only
358 IMPORT_C TUint Size() const;
361 Compatibility - internal use only
364 IMPORT_C TUint Version() const;
367 TInt iMaxBlocksPerRequest;
368 TSize iMinBlockSizeInPixels;
369 TInt iOptimalBlocksPerRequest;
370 TInt iStreamSizeInBlocks;
371 TNavigation iNavigation;
372 TUint iSizeVersion; // bits 31 to 8 size, 7 to 0 contain version
373 TInt iReserved; // future proof
377 'Block' streaming extension for Image Conversion Library decoder.
379 class TImageConvStreamedDecode
381 friend class CImageDecoder;
385 Returns a list of supported formats and the optimal format to be used. @see imageframeconst.h
386 for a list of format uids.
387 @param aFormats Returns an array of format uids
388 @param aOptimalFormat The 'best' uid to use.
390 IMPORT_C void GetSupportedFormatsL(RArray<TUid>& aFormats, TUid& aOptimalFormat) const;
393 Returns the capabilities of the codec plugin for a specific format and for a specific frame.
394 @param aFormat The format.
395 @param aFrameNumber frame to stream
396 @param aCaps The capabilities for the format given.
398 IMPORT_C void GetCapabilities(TUid aFormat, TInt aFrameNumber, TDecodeStreamCaps& aCaps) const;
401 Get the size of the memory buffer to hold the returned data.
403 @param aFormat the required format
404 @param aBlockSizeInPixels returns the size in pixels of the block returned from the stream when aNumBlocks of minimum block size are requested.
405 @param aNumBlocks the number of blocks of size TDecodeStreamCaps::MinBlockSizeInPixels() to be returned by one request
407 @return The memory buffer size in bytes to hold the requested blocks. System wide error if for example
408 the format is not supported.
410 IMPORT_C TInt GetBufferSize(TUid aFormat, TSize& aBlockSizeInPixels, TInt aNumBlocks) const;
414 Initialise the stream.
416 @param aFormat the format to use
417 @param aFrameNumber frame to stream
418 @param aNavigation indication to stream of the way that the stream will be navigated. Allows
419 codec to optimise it's behaviour.
420 @leave System wide error if for example the format is not supported.
422 @note must call InitFrameL before GetBlocks or GetNextBlocks. Failure to do so completes request with
425 IMPORT_C void InitFrameL(TUid aFormat, TInt aFrameNumber, TDecodeStreamCaps::TNavigation aNavigation);
428 Start asynchronous call to return random blocks from the stream
430 @param aStatus request status
431 @param aFrame An image frame wrapper a memory buffer to hold the returned block(s) of
432 pixel data. This can be 'uninitialised' or given specific format which must match that
433 specified in the InitFrameL call.
434 @param aSeqPosition block number starting at top left 0 ... TDecodeStreamCaps::StreamSizeInBlocks()
435 @param aNumBlocksToGet number of blocks requested
436 @param aNumBlocksRead number of blocks which will be returned when the request completes
438 @note use CImageDecoder::Cancel() to cancel this request.
440 IMPORT_C void GetBlocks(TRequestStatus& aStatus, CImageFrame& aFrame, TInt aSeqPosition, TInt aNumBlocksToGet, TInt& aNumBlocksRead);
443 Start asynchronous call to return blocks sequentially from the stream. Blocks are returned
444 from the first block until the last in the stream.
446 @param aStatus request status
447 @param aFrame An image frame wrapper a memory buffer to hold the returned block(s) of
448 pixel data. This can be 'uninitialised' or given specific format which must match that
449 specified in the InitFrameL call.
450 @param aNumBlocksToGet number of blocks requested
451 @param aNumBlocksRead number of blocks which will be returned when the request completes
453 @note use CImageDecoder::Cancel() to cancel this request.
455 IMPORT_C void GetNextBlocks(TRequestStatus& aStatus, CImageFrame& aFrame, TInt aNumBlocksToGet, TInt& aNumBlocksRead, TBool& aHaveMoreBlocks);
458 IMPORT_C TImageConvStreamedDecode();
459 void SetExtension(MImageConvExtension* aExtension);
462 MImageConvStreamedDecode* iExtension;
463 TInt iReserved; // future proof
467 'Block' streaming extension for Image Conversion Library encoder.
470 'Block' streaming extension for Image Conversion Library encoder.
472 class TEncodeStreamCaps
475 /** Navigation possibilities within the stream.
479 /** Blocks can be returned from first to last */
480 ENavigationSequentialForward = 0x01,
482 /** Blocks can be returned in a random order but moving only from first to last e.g. 1, 5, 18...*/
483 ENavigationRandomForward = 0x02,
485 /** Blocks can be returned in a random order but moving only from last to first e.g. 1, 5, 18...*/
486 ENavigationRandomBackwards = 0x04
492 IMPORT_C TEncodeStreamCaps();
497 @param aMaxBlocksPerRequest Maximum number of blocks that can be sent from the stream to client in a
499 @param aMinBlockSizeInPixels Minimum size in pixels of a block sent to the stream from the client in
501 @param aOptimalBlocksPerRequest Optimum number of blocks sent to the stream from the client in
502 a single request to get maximum performance benefit.
503 @param aNavigation Navigation capabilities.
505 IMPORT_C TEncodeStreamCaps(TInt aMaxBlocksPerRequest, const TSize& aMinBlockSizeInPixels,
506 TInt aOptimalBlocksPerRequest,
507 TEncodeStreamCaps::TNavigation aNavigation);
509 Maximum number of blocks that can be sent from the stream to client in a
512 @return Maximum number of blocks that can be sent from the stream to client in a
515 IMPORT_C TInt MaxBlocksPerRequest() const;
518 Minimum size in pixels of a block sent to the stream from the client in
521 @return Minimum size in pixels of a block sent to the stream from the client in
524 IMPORT_C const TSize& MinBlockSizeInPixels() const;
527 Optimum number of blocks sent to the stream from the client in
528 a single request to get maximum performance benefit.
530 @return Optimum number of blocks sent to the stream from the client in
531 a single request to get maximum performance benefit.
533 IMPORT_C TInt OptimalBlocksPerRequest() const;
537 Navigation capabilities.
539 @return navigation capabilities.
541 Full random access to the stream if Navigation() returns
542 ENavigationSequentialForward | ENavigationRandomForward |ENavigationRandomBackwards
544 IMPORT_C TEncodeStreamCaps::TNavigation Navigation() const;
547 Compatibility - internal use only
550 IMPORT_C TUint Size() const;
553 Compatibility - internal use only
556 IMPORT_C TUint Version() const;
559 TInt iMaxBlocksPerRequest;
560 TSize iMinBlockSizeInPixels;
561 TInt iOptimalBlocksPerRequest;
562 TNavigation iNavigation;
563 TUint iSizeVersion; // bits 31 to 8 size, 7 to 0 contain version
564 TInt iReserved; // future proof
567 class TImageConvStreamedEncode
569 friend class CImageEncoder;
573 Returns a list of supported formats and the optimal format to be used. @see imageframeconst.h
574 for a list of format uids.
575 @param aFormats Returns an array of format uids
576 @param aOptimalFormat The 'best' uid to use.
578 IMPORT_C void GetSupportedFormatsL(RArray<TUid>& aFormats, TUid& aOptimalFormat) const;
581 Returns the capabilities of the codec plugin for a specific format.
582 @param aFormat The format.
583 @param aCaps The capabilities for the format given.
585 IMPORT_C void GetCapabilities(TUid aFormat, TEncodeStreamCaps& aCaps) const;
588 Initialise the stream.
590 @param aFormat the format to use
591 @param aFrameNumber frame to stream
592 @param aFrameSizeInPixels Size of this frame in pixels
593 @param aBlockSizeInPixels Size of block to be added / appended.
594 @param aNavigation indication to stream of the way that the stream will be navigated. Allows
595 codec to optimise it's behaviour.
596 @param aFrameImageData The frame image data (optional pass NULL if not required).
597 There are format-specific image data variants that are used by encoders to obtain image specific
598 data. This behaviour is invoked by specifying aFrameImageData. Otherwise, encoder specific defaults
599 are invoked. @see TJpegImageData
601 @leave System wide error if for example the format is not supported.
603 @note must call InitFrameL before AppendBlocks or AddBlocks. Failure to do so completes request with
606 @note can either specify format through aFormat or aImageFrameData. Conflicts cause a leave with KErrArgument.
608 IMPORT_C void InitFrameL(TUid aFormat, TInt aFrameNumber, const TSize& aFrameSizeInPixels, const TSize& aBlockSizeInPixels, TEncodeStreamCaps::TNavigation aNavigation, const CFrameImageData* aFrameImageData);
611 Append blocks to the stream.
612 @param aStatus request status
613 @param aBlocks wraps a memory buffer containing the pixel data to be added to the stream
614 @param aNumBlocksToAdd number of blocks of size TEncodeStreamCaps::MinBlockSizeInPixels to add to the stream
616 IMPORT_C void AppendBlocks(TRequestStatus& aStatus, const CImageFrame& aBlocks, TInt aNumBlocksToAdd);
619 Add blocks to the stream at a random position.
620 @param aStatus request status
621 @param aBlocks wraps a memory buffer containing the pixel data to be added to the stream
622 @param aSeqPosition position of block in stream starting at 0
624 IMPORT_C void AddBlocks(TRequestStatus& aStatus, const CImageFrame& aBlocks, const TInt& aSeqPosition);
627 Signal completion of writing the stream
628 @param aStatus request status
630 IMPORT_C void Complete(TRequestStatus& aStatus);
634 IMPORT_C TImageConvStreamedEncode();
635 void SetExtension(MImageConvExtension* aExtension);
637 MImageConvStreamedEncode* iExtension;
638 TInt iReserved; // future proof
641 #endif // IMAGECONVERSIONEXTENSION_H