imaging/imagingfws/src/imageconversionextension.cpp
changeset 0 5752a19fdefe
equal deleted inserted replaced
-1:000000000000 0:5752a19fdefe
       
     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 #include <imageframe.h>
       
    17 #include <icl/imageconversionextension.h>
       
    18 #include <icl/imageconversionextensionintf.h>
       
    19 #include <icl/icl_uids.hrh>
       
    20 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
       
    21 #include <icl/icl_uids_const.hrh>
       
    22 #include <icl/icl_uids_def.hrh>
       
    23 #endif
       
    24 #include "ImageClientMain.h"
       
    25 #include "fwextconstants.h"
       
    26 
       
    27 const TUint KVersionMask = 0x000000FF;
       
    28 const TUint KSizeMask = 0xFFFFFF00;
       
    29 
       
    30 const TUint KVersionZero = 0x00000000;
       
    31 
       
    32 EXPORT_C TScalerCaps::TScalerCaps()
       
    33 :iMaxUpscaleLimit(1), iMustPreserveAspectRatio(ETrue), iMaxDownscaleLimit(-4), 
       
    34 iPowerOfTwoScalingOnly(ETrue), iSizeVersion(KVersionZero|(sizeof(TScalerCaps)<<8)),
       
    35 iReserved(0)
       
    36 	{
       
    37 	}
       
    38 	
       
    39 EXPORT_C TScalerCaps::TScalerCaps(TInt aMaxUpscaleLimit,TInt aMaxDownscaleLimit,TBool aPreserveAspectRatioIsNeeded)
       
    40 :iMaxUpscaleLimit(aMaxUpscaleLimit), iMustPreserveAspectRatio(aPreserveAspectRatioIsNeeded),
       
    41 iMaxDownscaleLimit(aMaxDownscaleLimit), iSizeVersion(KVersionZero|(sizeof(TScalerCaps)<<8)),
       
    42 iReserved(0)
       
    43 	{
       
    44 	}
       
    45 
       
    46 EXPORT_C TInt TScalerCaps::MaxUpscaleLimit() const
       
    47 	{
       
    48 	return iMaxUpscaleLimit;
       
    49 	}
       
    50 	
       
    51 EXPORT_C TInt TScalerCaps::MaxDownscaleLimit() const
       
    52 	{
       
    53 	return iMaxDownscaleLimit;
       
    54 	}
       
    55 	
       
    56 EXPORT_C TBool TScalerCaps::PowerOfTwoScalingOnly() const
       
    57 	{
       
    58 	return iPowerOfTwoScalingOnly;
       
    59 	}
       
    60 	
       
    61 EXPORT_C TBool TScalerCaps::MustPreserveAspectRatio() const
       
    62 	{
       
    63 	return iMustPreserveAspectRatio;		
       
    64 	}
       
    65 	
       
    66 EXPORT_C TUint TScalerCaps::Size() const
       
    67 	{
       
    68 	return (KSizeMask & iSizeVersion) >> 8;
       
    69 	}
       
    70 
       
    71 EXPORT_C TUint TScalerCaps::Version() const
       
    72 	{
       
    73 	return (KVersionMask & iSizeVersion);
       
    74 	}
       
    75 
       
    76 EXPORT_C TDecodeStreamCaps::TDecodeStreamCaps()
       
    77 :iMaxBlocksPerRequest(1), iMinBlockSizeInPixels(1,1), iOptimalBlocksPerRequest(1),
       
    78 iStreamSizeInBlocks(1), iNavigation(TDecodeStreamCaps::ENavigationSequentialForward),
       
    79 iSizeVersion(KVersionZero|(sizeof(TDecodeStreamCaps)<<8)), iReserved(0)
       
    80 	{
       
    81 	}
       
    82 
       
    83 EXPORT_C TDecodeStreamCaps::TDecodeStreamCaps(TInt aMaxBlocksPerRequest, const TSize& aMinBlockSizeInPixels, 
       
    84 				  TInt aOptimalBlocksPerRequest, TInt aStreamSizeInBlocks,
       
    85 				  TDecodeStreamCaps::TNavigation aNavigation)
       
    86 :iMaxBlocksPerRequest(aMaxBlocksPerRequest), iMinBlockSizeInPixels(aMinBlockSizeInPixels),
       
    87 iOptimalBlocksPerRequest(aOptimalBlocksPerRequest) ,iStreamSizeInBlocks(aStreamSizeInBlocks),
       
    88 iNavigation(aNavigation), iSizeVersion(KVersionZero|(sizeof(TDecodeStreamCaps)<<8)), iReserved(0)
       
    89 	{
       
    90 	}
       
    91 		
       
    92 EXPORT_C TInt TDecodeStreamCaps::MaxBlocksPerRequest() const
       
    93 	{
       
    94 	return iMaxBlocksPerRequest;
       
    95 	}
       
    96 
       
    97 EXPORT_C const TSize& TDecodeStreamCaps::MinBlockSizeInPixels() const
       
    98 	{
       
    99 	return iMinBlockSizeInPixels;
       
   100 	}
       
   101 
       
   102 EXPORT_C TInt TDecodeStreamCaps::OptimalBlocksPerRequest() const
       
   103 	{
       
   104 	return iOptimalBlocksPerRequest;
       
   105 	}
       
   106 
       
   107 EXPORT_C TInt TDecodeStreamCaps::StreamSizeInBlocks() const
       
   108 	{
       
   109 	return iStreamSizeInBlocks;
       
   110 	}
       
   111 
       
   112 EXPORT_C TDecodeStreamCaps::TNavigation TDecodeStreamCaps::Navigation() const
       
   113 	{
       
   114 	return iNavigation;
       
   115 	}
       
   116 	
       
   117 EXPORT_C TUint TDecodeStreamCaps::Size() const
       
   118 	{
       
   119 	return (KSizeMask & iSizeVersion) >> 8;
       
   120 	}
       
   121 
       
   122 EXPORT_C TUint TDecodeStreamCaps::Version() const
       
   123 	{
       
   124 	return (KVersionMask & iSizeVersion);
       
   125 	}
       
   126 
       
   127 EXPORT_C TImageConvOperation::TImageConvOperation()
       
   128 :iExtension(NULL), iReserved(0)
       
   129 	{
       
   130 	}
       
   131 	
       
   132 EXPORT_C TUint TImageConvOperation::Capabilities() const
       
   133 	{
       
   134 	__ASSERT_ALWAYS(iExtension != NULL, Panic(ENullImageConvExtension));
       
   135 	return iExtension->Capabilities();
       
   136 	}
       
   137 
       
   138 EXPORT_C void TImageConvOperation::AddOperationL(TImageConvOperation::TOperation aOperation)
       
   139 	{
       
   140 	__ASSERT_ALWAYS(iExtension != NULL, Panic(ENullImageConvExtension));
       
   141 	iExtension->AddOperationL(aOperation);
       
   142 	}
       
   143 
       
   144 EXPORT_C void TImageConvOperation::ClearOperationStack()
       
   145 	{
       
   146 	__ASSERT_ALWAYS(iExtension != NULL, Panic(ENullImageConvExtension));
       
   147 	iExtension->ClearOperationStack();
       
   148 	}
       
   149 	
       
   150 void TImageConvOperation::SetExtension(MImageConvExtension* aExtension)
       
   151 	{
       
   152 	__ASSERT_ALWAYS(aExtension->Uid() == KICLOperationUid, Panic(EInvalidFwExtensionUid));
       
   153 	iExtension = static_cast<MImageConvOperation*>(aExtension);
       
   154 	}
       
   155 
       
   156 EXPORT_C TImageConvScaler::TImageConvScaler()
       
   157 :iExtension(NULL), iReserved(0)
       
   158 	{
       
   159 	}	
       
   160 
       
   161 EXPORT_C void TImageConvScaler::GetCapabilities(TScalerCaps& aCaps) const
       
   162 	{
       
   163 	__ASSERT_ALWAYS(iExtension != NULL, Panic(ENullImageConvExtension));
       
   164 	iExtension->GetCapabilities(aCaps);
       
   165 	}
       
   166 	
       
   167 EXPORT_C void TImageConvScaler::SetScalingL(const TSize& aDesiredSize, TImageConvScaler::TScalerQuality aQuality, TBool aLockAspectRatio)
       
   168 	{
       
   169 	__ASSERT_ALWAYS(iExtension != NULL, Panic(ENullImageConvExtension));
       
   170 	iExtension->SetScalingL(aDesiredSize, aQuality, aLockAspectRatio);
       
   171 	}
       
   172 	
       
   173 EXPORT_C void TImageConvScaler::SetScalingL(TInt aScalingCoeff, TImageConvScaler::TScalerQuality aScalingQuality)
       
   174 	{
       
   175 	__ASSERT_ALWAYS(iExtension != NULL, Panic(ENullImageConvExtension));
       
   176 	iExtension->SetScalingL(aScalingCoeff, aScalingQuality);
       
   177 	}
       
   178 
       
   179 void TImageConvScaler::SetExtension(MImageConvExtension* aExtension)
       
   180 	{
       
   181 	__ASSERT_ALWAYS(aExtension->Uid() == KICLScalerUid, Panic(EInvalidFwExtensionUid));
       
   182 	iExtension = static_cast<MImageConvScaler*>(aExtension);
       
   183 	}
       
   184 	
       
   185 EXPORT_C TImageConvStreamedDecode::TImageConvStreamedDecode()
       
   186 :iExtension(NULL), iReserved(0)	
       
   187 	{
       
   188 	}	
       
   189 	
       
   190 EXPORT_C void TImageConvStreamedDecode::GetBlocks(TRequestStatus& aStatus, CImageFrame& aFrame, TInt aSeqPosition, TInt aNumBlocksToGet, TInt& aNumBlocksRead)
       
   191 	{
       
   192 	__ASSERT_ALWAYS(iExtension != NULL, Panic(ENullImageConvExtension));
       
   193 	iExtension->GetBlocks(&aStatus, &aFrame, aSeqPosition, aNumBlocksToGet, &aNumBlocksRead);
       
   194 	}
       
   195 
       
   196 EXPORT_C TInt TImageConvStreamedDecode::GetBufferSize(TUid aFormat, TSize& aBlockSizeInPixels, TInt aNumBlocks) const
       
   197 	{
       
   198 	__ASSERT_ALWAYS(iExtension != NULL, Panic(ENullImageConvExtension));
       
   199 	return iExtension->GetBufferSize(aFormat, aBlockSizeInPixels, aNumBlocks);
       
   200 	}
       
   201 	
       
   202 EXPORT_C void TImageConvStreamedDecode::GetNextBlocks(TRequestStatus& aStatus, CImageFrame& aFrame, TInt aNumBlocksToGet, TInt& aNumBlocksRead, TBool& aHaveMoreBlocks)
       
   203 	{
       
   204 	__ASSERT_ALWAYS(iExtension != NULL, Panic(ENullImageConvExtension));
       
   205 	iExtension->GetNextBlocks(&aStatus, &aFrame, aNumBlocksToGet, &aNumBlocksRead, &aHaveMoreBlocks);
       
   206 	}
       
   207 	
       
   208 EXPORT_C void TImageConvStreamedDecode::GetCapabilities(TUid aFormat, TInt aFrameNumber, TDecodeStreamCaps& aCaps) const
       
   209 	{
       
   210 	__ASSERT_ALWAYS(iExtension != NULL, Panic(ENullImageConvExtension));
       
   211 	iExtension->GetCapabilities(aFormat, aFrameNumber, aCaps);
       
   212 	}
       
   213 	
       
   214 EXPORT_C void TImageConvStreamedDecode::GetSupportedFormatsL(RArray<TUid>& aFormats, TUid& aOptimalFormat) const
       
   215 	{
       
   216 	__ASSERT_ALWAYS(iExtension != NULL, Panic(ENullImageConvExtension));
       
   217 	iExtension->GetSupportedFormatsL(aFormats, aOptimalFormat);
       
   218 	}
       
   219 
       
   220 EXPORT_C void TImageConvStreamedDecode::InitFrameL(TUid aFormat, TInt aFrameNumber, TDecodeStreamCaps::TNavigation aNavigation)
       
   221 	{
       
   222 	__ASSERT_ALWAYS(iExtension != NULL, Panic(ENullImageConvExtension));
       
   223 	iExtension->InitFrameL(aFormat, aFrameNumber, aNavigation);
       
   224 	}
       
   225 
       
   226 void TImageConvStreamedDecode::SetExtension(MImageConvExtension* aExtension)
       
   227 	{
       
   228 	__ASSERT_ALWAYS(aExtension->Uid() == KICLStreamedDecodeUid, Panic(EInvalidFwExtensionUid));
       
   229 	iExtension = static_cast<MImageConvStreamedDecode*>(aExtension);
       
   230 	}
       
   231 
       
   232 EXPORT_C TEncodeStreamCaps::TEncodeStreamCaps()
       
   233 :iMaxBlocksPerRequest(1), iMinBlockSizeInPixels(1,1), iOptimalBlocksPerRequest(1),
       
   234 iNavigation(TEncodeStreamCaps::ENavigationSequentialForward),
       
   235 iSizeVersion(KVersionZero|(sizeof(TEncodeStreamCaps)<<8)), iReserved(0)
       
   236 	{
       
   237 	}
       
   238 
       
   239 EXPORT_C TEncodeStreamCaps::TEncodeStreamCaps(TInt aMaxBlocksPerRequest, const TSize& aMinBlockSizeInPixels,
       
   240 									 TInt aOptimalBlocksPerRequest,
       
   241 					  				 TEncodeStreamCaps::TNavigation aNavigation)
       
   242 :iMaxBlocksPerRequest(aMaxBlocksPerRequest), iMinBlockSizeInPixels(aMinBlockSizeInPixels),
       
   243 iOptimalBlocksPerRequest(aOptimalBlocksPerRequest), iNavigation(aNavigation),
       
   244 iSizeVersion(KVersionZero|(sizeof(TEncodeStreamCaps)<<8)), iReserved(0)
       
   245 	{
       
   246 	}
       
   247 
       
   248 EXPORT_C TInt TEncodeStreamCaps::MaxBlocksPerRequest() const
       
   249 	{
       
   250 	return iMaxBlocksPerRequest;
       
   251 	}
       
   252 
       
   253 EXPORT_C const TSize& TEncodeStreamCaps::MinBlockSizeInPixels() const
       
   254 	{
       
   255 	return iMinBlockSizeInPixels;
       
   256 	}
       
   257 
       
   258 EXPORT_C TInt TEncodeStreamCaps::OptimalBlocksPerRequest() const
       
   259 	{
       
   260 	return iOptimalBlocksPerRequest;
       
   261 	}
       
   262 
       
   263 EXPORT_C TEncodeStreamCaps::TNavigation TEncodeStreamCaps::Navigation() const
       
   264 	{
       
   265 	return iNavigation;
       
   266 	}
       
   267 
       
   268 EXPORT_C TUint TEncodeStreamCaps::Size() const
       
   269 	{
       
   270 	return (KSizeMask & iSizeVersion) >> 8;
       
   271 	}
       
   272 
       
   273 EXPORT_C TUint TEncodeStreamCaps::Version() const
       
   274 	{
       
   275 	return (KVersionMask & iSizeVersion);	
       
   276 	}
       
   277 
       
   278 EXPORT_C void TImageConvStreamedEncode::GetSupportedFormatsL(RArray<TUid>& aFormats, TUid& aOptimalFormat) const
       
   279 	{
       
   280 	__ASSERT_ALWAYS(iExtension != NULL, Panic(ENullImageConvExtension));
       
   281 	iExtension->GetSupportedFormatsL(aFormats, aOptimalFormat);
       
   282 	}
       
   283 
       
   284 EXPORT_C void TImageConvStreamedEncode::GetCapabilities(TUid aFormat, TEncodeStreamCaps& aCaps) const
       
   285 	{
       
   286 	__ASSERT_ALWAYS(iExtension != NULL, Panic(ENullImageConvExtension));
       
   287 	iExtension->GetCapabilities(aFormat, aCaps);
       
   288 	}
       
   289 
       
   290 EXPORT_C void TImageConvStreamedEncode::InitFrameL(TUid aFormat, TInt aFrameNumber, const TSize& aFrameSizeInPixels, const TSize& aBlockSizeInPixels, TEncodeStreamCaps::TNavigation aNavigation, const CFrameImageData* aFrameImageData)
       
   291 	{
       
   292 	__ASSERT_ALWAYS(iExtension != NULL, Panic(ENullImageConvExtension));
       
   293 	iExtension->InitFrameL(aFormat, aFrameNumber, aFrameSizeInPixels, aBlockSizeInPixels, aNavigation, aFrameImageData);
       
   294 	}
       
   295 
       
   296 EXPORT_C void TImageConvStreamedEncode::AppendBlocks(TRequestStatus& aStatus, const CImageFrame& aBlocks, TInt aNumBlocksToAdd)
       
   297 	{
       
   298 	__ASSERT_ALWAYS(iExtension != NULL, Panic(ENullImageConvExtension));
       
   299 	iExtension->AppendBlocks(&aStatus, aBlocks, aNumBlocksToAdd);
       
   300 	}
       
   301 
       
   302 EXPORT_C void TImageConvStreamedEncode::AddBlocks(TRequestStatus& aStatus, const CImageFrame& aBlocks, const TInt& aSeqPosition)
       
   303 	{
       
   304 	__ASSERT_ALWAYS(iExtension != NULL, Panic(ENullImageConvExtension));
       
   305 	iExtension->AddBlocks(&aStatus, aBlocks, aSeqPosition);
       
   306 	}
       
   307 
       
   308 EXPORT_C void TImageConvStreamedEncode::Complete(TRequestStatus& aStatus)
       
   309 	{
       
   310 	__ASSERT_ALWAYS(iExtension != NULL, Panic(ENullImageConvExtension));
       
   311 	iExtension->Complete(&aStatus);
       
   312 	}
       
   313 
       
   314 EXPORT_C TImageConvStreamedEncode::TImageConvStreamedEncode()
       
   315 :iExtension(NULL), iReserved(0)
       
   316 	{
       
   317 	}
       
   318 
       
   319 void TImageConvStreamedEncode::SetExtension(MImageConvExtension* aExtension)
       
   320 	{
       
   321 	iExtension = static_cast<MImageConvStreamedEncode*>(aExtension);	
       
   322 	}
       
   323 
       
   324