epoc32/include/icl/imageconversionextensionintf.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
parent 2 2fe1408b6811
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
     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 "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 //
    15 
    16 #ifndef IMAGECONVERSIONEXTENSIONINTF_H
    17 #define IMAGECONVERSIONEXTENSIONINTF_H
    18 
    19 #include <icl/imageconversionextension.h>
    20 
    21 class CImageFrame;
    22 class CFrameImageData;
    23 
    24 /**
    25 @file
    26 @publishedAll
    27 @released
    28 */
    29 
    30 /**
    31  Image Conversion Library extensions. When applied together there is an implicit order for operations:
    32  	1. Crop or clip.
    33  	2. Scale
    34  	3. Rotate / flip.
    35 
    36 In order to support an extension the codec plugin must implement the interface and return this interface 
    37 through a call to CImageDecoderPlugin::GetExtensionL.
    38 */
    39  
    40 /**
    41 Extension base class
    42 */
    43 class MImageConvExtension
    44 	{
    45 public:
    46 	/** 
    47 	Uid of extension interface.
    48 	*/
    49 	virtual TUid Uid() const = 0; 
    50 
    51 	/**
    52 	Increment the reference count.
    53 	*/
    54 	virtual void IncrementRef() = 0;
    55 	
    56 	/**
    57 	Called when the client has finished with this interface allowing the codec to clean up.
    58 	*/
    59 	virtual void Release() = 0; 
    60 	};
    61 
    62 /**
    63 Operation extension for Image Conversion Library. Allows rotation and mirror/flip. 
    64 */
    65 class MImageConvOperation : public MImageConvExtension
    66 	{
    67 public:	
    68 	/**
    69 	 Capabilities of the code plugin.
    70 	 
    71 	 @return Bitmask combination of TOperation. Bit is set if decoder plugin supports the operation.
    72 	 */
    73 	virtual TUint Capabilities() const = 0;
    74 	
    75 	/**
    76 	 Set up an operation be applied to the source. May be called more than once 
    77 	 to set up a stack of operations, but it is not possible to add more than one
    78 	 operation in a single call.
    79 	 
    80 	 @param aOperation An operation to be added to the current operation stack.
    81 	 
    82 	 @leave if more than one TOperation enum is passed for each individual call
    83 	 */
    84 	virtual void AddOperationL(TImageConvOperation::TOperation aOperation) = 0;
    85 	
    86 	/**
    87 	 Remove all operations previously set. 
    88 	*/
    89 	virtual void ClearOperationStack() = 0;
    90 	};
    91 
    92 /**
    93 Scaling extension for Image Conversion Library
    94 */
    95 class MImageConvScaler : public MImageConvExtension
    96 	{
    97 public:
    98 	/**
    99 	 Gets the scaling capabilities.
   100 	 
   101 	 @param aCaps Returns scaling capabilities of the codec plugin.
   102 	 */
   103 	virtual void GetCapabilities(TScalerCaps& aCaps) const = 0;
   104 
   105     /** 
   106      Request scaling to the desired size using the quality specified and specifying if the aspect ratio is to
   107      be preserved.
   108 	 @param aDesiredSize  Proposed size of the scaled image.
   109 	 @param aQuality Desired quality of the image. Allows codec to lower quality targets to
   110      improve performance.
   111 	 @param aLockAspectRatio Set to ETrue if the aspect ratio of the original image is to be preserved.
   112 	 @leave KErrNotSupported if an invalid size is passed.
   113 	 @leave KErrNotSupported if aLockAspectRatio is EFalse and codec only supports preservation of aspect ratio.
   114 	 */ 
   115 	virtual void SetScalingL(const TSize& aDesiredSize, TImageConvScaler::TScalerQuality aQuality, TBool aLockAspectRatio) = 0;
   116 
   117 	/**
   118 	 Define the scaling to be applied to the image according to the given coefficient at the requested quality.
   119 	 
   120 	 @param aScalingCoeff Scale to apply to the source. 2 means twice the original size, -2 half the size. 
   121 	                      Do not confuse this with ReductionFactor where 2 indicates 1/2 size.
   122      @param aScalingQuality Desired quality of the image. Allows codec to lower quality targets to
   123      improve performance.
   124 	 @leave KErrNotSupported if codec cannot perform the requested scale.
   125 	 */
   126 	virtual void SetScalingL(TInt aScalingCoeff, TImageConvScaler::TScalerQuality aScalingQuality) = 0;
   127 	};
   128 
   129 /**
   130 Block Streaming extension for decoder plugins.
   131 */
   132 class MImageConvStreamedDecode : public MImageConvExtension
   133 	{	
   134 public:
   135     /**
   136      Returns a list of supported formats and the optimal format to be used. @see imageframeconst.h
   137      for a list of format uids.
   138      @param aFormats Returns an array of format uids 
   139      @param aOptimalFormat The 'best' uid to use. 
   140      */
   141 	virtual void GetSupportedFormatsL(RArray<TUid>& aFormats, TUid& aOptimalFormat) const = 0;
   142 
   143 	/**
   144 	 Returns the capabilities of the codec plugin for a specific format.
   145 	 @param aFormat The format.
   146 	 @param aFrameNumber frame to stream
   147 	 @param aCaps The capabilities for the format given.
   148 	 */     
   149 	virtual void GetCapabilities(TUid aFormat, TInt aFrameNumber, TDecodeStreamCaps& aCaps) const = 0;
   150 	
   151 	/**
   152 	 Get the size of the memory buffer to hold the returned data.
   153 	 
   154 	 @param aFormat the required format
   155 	 @param aBlockSizeInPixels size of a single block to be returned
   156 	 @param aNumBlocks the number of blocks of size TDecodeStreamCaps::MinBlockSizeInPixels() to be returned by one request
   157 	 @return The memory buffer size in bytes to hold the requested blocks.
   158 	 */
   159 	virtual TInt GetBufferSize(TUid aFormat, TSize& aBlockSizeInPixels, TInt aNumBlocks) const = 0;
   160 
   161 	/**
   162 	 Initialise the stream.
   163 	 @param aFormat the format to use
   164 	 @param aFrameNumber frame to stream
   165 	 @param aNavigation indication to stream of the way that the stream will be navigated. Allows 
   166 	 codec to optimise it's behaviour.
   167 	 
   168 	 @note TO DO Do we need to specify where the source is held e.g. in memory, on flash card etc?
   169 	 
   170 	 @note must call InitFrameL before GetBlocks or GetNextBlocks. Failure to do so completes request with
   171 	 KErrNotReady
   172 	 */
   173 	virtual void InitFrameL(TUid aFormat, TInt aFrameNumber, TDecodeStreamCaps::TNavigation aNavigation) = 0;
   174 
   175 	/**
   176 	 Start asynchronous call to return random blocks from the stream
   177 	 
   178 	 @param aStatus request status
   179 	 @param aFrame An image frame wrapper a memory buffer to hold the returned block(s) of 
   180 	 pixel data. This can be 'uninitialised' or given specific format which must match that
   181 	 specified in the InitFrameL call.
   182 	 @param aSeqPosition block number starting at 0 ...
   183 	 @param aNumBlocksToGet number of blocks requested
   184 	 @param aNumBlocksRead number of blocks which will be returned when the request completes
   185 	 
   186      @note use CImageDecoder::Cancel() to cancel this request.
   187 	 */
   188 	virtual void GetBlocks(TRequestStatus* aStatus, CImageFrame* aFrame, TInt aSeqPosition, TInt aNumBlocksToGet, TInt* aNumBlocksRead) = 0;
   189 
   190 	/**
   191 	 Start asynchronous call to return blocks sequentially from the stream. Blocks are returned 
   192 	 from the first block until the last in the stream.
   193 	 
   194 	 @param aStatus request status
   195 	 @param aFrame An image frame wrapper a memory buffer to hold the returned block(s) of 
   196 	 pixel data. This can be 'uninitialised' or given specific format which must match that
   197 	 specified in the InitFrameL call.
   198 	 @param aNumBlocksToGet number of blocks requested
   199 	 @param aNumBlocksRead number of blocks which will be returned when the request completes
   200 	 
   201      @note use CImageDecoder::Cancel() to cancel this request.
   202 	 */
   203 	virtual void GetNextBlocks(TRequestStatus* aStatus, CImageFrame* aFrame, TInt aNumBlocksToGet, TInt* aNumBlocksRead, TBool* aHaveMoreBlocks) = 0;
   204 	};
   205 
   206 /**
   207 Block Streaming extension for encoder plugins.
   208 */
   209 class MImageConvStreamedEncode : public MImageConvExtension
   210 	{
   211 public:
   212     /**
   213      Returns a list of supported formats and the optimal format to be used. @see imageframeconst.h
   214      for a list of format uids.
   215      @param aFormats Returns an array of format uids 
   216      @param aOptimalFormat The 'best' uid to use. 
   217      */
   218 	virtual void GetSupportedFormatsL(RArray<TUid>& aFormats, TUid& aOptimalFormat) const = 0;
   219 
   220 	/**
   221 	 Returns the capabilities of the codec plugin for a specific format.
   222 	 @param aFormat The format.
   223 	 @param aCaps The capabilities for the format given.
   224 	 */     
   225 	virtual void GetCapabilities(TUid aFormat, TEncodeStreamCaps& aCaps) const = 0;
   226 
   227 	/**
   228 	 Initialise the stream.
   229 	 @param aFormat the format to use
   230 	 @param aFrameNumber frame to stream
   231 	 @param aFrameSizeInPixels Size of this frame in pixels
   232 	 @param aBlockSizeInPixels Size of block to be added / appended. ??? do we want to support multiple blocks being added
   233 	 in which case InitFrameL needs an extra parameter
   234 	 @param aNavigation indication to stream of the way that the stream will be navigated. Allows 
   235 	 codec to optimise it's behaviour.
   236 	 @param aFrameImageData The frame image data. Optional.
   237 	 There exists format-specific image data variants that are used by 
   238 	 encoders to obtain image specific data. This behaviour is invoked by specifying 
   239 	 aFrameImageData. Otherwise, if set to NULL, encoder specific defaults are invoked. @see TJpegImageData
   240 	 
   241 	 @note TO DO Do we need to specify where the destination is held e.g. in memory, on flash card etc?
   242 	 
   243 	 @note must call InitFrameL before AppendBlocks or AddBlocks. Failure to do so completes request with
   244 	 KErrNotReady
   245 
   246 	 @note can either specify format through aFormat or aImageFrameData. Conflicts should leave with KErrArgument. 
   247 	 */
   248 	virtual void InitFrameL(TUid aFormat, TInt aFrameNumber, const TSize& aFrameSizeInPixels, const TSize& aBlockSizeInPixels, TEncodeStreamCaps::TNavigation aNavigation, const CFrameImageData* aFrameImageData) = 0;
   249 	
   250 	/** Append blocks to the stream.
   251 	 @param aStatus request status	
   252 	 @param aBlocks wraps a memory buffer containing the pixel data to be added to the stream
   253 	 @param aNumBlocksToAdd number of blocks of size TEncodeStreamCaps::MinBlockSizeInPixels to add to the stream
   254 	 */
   255 	virtual void AppendBlocks(TRequestStatus* aStatus, const CImageFrame& aBlocks, TInt aNumBlocksToAdd) = 0 ;
   256 	
   257 	/** Add blocks to the stream at a random position.
   258 	 @param aStatus request status	
   259 	 @param aBlocks wraps a memory buffer containing the pixel data to be added to the stream
   260 	 @param aSeqPosition position of block in stream starting at 0
   261 	 */
   262 	virtual void AddBlocks(TRequestStatus* aStatus, const CImageFrame& aBlocks, const TInt& aSeqPosition) = 0;
   263 	
   264 	/** Signal completion of writing the stream
   265 	 @param aStatus request status	
   266 	*/
   267 	virtual void Complete(TRequestStatus* aStatus) = 0; 
   268 private:
   269 	TInt iReserved; // future proof
   270 	};
   271 
   272 
   273 /**
   274 Extension for Prepare (analyse image in advance of conversion)
   275 */
   276 class MImageConvPrepare : public MImageConvExtension
   277 	{
   278 public:
   279 	/**
   280 	Call to allow analysis of image prior to calling Convert.
   281 
   282 	@param	aStatus
   283 			Request status. On completion this contains an error code. This is KErrNone if the frame
   284 			was analyzed successfully, KErrNotSupported if the codec does not support analysis, or a 
   285 			system-wide error code.
   286 	*/
   287 	virtual void Prepare(TRequestStatus* aStatus) = 0;
   288 
   289 private:
   290 	TInt iReserved; // future proof
   291 	};
   292 	
   293 
   294 
   295 #endif // IMAGECONVERSIONEXTENSIONINF_H