imagingandcamerafws/imaginginttest/src/TestStepYUVConversion.cpp
changeset 0 40261b775718
equal deleted inserted replaced
-1:000000000000 0:40261b775718
       
     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 file contains the test steps ICL YUV testing  for Bravo - PREQ 747.
       
    15 // 
       
    16 //
       
    17 
       
    18 // EPOC includes
       
    19 #include <testframework.h>
       
    20 #include <icl/icl_uids.hrh>
       
    21 #include "TestStepYUVConversion.h"
       
    22 #include "ICLFbsSessionTest.h"
       
    23 #include <iclexifimageframe.h>
       
    24 
       
    25 #define INFO_PRINTF1_IF_LOGS_ENABLED( a ) if(iEnableLogs) 		\
       
    26 											{					\
       
    27 											INFO_PRINTF1( a );	\
       
    28 											}											
       
    29 											
       
    30 #define INFO_PRINTF2_IF_LOGS_ENABLED( a, b ) if(iEnableLogs)					\
       
    31 												{								\
       
    32 												INFO_PRINTF2( ( a ), ( b ) );	\
       
    33 												}
       
    34 											
       
    35 #define INFO_PRINTF3_IF_LOGS_ENABLED( a, b, c ) if(iEnableLogs)								\
       
    36 													{										\
       
    37 													INFO_PRINTF3( ( a ), ( b ), ( c ) );	\
       
    38 													}
       
    39 											
       
    40 #define ERR_PRINTF1_IF_LOGS_ENABLED( a ) if(iEnableLogs)		\
       
    41 											{					\
       
    42 											ERR_PRINTF1( a );	\
       
    43 											}											
       
    44 											
       
    45 #define ERR_PRINTF2_IF_LOGS_ENABLED( a, b ) if(iEnableLogs)						\
       
    46 												{								\
       
    47 												ERR_PRINTF2( ( a ), ( b ) );	\
       
    48 												}
       
    49 											
       
    50 #define ERR_PRINTF3_IF_LOGS_ENABLED( a, b, c ) if(iEnableLogs)							\
       
    51 													{									\
       
    52 													ERR_PRINTF3( ( a ), ( b ), ( c ) );	\
       
    53 													}											
       
    54 										
       
    55 																																	
       
    56 const TUid KImageFramePluginUid  = {0x101F7C60};
       
    57 const TUid KTestImageFramePluginUid = {0x101f7c61};
       
    58 
       
    59 const TInt KRChunkSize  = 0;
       
    60 
       
    61 //
       
    62 // POSITIVE TESTS
       
    63 //
       
    64 
       
    65 //
       
    66 // CTestConvertYuvRchunk
       
    67 //
       
    68 
       
    69  CTestStepYUVConversion::CTestStepYUVConversion(const TDesC& aTestName) : CTestStepConversion(aTestName)
       
    70  {
       
    71  	iHeapSize = 500000;
       
    72  	iEnableLogs = ETrue;//By deafult log the messages    
       
    73  }
       
    74 
       
    75 /*
       
    76 *
       
    77 * OpenImageAndYUVDecodeToDesc
       
    78 * MM-ICL-FRM-I-1001-CP,  MM-ICL-FRM-I-1008-HP
       
    79 *
       
    80 */
       
    81 
       
    82 TInt CTestStepYUVConversion::DecodeToRChunkAndEncodeToDescL(const TDesC& aFileName)
       
    83     {
       
    84     // Get the path
       
    85     TFileName theSourceFilename;
       
    86     Directory(EInput, theSourceFilename);
       
    87     theSourceFilename.Append(aFileName);
       
    88 
       
    89     User::LeaveIfError(iFs.Connect());
       
    90     CleanupClosePushL(iFs);
       
    91     
       
    92     INFO_PRINTF2_IF_LOGS_ENABLED(_L("Opening the file %S for "), &theSourceFilename);
       
    93     // Open the image and create an image imageDecoder
       
    94     CJPEGImageFrameDecoder* imageDecoder = NULL;
       
    95 	TRAPD(err,imageDecoder = static_cast<CJPEGImageFrameDecoder*>( CImageDecoder::FileNewL(iFs, theSourceFilename, CImageDecoder::EOptionNone, KNullUid, KNullUid, KImageFramePluginUid)));
       
    96 	    
       
    97     if (err != KErrNone)
       
    98         {
       
    99         INFO_PRINTF3_IF_LOGS_ENABLED(_L("Cannot open file: %S. Unexpected Error: %d"), &theSourceFilename, err);
       
   100         User::Leave(err);
       
   101         }
       
   102     if (imageDecoder == NULL)
       
   103         {
       
   104         INFO_PRINTF1_IF_LOGS_ENABLED(_L("ImageDecoder is NULL!"));
       
   105         User::Leave(err);
       
   106         }
       
   107     CleanupStack::PushL(imageDecoder);
       
   108 	INFO_PRINTF2_IF_LOGS_ENABLED(_L("The file %S had been opened."), &theSourceFilename);
       
   109     
       
   110     // create destination RChunk
       
   111 	RChunk chunk;
       
   112 	TInt imageSizeInBytes;
       
   113 	TBool supported = imageDecoder->RecommendedBufferSize(imageSizeInBytes);
       
   114 	if (supported == EFalse)
       
   115 		{
       
   116 		INFO_PRINTF1_IF_LOGS_ENABLED(_L("Codec does not support this image format"));
       
   117 		User::Leave(KErrNotSupported);
       
   118 		}
       
   119 		
       
   120 	TInt res = chunk.CreateGlobal(_L("aRchunkICL"), imageSizeInBytes, imageSizeInBytes, EOwnerProcess);	
       
   121 	User::LeaveIfError(res);
       
   122 	
       
   123 	CleanupClosePushL(chunk);
       
   124   		
       
   125   	// create an empty imageframe   
       
   126   	CImageFrame* theImageFrame = NULL;
       
   127 	TRAP(err, theImageFrame = CImageFrame::NewL(&chunk, imageSizeInBytes, KRChunkSize));
       
   128 	if (err != KErrNone)
       
   129 		{
       
   130 		INFO_PRINTF2_IF_LOGS_ENABLED(_L("Could not do Create imageFrame"),err);
       
   131 		if (theImageFrame)
       
   132 			{
       
   133 			delete theImageFrame;
       
   134 			}
       
   135 		User::Leave(err);
       
   136 		}
       
   137 		CleanupStack::PushL(theImageFrame);
       
   138 	// Create an active listener and push it on the cleanup stack
       
   139     CActiveListener* activeListener = new (ELeave) CActiveListener;
       
   140     CleanupStack::PushL(activeListener);
       
   141     
       
   142     activeListener->InitialiseActiveListener();
       
   143     
       
   144     // Decode the image
       
   145     imageDecoder->ConvertFrame(&activeListener->iStatus, *theImageFrame);
       
   146     CActiveScheduler::Start();
       
   147 
       
   148     err = activeListener->iStatus.Int();
       
   149     if (err != KErrNone)
       
   150         {
       
   151         ERR_PRINTF2_IF_LOGS_ENABLED(_L("Error during Decoding of the file: %S"), &theSourceFilename);
       
   152         User::Leave(err);
       
   153         }
       
   154         
       
   155     // Encode //
       
   156     
       
   157 	// Create the destination buffer
       
   158 	HBufC8 *theDestinationImage = NULL;
       
   159 	//CleanupStack::PushL(theDestinationImage);
       
   160 	
       
   161 	// Create an object of CJPEGImageFrameEncoder
       
   162     CJPEGImageFrameEncoder* imageEncoder = NULL;
       
   163 	TRAP(err, imageEncoder = static_cast<CJPEGImageFrameEncoder*>( CImageEncoder::DataNewL(theDestinationImage, CImageEncoder::EOptionNone, KNullUid, KNullUid, KImageFramePluginUid)));
       
   164 
       
   165 	if (err != KErrNone)
       
   166 		{
       
   167 		delete theDestinationImage;
       
   168 		theDestinationImage = NULL;
       
   169 		ERR_PRINTF3_IF_LOGS_ENABLED(_L("Error during creating Image Encoder UId %d to file %S" ), iImageTypeUid, &iFileNameDest);			 		
       
   170 		if (err == KErrPathNotFound)
       
   171     		{
       
   172     		ERR_PRINTF2_IF_LOGS_ENABLED(_L("Path %S not found" ), &iFileNameDest);
       
   173     		}
       
   174 		if (err == KErrAccessDenied)
       
   175     		{
       
   176     		ERR_PRINTF1_IF_LOGS_ENABLED(_L("Access denied" ));
       
   177     		}
       
   178 		User::Leave(err);
       
   179 		}
       
   180 	CleanupStack::PushL(imageEncoder);
       
   181 
       
   182     // Create CActiveListener
       
   183 	CActiveListener* activeEncodeListener = new(ELeave)CActiveListener;
       
   184 	CleanupStack::PushL( activeEncodeListener );
       
   185 
       
   186 	iActiveScheduler->SetEncoder(imageEncoder, activeEncodeListener, 0);
       
   187 	iActiveScheduler->SetStep(this);
       
   188 
       
   189 	activeEncodeListener->InitialiseActiveListener();
       
   190   
       
   191   	
       
   192 	// Do the Encode from YUV to JPEG
       
   193 	imageEncoder->ConvertFrame(&activeEncodeListener->iStatus, *theImageFrame);
       
   194 	CActiveScheduler::Start();
       
   195 
       
   196 	err = activeEncodeListener->iStatus.Int();
       
   197 	iActiveScheduler->ResetValues();
       
   198     
       
   199     if (err != KErrNone)
       
   200 		{
       
   201 		ERR_PRINTF1_IF_LOGS_ENABLED(_L("Error during conversion"));
       
   202 		User::Leave(err);
       
   203 		}
       
   204 	
       
   205 	// Cleanup
       
   206 	CleanupStack::PopAndDestroy(6); //active scheduler
       
   207 
       
   208     //compare two file into a flat buffer
       
   209 	err = CompareFileL(aFileName, theDestinationImage, iImageTypeUid, EReference); 
       
   210 	User::LeaveIfError(err);
       
   211     
       
   212     delete theDestinationImage;
       
   213 	theDestinationImage = NULL;
       
   214 	CleanupStack::PopAndDestroy(1);
       
   215 	
       
   216 	return err;
       
   217     }
       
   218 
       
   219 /*
       
   220 *
       
   221 * OpenImageAndYUVDecodeToRChunkL
       
   222 * MM-ICL-FRM-I-1002-CP, MM-ICL-FRM-I-1009-HP 
       
   223 *
       
   224 */
       
   225 
       
   226 TInt CTestStepYUVConversion::DecodeToRChunkAndEncodeToFileL(const TDesC& aFileName)
       
   227     {
       
   228     // Get the path
       
   229     TFileName theSourceFilename;
       
   230     Directory(EInput, theSourceFilename);
       
   231     theSourceFilename.Append(aFileName);
       
   232 
       
   233     User::LeaveIfError(iFs.Connect());
       
   234 	CleanupClosePushL(iFs);
       
   235 	
       
   236 	INFO_PRINTF2_IF_LOGS_ENABLED(_L("Opening the file %S for "), &theSourceFilename);
       
   237     
       
   238     // Open the image and create an image imageDecoder
       
   239     CJPEGImageFrameDecoder* imageDecoder = NULL;
       
   240 	TRAPD(err,imageDecoder = static_cast<CJPEGImageFrameDecoder*>( CImageDecoder::FileNewL(iFs, theSourceFilename, CImageDecoder::EOptionNone, KNullUid, KNullUid, KImageFramePluginUid)));
       
   241 	    
       
   242     if (err != KErrNone)
       
   243         {
       
   244         INFO_PRINTF3_IF_LOGS_ENABLED(_L("Cannot open file: %S. Unexpected Error: %d"), &theSourceFilename, err);
       
   245         User::Leave(err);
       
   246         }
       
   247 
       
   248     if (imageDecoder == NULL)
       
   249         {
       
   250         INFO_PRINTF1_IF_LOGS_ENABLED(_L("ImageDecoder is NULL!"));
       
   251         User::Leave(err);
       
   252         }
       
   253     CleanupStack::PushL(imageDecoder);
       
   254 
       
   255 	INFO_PRINTF2_IF_LOGS_ENABLED(_L("The file %S had been opened."), &theSourceFilename);
       
   256     
       
   257 	// create destination RChunk
       
   258 	RChunk chunk;
       
   259 	TInt imageSizeInBytes;
       
   260 	TBool supported = imageDecoder->RecommendedBufferSize(imageSizeInBytes);
       
   261 	if (supported == EFalse)
       
   262 		{
       
   263 		INFO_PRINTF1_IF_LOGS_ENABLED(_L("Codec does not support this image format"));
       
   264 		User::Leave(KErrNotSupported);
       
   265 		}
       
   266 		
       
   267 	TInt res = chunk.CreateGlobal(_L("aRchunkICL"), imageSizeInBytes, imageSizeInBytes, EOwnerProcess);	
       
   268 	User::LeaveIfError(res);
       
   269 	
       
   270 	CleanupClosePushL(chunk);
       
   271   		
       
   272 	// create an empty imageframe   
       
   273   	CImageFrame* theImageFrame = NULL;
       
   274 	TRAP(err, theImageFrame = CImageFrame::NewL(&chunk, imageSizeInBytes,KRChunkSize));
       
   275 	if (err != KErrNone)
       
   276 		{
       
   277 		INFO_PRINTF2_IF_LOGS_ENABLED(_L("Could not do Create imageFrame"),err);
       
   278 		if (theImageFrame)
       
   279 			{
       
   280 			delete theImageFrame;
       
   281 			}
       
   282 		User::Leave(err);
       
   283 		}
       
   284 		CleanupStack::PushL(theImageFrame);
       
   285 	 	
       
   286 	// Create an active listener and push it on the cleanup stack
       
   287     CActiveListener* activeListener = new (ELeave) CActiveListener;
       
   288     CleanupStack::PushL(activeListener);
       
   289     activeListener->InitialiseActiveListener();
       
   290     
       
   291     // Decode the image
       
   292     imageDecoder->ConvertFrame(&activeListener->iStatus, *theImageFrame);
       
   293     CActiveScheduler::Start();
       
   294 
       
   295     err = activeListener->iStatus.Int();
       
   296     if (err != KErrNone)
       
   297         {
       
   298         ERR_PRINTF2_IF_LOGS_ENABLED(_L("Error during Decoding of the file: %S"), &theSourceFilename);
       
   299         User::Leave(err);
       
   300         }
       
   301         
       
   302     // Encode //
       
   303     
       
   304 	// Create the destination filename from the source filename
       
   305 	TBuf<KLenBuffer> theExtension;
       
   306 
       
   307 	Directory(EOutput, iFileNameDest);
       
   308 	iFileNameDest.Append(aFileName.Left(aFileName.Length() - 4));
       
   309 	iFileNameDest.Append(_L("_OUT."));
       
   310 
       
   311 	GetImageExtension(iImageTypeUid, theExtension);
       
   312 	iFileNameDest.Append(theExtension);
       
   313 	
       
   314 	// Create an object of CJPEGImageFrameEncoder
       
   315     CJPEGImageFrameEncoder* imageEncoder = NULL;
       
   316 	TRAP(err, imageEncoder = static_cast<CJPEGImageFrameEncoder*>( CImageEncoder::FileNewL(iFs, iFileNameDest, CImageEncoder::EOptionNone, KNullUid, KNullUid, KImageFramePluginUid)));
       
   317 
       
   318 	if (err != KErrNone)
       
   319 		{
       
   320 		ERR_PRINTF3_IF_LOGS_ENABLED(_L("Error during creating Image Encoder UId %d to file %S" ), iImageTypeUid, &iFileNameDest);
       
   321 		if (err == KErrPathNotFound)
       
   322     		{
       
   323     		ERR_PRINTF2_IF_LOGS_ENABLED(_L("Path %S not found" ), &iFileNameDest);
       
   324     		}
       
   325 		if (err == KErrAccessDenied)
       
   326     		{
       
   327     		ERR_PRINTF1_IF_LOGS_ENABLED(_L("Access denied" ));
       
   328     		}
       
   329 		User::Leave(err);
       
   330 		}
       
   331 	CleanupStack::PushL(imageEncoder);
       
   332 
       
   333     // Create CActiveListener
       
   334 	CActiveListener* activeEncodeListener = new(ELeave)CActiveListener;
       
   335 	CleanupStack::PushL(activeEncodeListener);
       
   336 
       
   337 	iActiveScheduler->SetEncoder(imageEncoder, activeEncodeListener, 0);
       
   338 	iActiveScheduler->SetStep(this);
       
   339 
       
   340 	activeEncodeListener->InitialiseActiveListener();
       
   341   
       
   342 	// Do the Encode from YUV to JPEG
       
   343 	imageEncoder->ConvertFrame(&activeEncodeListener->iStatus, *theImageFrame);
       
   344 	CActiveScheduler::Start();
       
   345 
       
   346 	err = activeEncodeListener->iStatus.Int();
       
   347 	iActiveScheduler->ResetValues();
       
   348     
       
   349     if (err != KErrNone)
       
   350 		{
       
   351 		ERR_PRINTF2_IF_LOGS_ENABLED(_L("Error during conversion"),err);
       
   352 		User::Leave(err);
       
   353 		}
       
   354 	
       
   355 	// Cleanup
       
   356 	CleanupStack::PopAndDestroy(6); //active scheduler
       
   357 	
       
   358 	//compare two file into a flat buffer
       
   359 	TInt fileSize;
       
   360 	
       
   361 	iFile.Open(iFs, iFileNameDest, EFileRead);
       
   362 	CleanupClosePushL(iFile);
       
   363 	
       
   364 	iFile.Size(fileSize);
       
   365 	INFO_PRINTF2_IF_LOGS_ENABLED(_L("File Size: %d"),fileSize);
       
   366 	HBufC8 *theCreatedImage = HBufC8::NewMaxLC(fileSize);
       
   367 			
       
   368 	TPtr8 imageFromFilePtr = theCreatedImage->Des();
       
   369 	iFile.Read(imageFromFilePtr);
       
   370 	iFile.Close();
       
   371 	
       
   372 	err = CompareFileL(aFileName, theCreatedImage, iImageTypeUid, EReference); 
       
   373     User::LeaveIfError(err);
       
   374     
       
   375 	// Cleanup
       
   376 	CleanupStack::PopAndDestroy(3); //theCreatedImage
       
   377 	
       
   378     return err;
       
   379     }
       
   380 
       
   381 /**
       
   382 *
       
   383 * DecodeToDescAndEncodeToDescL
       
   384 * MM-ICL-FRM-I-1003-CP,  MM-ICL-FRM-I-1010-HP
       
   385 *
       
   386 */
       
   387 
       
   388 
       
   389 TInt CTestStepYUVConversion::DecodeToDescAndEncodeToDescL(const TDesC& aFileName)
       
   390     {
       
   391     // Get the path
       
   392     TFileName theSourceFilename;
       
   393     Directory(EInput, theSourceFilename);
       
   394     theSourceFilename.Append(aFileName);
       
   395 
       
   396     User::LeaveIfError(iFs.Connect());
       
   397     CleanupClosePushL(iFs);
       
   398 
       
   399 	INFO_PRINTF2_IF_LOGS_ENABLED(_L("Opening the file %S for "), &theSourceFilename);
       
   400     
       
   401     // Open the image and create an image imageDecoder
       
   402     CJPEGImageFrameDecoder* imageDecoder = NULL;
       
   403 	TRAPD(err, imageDecoder = static_cast<CJPEGImageFrameDecoder*>( CImageDecoder::FileNewL(iFs, theSourceFilename, CImageDecoder::EOptionNone, KNullUid, KNullUid, KImageFramePluginUid)));
       
   404 
       
   405     if (err != KErrNone)
       
   406         {
       
   407         INFO_PRINTF3_IF_LOGS_ENABLED(_L("Cannot open file: %S. Unexpected Error: %d"), &theSourceFilename, err);
       
   408         User::Leave(err);
       
   409         }
       
   410 
       
   411     if (imageDecoder == NULL)
       
   412         {
       
   413         INFO_PRINTF1_IF_LOGS_ENABLED(_L("ImageDecoder is NULL!"));
       
   414         User::Leave(err);
       
   415         }
       
   416     CleanupStack::PushL(imageDecoder);
       
   417 
       
   418 	INFO_PRINTF2_IF_LOGS_ENABLED(_L("The file %S had been opened for Decode."), &theSourceFilename);
       
   419 	
       
   420 	// create destination Desc
       
   421 	TInt imageSizeInBytes;
       
   422 	TBool supported = imageDecoder->RecommendedBufferSize(imageSizeInBytes);
       
   423 	if (supported == EFalse)
       
   424 	{
       
   425 		INFO_PRINTF1_IF_LOGS_ENABLED(_L("Codec does not support this image format"));
       
   426 		User::Leave(KErrNotSupported);
       
   427 	}
       
   428 	
       
   429 	HBufC8* buffer = HBufC8::NewMaxL(imageSizeInBytes);
       
   430 	CleanupStack::PushL(buffer);
       
   431 	TPtr8 ptr = buffer->Des();
       
   432   	
       
   433 	// create an empty imageframe   
       
   434 	CImageFrame* theImageFrame = NULL;
       
   435 	TRAP(err, theImageFrame =	CImageFrame::NewL(ptr, imageSizeInBytes));
       
   436 	if (err != KErrNone)
       
   437 		{
       
   438 		INFO_PRINTF2_IF_LOGS_ENABLED(_L("Could not do Create imageFrame"),err);
       
   439 		if (theImageFrame)
       
   440 			{
       
   441 			delete theImageFrame;
       
   442 			}
       
   443 		User::Leave(err);
       
   444 		}
       
   445 	CleanupStack::PushL(theImageFrame);
       
   446 	
       
   447 	// Create an active listener and push it on the cleanup stack
       
   448     CActiveListener* activeListener = new (ELeave) CActiveListener;
       
   449     CleanupStack::PushL(activeListener);
       
   450     activeListener->InitialiseActiveListener();
       
   451 
       
   452     // Decode the image
       
   453     imageDecoder->ConvertFrame(&activeListener->iStatus, *theImageFrame);
       
   454     CActiveScheduler::Start();
       
   455     err = activeListener->iStatus.Int();
       
   456     
       
   457     if (err != KErrNone)
       
   458         {
       
   459         ERR_PRINTF2_IF_LOGS_ENABLED(_L("Error during conversion of the file: %S"), &theSourceFilename);
       
   460         User::Leave(err);
       
   461         }
       
   462     
       
   463     // Encode //
       
   464     
       
   465 	// Create the destination buffer
       
   466 	HBufC8 *theDestinationImage = NULL;
       
   467 	
       
   468 	// Create an object of CJPEGImageFrameEncoder
       
   469     CJPEGImageFrameEncoder* imageEncoder = NULL;
       
   470 	TRAP(err, imageEncoder = static_cast<CJPEGImageFrameEncoder*>( CImageEncoder::DataNewL(theDestinationImage, CImageEncoder::EOptionNone, KNullUid, KNullUid, KImageFramePluginUid)));
       
   471 
       
   472 	if (err != KErrNone)
       
   473 		{
       
   474 		ERR_PRINTF3_IF_LOGS_ENABLED(_L("Error during creating Image Encoder UId %d to file %S" ), iImageTypeUid, &iFileNameDest);
       
   475 		if (err == KErrPathNotFound)
       
   476     		{
       
   477     		ERR_PRINTF2_IF_LOGS_ENABLED(_L("Path %S not found" ), &iFileNameDest);
       
   478     		}
       
   479 		if (err == KErrAccessDenied)
       
   480     		{
       
   481     		ERR_PRINTF1_IF_LOGS_ENABLED(_L("Access denied" ));
       
   482     		}
       
   483 		User::Leave(err);
       
   484 		}
       
   485 	CleanupStack::PushL(imageEncoder);
       
   486 
       
   487     // Create CActiveListener
       
   488 	CActiveListener* activeEncodeListener = new(ELeave)CActiveListener;
       
   489 	CleanupStack::PushL( activeEncodeListener );
       
   490 
       
   491 	iActiveScheduler->SetEncoder(imageEncoder, activeEncodeListener, 0);
       
   492 	iActiveScheduler->SetStep(this);
       
   493 
       
   494 	activeEncodeListener->InitialiseActiveListener();
       
   495   
       
   496 	// Do the Encode from YUV to JPEG
       
   497 	imageEncoder->ConvertFrame(&activeEncodeListener->iStatus, *theImageFrame);
       
   498 	CActiveScheduler::Start();
       
   499 
       
   500 	err = activeEncodeListener->iStatus.Int();
       
   501 	iActiveScheduler->ResetValues();
       
   502     
       
   503     if (err != KErrNone)
       
   504 		{
       
   505 		ERR_PRINTF1_IF_LOGS_ENABLED(_L("Error during conversion"));
       
   506 		delete theDestinationImage;
       
   507 		theDestinationImage = NULL;
       
   508 		
       
   509 		User::Leave(err);
       
   510 		}
       
   511 	
       
   512 	// Cleanup
       
   513 	CleanupStack::PopAndDestroy(6); //active sheduler
       
   514 	
       
   515     //compare two file into a flat buffer
       
   516 	err = CompareFileL(aFileName, theDestinationImage , iImageTypeUid, EReference); 
       
   517     User::LeaveIfError(err);
       
   518     
       
   519     delete theDestinationImage;
       
   520 	theDestinationImage = NULL;
       
   521 	CleanupStack::PopAndDestroy(1);
       
   522 	
       
   523 	return err;
       
   524     }
       
   525 
       
   526 /**
       
   527 *
       
   528 * DecodeToDescAndEncodeToFileL
       
   529 * MM-ICL-FRM-I-1004-CP,  MM-ICL-FRM-I-1011-HP
       
   530 *
       
   531 */
       
   532 
       
   533 
       
   534 TInt CTestStepYUVConversion::DecodeToDescAndEncodeToFileL(const TDesC& aFileName)
       
   535     {
       
   536     // Get the path
       
   537     TFileName theSourceFilename;
       
   538     Directory(EInput, theSourceFilename);
       
   539     theSourceFilename.Append(aFileName);
       
   540 
       
   541     User::LeaveIfError(iFs.Connect());
       
   542 	CleanupClosePushL(iFs);
       
   543 
       
   544 	INFO_PRINTF2_IF_LOGS_ENABLED(_L("Opening the file %S for "), &theSourceFilename);
       
   545     
       
   546     // Open the image and create an image imageDecoder
       
   547     CJPEGImageFrameDecoder* imageDecoder = NULL;
       
   548 	TRAPD(err, imageDecoder = static_cast<CJPEGImageFrameDecoder*>( CImageDecoder::FileNewL(iFs, theSourceFilename, CImageDecoder::EOptionNone, KNullUid, KNullUid, KImageFramePluginUid)));
       
   549 
       
   550     if (err != KErrNone)
       
   551         {
       
   552         INFO_PRINTF3_IF_LOGS_ENABLED(_L("Cannot open file: %S. Unexpected Error: %d"), &theSourceFilename, err);
       
   553         User::Leave(err);
       
   554         }
       
   555 
       
   556     if (imageDecoder == NULL)
       
   557         {
       
   558         INFO_PRINTF1_IF_LOGS_ENABLED(_L("ImageDecoder is NULL!"));
       
   559         User::Leave(err);
       
   560         }
       
   561     CleanupStack::PushL(imageDecoder);
       
   562 
       
   563 	INFO_PRINTF2_IF_LOGS_ENABLED(_L("The file %S had been opened for Decode."), &theSourceFilename);
       
   564     
       
   565     // create destination Desc
       
   566 	TInt imageSizeInBytes;
       
   567 	TBool supported = imageDecoder->RecommendedBufferSize(imageSizeInBytes);
       
   568 	if (supported == EFalse)
       
   569 	{
       
   570 		INFO_PRINTF1_IF_LOGS_ENABLED(_L("Codec does not support this image format"));
       
   571 		User::Leave(KErrNotSupported);
       
   572 	}
       
   573 	
       
   574 	HBufC8* buffer = HBufC8::NewMaxL(imageSizeInBytes);
       
   575 	CleanupStack::PushL(buffer);
       
   576 	TPtr8 ptr = buffer->Des();
       
   577   	
       
   578 	// create an empty imageframe   
       
   579 	CImageFrame* theImageFrame = NULL;
       
   580 	TRAP(err, theImageFrame =	CImageFrame::NewL(ptr, imageSizeInBytes));
       
   581 	if (err != KErrNone)
       
   582 		{
       
   583 		INFO_PRINTF2_IF_LOGS_ENABLED(_L("Could not do Create imageFrame"),err);
       
   584 		if (theImageFrame)
       
   585 			{
       
   586 			delete theImageFrame;
       
   587 			}
       
   588 		User::Leave(err);
       
   589 		}
       
   590 	CleanupStack::PushL(theImageFrame);
       
   591 
       
   592     // Create an active listener and push it on the cleanup stack
       
   593     CActiveListener* activeListener = new (ELeave) CActiveListener;
       
   594     CleanupStack::PushL(activeListener);
       
   595     activeListener->InitialiseActiveListener();
       
   596 
       
   597     // Decode the image
       
   598     imageDecoder->ConvertFrame(&activeListener->iStatus, *theImageFrame);
       
   599     CActiveScheduler::Start();
       
   600     err = activeListener->iStatus.Int();
       
   601     
       
   602     if (err != KErrNone)
       
   603         {
       
   604         ERR_PRINTF2_IF_LOGS_ENABLED(_L("Error during conversion of the file: %S"), &theSourceFilename);
       
   605         User::Leave(err);
       
   606         }
       
   607     
       
   608     // Encode //
       
   609     
       
   610 	// Create the destination filename from the source filename
       
   611 	TBuf<KLenBuffer> theExtension;
       
   612 
       
   613 	Directory(EOutput, iFileNameDest);
       
   614 	iFileNameDest.Append(aFileName.Left(aFileName.Length() - 4));
       
   615 	iFileNameDest.Append(_L("_OUT."));
       
   616 
       
   617 	GetImageExtension(iImageTypeUid, theExtension);
       
   618 	iFileNameDest.Append(theExtension);
       
   619 	
       
   620 	// Create an object of CJPEGImageFrameEncoder
       
   621     CJPEGImageFrameEncoder* imageEncoder = NULL;
       
   622 	TRAP(err, imageEncoder = static_cast<CJPEGImageFrameEncoder*>( CImageEncoder::FileNewL(iFs, iFileNameDest, CImageEncoder::EOptionNone, KNullUid, KNullUid, KImageFramePluginUid)));
       
   623 
       
   624 	if (err != KErrNone)
       
   625 		{
       
   626 		ERR_PRINTF3_IF_LOGS_ENABLED(_L("Error during creating Image Encoder UId %d to file %S" ), iImageTypeUid, &iFileNameDest);
       
   627 		if (err == KErrPathNotFound)
       
   628     		{
       
   629     		ERR_PRINTF2_IF_LOGS_ENABLED(_L("Path %S not found" ), &iFileNameDest);
       
   630     		}
       
   631 		if (err == KErrAccessDenied)
       
   632     		{
       
   633     		ERR_PRINTF1_IF_LOGS_ENABLED(_L("Access denied" ));
       
   634     		}
       
   635 		User::Leave(err);
       
   636 		}
       
   637 	CleanupStack::PushL(imageEncoder);
       
   638 
       
   639     // Create CActiveListener
       
   640 	CActiveListener* activeEncodeListener = new(ELeave)CActiveListener;
       
   641 	CleanupStack::PushL( activeEncodeListener );
       
   642 
       
   643 	iActiveScheduler->SetEncoder(imageEncoder, activeEncodeListener, 0);
       
   644 	iActiveScheduler->SetStep(this);
       
   645 
       
   646 	activeEncodeListener->InitialiseActiveListener();
       
   647   
       
   648 	// Do the Encode from YUV to JPEG
       
   649 	imageEncoder->ConvertFrame(&activeEncodeListener->iStatus, *theImageFrame);
       
   650 	CActiveScheduler::Start();
       
   651 
       
   652 	err = activeEncodeListener->iStatus.Int();
       
   653 	iActiveScheduler->ResetValues();
       
   654     
       
   655     if (err != KErrNone)
       
   656 		{
       
   657 		ERR_PRINTF1_IF_LOGS_ENABLED(_L("Error during conversion"));
       
   658 		User::Leave(err);
       
   659 		}
       
   660 	
       
   661 	// Cleanup
       
   662 	CleanupStack::PopAndDestroy(6); //active sheduler
       
   663 		
       
   664     //compare two file into a flat buffer
       
   665 	TInt fileSize;
       
   666 	
       
   667 	iFile.Open(iFs, iFileNameDest, EFileRead);
       
   668 	CleanupClosePushL(iFile);
       
   669 	
       
   670 	iFile.Size(fileSize);
       
   671 	HBufC8 *theCreatedImage = HBufC8::NewMaxLC(fileSize);
       
   672 
       
   673 	TPtr8 imageFromFilePtr = theCreatedImage->Des();
       
   674 	iFile.Read(imageFromFilePtr);
       
   675 	iFile.Close();
       
   676 
       
   677 	err = CompareFileL(aFileName, theCreatedImage, iImageTypeUid, EReference); 
       
   678     User::LeaveIfError(err);
       
   679     
       
   680 	// Cleanup
       
   681 	CleanupStack::PopAndDestroy(3);
       
   682 	
       
   683     return err;
       
   684     }
       
   685 		
       
   686 /*
       
   687 *
       
   688 * DecodeToRChunkAndEncodeToFileXtraParamsL
       
   689 * MM-ICL-FRM-I-1005-LP
       
   690 *
       
   691 */
       
   692 
       
   693 TInt CTestStepYUVConversion::DecodeToRChunkAndEncodeToFileXtraParamsL(const TDesC& aFileName)
       
   694     {
       
   695     // Get the path
       
   696     TFileName theSourceFilename;
       
   697     Directory(EInput, theSourceFilename);
       
   698     theSourceFilename.Append(aFileName);
       
   699 
       
   700     User::LeaveIfError(iFs.Connect());
       
   701 
       
   702     INFO_PRINTF2(_L("Opening the file %S for "), &theSourceFilename);
       
   703     
       
   704     // Open the image and create an image imageDecoder
       
   705     CJPEGImageFrameDecoder* imageDecoder = NULL;
       
   706 	TRAPD(err,imageDecoder = static_cast<CJPEGImageFrameDecoder*>( CImageDecoder::FileNewL(iFs, theSourceFilename, CImageDecoder::EOptionAlwaysThread, KNullUid, KNullUid, KImageFramePluginUid)));
       
   707 	    
       
   708     if (err != KErrNone)
       
   709         {
       
   710         INFO_PRINTF3(_L("Cannot open file: %S. Unexpected Error: %d"), &theSourceFilename, err);
       
   711         return err;
       
   712         }
       
   713 
       
   714     if (imageDecoder == NULL)
       
   715         {
       
   716         INFO_PRINTF1(_L("ImageDecoder is NULL!"));
       
   717         return err;
       
   718         }
       
   719     CleanupStack::PushL(imageDecoder);
       
   720 
       
   721 	INFO_PRINTF2_IF_LOGS_ENABLED(_L("The file %S had been opened."), &theSourceFilename);
       
   722     
       
   723 	// create destination RChunk
       
   724 		RChunk chunk;
       
   725 		TInt imageSizeInBytes;
       
   726 		TBool supported = imageDecoder->RecommendedBufferSize(KUidFormatYUV420Planar, imageSizeInBytes);
       
   727 		if (supported == EFalse)
       
   728 			{
       
   729 			ERR_PRINTF1(_L("The format 'KUidFormatYUV420Planar' is not Supported"));
       
   730 			User::Leave(KErrNotSupported);
       
   731 			}
       
   732 		
       
   733 		TInt res = chunk.CreateGlobal(_L("aRchunkICL"), imageSizeInBytes, imageSizeInBytes, EOwnerProcess);	
       
   734 		User::LeaveIfError(res);
       
   735 	
       
   736 	  	CleanupClosePushL(chunk);
       
   737   	
       
   738 		// create an empty imageframe   
       
   739 		CImageFrame* theImageFrame = NULL;
       
   740 		TRAP(err, theImageFrame =	CImageFrame::NewL(&chunk, imageSizeInBytes,KRChunkSize));
       
   741 		if (err != KErrNone)
       
   742 			{
       
   743 			INFO_PRINTF1(_L("Could not do Create imageFrame"));
       
   744 			if (theImageFrame)
       
   745 				{
       
   746 				delete theImageFrame;
       
   747 				}
       
   748 			return EFail;
       
   749 			}
       
   750 		CleanupStack::PushL(theImageFrame);
       
   751 
       
   752 	// Create an active listener and push it on the cleanup stack
       
   753     CActiveListener* activeListener = new (ELeave) CActiveListener;
       
   754     CleanupStack::PushL(activeListener);
       
   755     activeListener->InitialiseActiveListener();
       
   756     
       
   757     // Decode the image
       
   758     imageDecoder->ConvertFrame(&activeListener->iStatus, *theImageFrame);
       
   759     CActiveScheduler::Start();
       
   760 
       
   761     err = activeListener->iStatus.Int();
       
   762     if (err != KErrNone)
       
   763         {
       
   764         ERR_PRINTF2(_L("Error during Decoding of the file: %S"), &theSourceFilename);
       
   765         User::Leave(err);
       
   766         }
       
   767         
       
   768     // Encode //
       
   769     
       
   770 	// Create the destination filename from the source filename
       
   771 	TBuf<KLenBuffer> theExtension;
       
   772 
       
   773 	Directory(EOutput, iFileNameDest);
       
   774 	iFileNameDest.Append(aFileName.Left(aFileName.Length() - 4));
       
   775 	iFileNameDest.Append(_L("_OUT."));
       
   776 
       
   777 	GetImageExtension(iImageTypeUid, theExtension);
       
   778 	iFileNameDest.Append(theExtension);
       
   779 	
       
   780 	// Create an object of CJPEGImageFrameEncoder
       
   781     CJPEGImageFrameEncoder* imageEncoder = NULL;
       
   782 	TRAP(err, imageEncoder = static_cast<CJPEGImageFrameEncoder*>( CImageEncoder::FileNewL(iFs, iFileNameDest, CImageEncoder::EOptionNone, KNullUid, KNullUid, KImageFramePluginUid)));
       
   783 
       
   784 	if (err != KErrNone)
       
   785 		{
       
   786 		ERR_PRINTF3(_L("Error during creating Image Encoder UId %d to file %S" ), iImageTypeUid, &iFileNameDest);
       
   787 		if (err == KErrPathNotFound)
       
   788     		{
       
   789     		ERR_PRINTF2(_L("Path %S not found" ), &iFileNameDest); 
       
   790     		}
       
   791 		if (err == KErrAccessDenied)
       
   792     		{
       
   793     		ERR_PRINTF1(_L("Access denied" )); 
       
   794     		}
       
   795 		return err;
       
   796 		}
       
   797 	CleanupStack::PushL(imageEncoder);
       
   798 	
       
   799 	// Create CFrameImageData 
       
   800     CFrameImageData* frameImageData = CFrameImageData::NewL();
       
   801     CleanupStack::PushL(frameImageData);
       
   802         
       
   803     TJpegImageData* jpegFormat = new(ELeave) TJpegImageData;
       
   804 	CleanupStack::PushL(jpegFormat);
       
   805 
       
   806 	jpegFormat->iSampleScheme = TJpegImageData::EColor420;
       
   807 	jpegFormat->iQualityFactor = 100;
       
   808 	User::LeaveIfError(frameImageData->AppendImageData(jpegFormat));
       
   809 	CleanupStack::Pop(jpegFormat);
       
   810 
       
   811     // Create CActiveListener
       
   812 	CActiveListener* activeEncodeListener = new(ELeave)CActiveListener;
       
   813 	CleanupStack::PushL( activeEncodeListener );
       
   814 
       
   815 	iActiveScheduler->SetEncoder(imageEncoder, activeEncodeListener, 0);
       
   816 	iActiveScheduler->SetStep(this);
       
   817 
       
   818 	activeEncodeListener->InitialiseActiveListener();
       
   819   
       
   820 	// Do the Encode from YUV to JPEG
       
   821 	imageEncoder->ConvertFrame(&activeEncodeListener->iStatus, *theImageFrame, frameImageData);
       
   822 	CActiveScheduler::Start();
       
   823 
       
   824 	err = activeEncodeListener->iStatus.Int();
       
   825 	iActiveScheduler->ResetValues();
       
   826     
       
   827     if (err != KErrNone)
       
   828 		{
       
   829 		ERR_PRINTF1(_L("Error during conversion"));
       
   830 		return err;
       
   831 		}
       
   832 	
       
   833 	// Cleanup
       
   834 	CleanupStack::PopAndDestroy(7, imageDecoder); 
       
   835 	
       
   836     //compare two file into a flat buffer
       
   837 	TInt fileSize;
       
   838 	
       
   839 	iFile.Open(iFs, iFileNameDest, EFileRead);
       
   840 	
       
   841 	CleanupClosePushL(iFile);
       
   842 	
       
   843 	iFile.Size(fileSize);
       
   844 	HBufC8 *theCreatedImage = HBufC8::NewMaxLC(fileSize);
       
   845 
       
   846 	TPtr8 imageFromFilePtr = theCreatedImage->Des();
       
   847 	iFile.Read(imageFromFilePtr);
       
   848 	iFile.Close();
       
   849 
       
   850 	err = CompareFileL(aFileName, theCreatedImage, iImageTypeUid, EReference); 
       
   851     User::LeaveIfError(err);
       
   852     
       
   853 	// Cleanup
       
   854 	CleanupStack::PopAndDestroy(2);
       
   855 	
       
   856     return err;
       
   857     }
       
   858 
       
   859 /**
       
   860 *
       
   861 * EnquireYUVDecoderPluginUIDL
       
   862 * MM-ICL-FRM-I-1006-LP
       
   863 *
       
   864 */
       
   865 
       
   866 
       
   867 TInt CTestStepYUVConversion::EnquireYUVDecoderPluginUIDL(const TDesC& aFileName)
       
   868 	{
       
   869 	
       
   870 	User::LeaveIfError(iFs.Connect());
       
   871     
       
   872     // - Load from File
       
   873 	TFileName	theSourceFilename;
       
   874 	Directory(EInput, theSourceFilename);
       
   875 	theSourceFilename.Append(aFileName);
       
   876 
       
   877 	CJPEGImageFrameDecoder* imageDecoder = NULL;
       
   878 	TRAPD(err, imageDecoder = static_cast<CJPEGImageFrameDecoder*>( CImageDecoder::FileNewL(iFs, theSourceFilename, CImageDecoder::EOptionNone, KNullUid, KNullUid, KImageFramePluginUid)));
       
   879 	
       
   880     if (err != KErrNone)
       
   881 	    {
       
   882 	    INFO_PRINTF3(_L("Cannot open file: %S. Unexpected Error: %d"), &theSourceFilename, err);
       
   883 	    return err;
       
   884 	    }
       
   885     
       
   886 	if (imageDecoder == NULL)
       
   887         {
       
   888         INFO_PRINTF1(_L("ImageDecoder is NULL!"));
       
   889         return err;
       
   890         }
       
   891     CleanupStack::PushL(imageDecoder);
       
   892 
       
   893 	TUid uid1 = imageDecoder->ImplementationUid();
       
   894 	INFO_PRINTF3(_L("UID of ImageDecoder loaded from file %S = 0x%08x\n"), &theSourceFilename, uid1);
       
   895 	if (uid1 == KTestImageFramePluginUid)
       
   896 	{
       
   897 	INFO_PRINTF2(_L("UID of ImageDecoder loaded from buffer is valid"),uid1);
       
   898 	}
       
   899 		
       
   900 	CleanupStack::PopAndDestroy(1);
       
   901 	
       
   902 	// - Load from Descriptor
       
   903 	TInt fileSize;
       
   904 
       
   905 	iFile.Open(iFs, theSourceFilename, EFileRead);
       
   906 	iFile.Size(fileSize);
       
   907 	HBufC8 *theImageFromFile = HBufC8::NewMaxLC(fileSize);
       
   908 
       
   909 	TPtr8 imageFromFilePtr = theImageFromFile->Des();
       
   910 	iFile.Read(imageFromFilePtr);
       
   911 	iFile.Close();
       
   912 	
       
   913 	TRAP(err, imageDecoder = static_cast<CJPEGImageFrameDecoder *>(CImageDecoder::DataNewL(iFs, imageFromFilePtr)));
       
   914 	if(imageDecoder == NULL)
       
   915 		{
       
   916 		return KErrUnknown;
       
   917 		}
       
   918 		
       
   919 	CleanupStack::PushL(imageDecoder);
       
   920 	
       
   921 	uid1 = imageDecoder->ImplementationUid();
       
   922 	INFO_PRINTF2(_L("UID of ImageDecoder loaded from buffer = 0x%08x\n"), uid1);
       
   923 	
       
   924 	if (uid1 == KTestImageFramePluginUid)
       
   925 	{
       
   926 	INFO_PRINTF1(_L("UID of ImageDecoder loaded from buffer is valid"));
       
   927 	}
       
   928 
       
   929     // Clean-up
       
   930 	 //imageDecoder, theImageFromFile
       
   931 	CleanupStack::PopAndDestroy(2, theImageFromFile);
       
   932 	return err;
       
   933 	}
       
   934 
       
   935 /* 
       
   936  *
       
   937  * Enquire UID of a loaded encoder 
       
   938  * MM-ICL-FRM-I-1006-LP
       
   939  *
       
   940  */
       
   941  
       
   942  
       
   943 TInt CTestStepYUVConversion::EnquireYUVEncoderPluginUIDL(const TDesC& aFileName)
       
   944 	{
       
   945 
       
   946 	User::LeaveIfError(iFs.Connect());
       
   947 
       
   948 	TFileName	iFileNameDest;
       
   949 	Directory(EInput, iFileNameDest);
       
   950 	iFileNameDest.Append(aFileName);
       
   951 	
       
   952 	CJPEGImageFrameDecoder* imageEncoder = NULL;
       
   953 	TRAPD(err, imageEncoder = static_cast<CJPEGImageFrameDecoder*>( CImageDecoder::FileNewL(iFs, iFileNameDest, CImageDecoder::EOptionNone, KNullUid, KNullUid, KImageFramePluginUid)));
       
   954 
       
   955 	if (err != KErrNone)
       
   956 		{
       
   957 		INFO_PRINTF2(_L("Cannot create file with Uid  = 0x%08x\n"), iImageTypeUid);
       
   958 		if (err == KErrPathNotFound)
       
   959 			{
       
   960 			INFO_PRINTF2(_L("Path %S not found"), &iFileNameDest);
       
   961 			}
       
   962 		return err;
       
   963 		}
       
   964 	CleanupStack::PushL(imageEncoder);	
       
   965 	
       
   966 	TUid uid1 = imageEncoder->ImplementationUid();
       
   967 	INFO_PRINTF3(_L("UID of ImageEncoder loaded by file %S = 0x%08x\n"), &iFileNameDest, uid1);
       
   968 	if (uid1 == KTestImageFramePluginUid)
       
   969 	{
       
   970 	INFO_PRINTF1(_L("UID of ImageEncoder loaded from buffer is valid"));
       
   971 	}
       
   972 
       
   973 	CleanupStack::PopAndDestroy(imageEncoder);
       
   974 	return err;
       
   975 	}
       
   976 
       
   977 /* 
       
   978  *
       
   979  * ListYUVDecoderSupportedFormats
       
   980  * MM-ICL-FRM-I-1007-CP
       
   981  *
       
   982  */
       
   983  
       
   984  
       
   985 TInt CTestStepYUVConversion::ListYUVDecoderSupportedFormats()
       
   986 	{
       
   987 	TInt	err;
       
   988 	RFileExtensionMIMETypeArray	theFileExtensionArray;
       
   989 	
       
   990 	TRAP(err, CJPEGImageFrameDecoder::GetFileTypesL(theFileExtensionArray));	
       
   991 	
       
   992 	if (err != KErrNone)
       
   993 		{
       
   994 		theFileExtensionArray.ResetAndDestroy();
       
   995 		return err;
       
   996 		}
       
   997 
       
   998 	
       
   999 	INFO_PRINTF1(_L("A List of imageDecoder file extensions and MIME types"));
       
  1000 	
       
  1001 	for (TInt index=0; index<theFileExtensionArray.Count(); index++)
       
  1002 		{
       
  1003 		CFileExtensionMIMEType& fileExtAndMIMEType = *theFileExtensionArray[index];
       
  1004 		
       
  1005 		const TDesC& extension = fileExtAndMIMEType.FileExtension();
       
  1006 		const TDesC8& mimeType = fileExtAndMIMEType.MIMEType();
       
  1007 		TBuf<KLenBuffer>	mimeType16;
       
  1008 
       
  1009 		mimeType16.Copy(mimeType);
       
  1010 		
       
  1011 		INFO_PRINTF3(_L("Extension : %S, MIME Type : %S"), &extension, &mimeType16);
       
  1012 		
       
  1013 		}
       
  1014 	
       
  1015 	theFileExtensionArray.ResetAndDestroy();
       
  1016 	
       
  1017 	return err;
       
  1018 	}
       
  1019 
       
  1020 
       
  1021 /* 
       
  1022  *
       
  1023  * ListYUVEncoderSupportedFormats
       
  1024  * MM-ICL-FRM-I-1007-CP
       
  1025  *
       
  1026  */
       
  1027 TInt CTestStepYUVConversion::ListYUVEncoderSupportedFormats()
       
  1028 	{
       
  1029 	TInt	err = KErrNone;
       
  1030 	
       
  1031 	RFileExtensionMIMETypeArray	theFileExtensionArray;
       
  1032 
       
  1033 	TRAP(err, CJPEGImageFrameEncoder::GetFileTypesL(theFileExtensionArray));	
       
  1034 	
       
  1035 	if (err != KErrNone)
       
  1036 		{
       
  1037 		theFileExtensionArray.ResetAndDestroy();
       
  1038 		return err;
       
  1039 		}
       
  1040 	INFO_PRINTF1(_L("\n"));
       
  1041 	INFO_PRINTF1(_L("A List of encoder file extensions and MIME types"));
       
  1042 	
       
  1043 	for (TInt index=0; index<theFileExtensionArray.Count(); index++)
       
  1044 		{
       
  1045 		CFileExtensionMIMEType& fileExtAndMIMEType = *theFileExtensionArray[index];
       
  1046 		
       
  1047 		const TDesC& extension = fileExtAndMIMEType.FileExtension();
       
  1048 		const TDesC8& mimeType = fileExtAndMIMEType.MIMEType();
       
  1049 		TBuf<KLenBuffer> mimeType16;
       
  1050 
       
  1051 		mimeType16.Copy(mimeType);
       
  1052 		
       
  1053 		INFO_PRINTF3(_L("Extension: %S, MIME Type : %S") , &extension, &mimeType16);
       
  1054 		
       
  1055 		}
       
  1056 	theFileExtensionArray.ResetAndDestroy();
       
  1057 	
       
  1058 	return err; 
       
  1059 	}
       
  1060 
       
  1061 
       
  1062 //
       
  1063 // NEGATIVE TESTS
       
  1064 //
       
  1065 
       
  1066 /* 
       
  1067  * YUVEncodeUnsupportedFrameL
       
  1068  * MM-ICL-FRM-I-1112-CP
       
  1069  *
       
  1070  */
       
  1071 
       
  1072 TInt CTestStepYUVConversion::YUVEncodeUnsupportedFrameL(const TDesC& aFileName)
       
  1073 	{
       
  1074 		 // Get the path
       
  1075     TFileName theSourceFilename;
       
  1076     Directory(EInput, theSourceFilename);
       
  1077     theSourceFilename.Append(aFileName);
       
  1078 
       
  1079     User::LeaveIfError(iFs.Connect());
       
  1080 
       
  1081     INFO_PRINTF2(_L("Opening the file %S for "), &theSourceFilename);
       
  1082     
       
  1083     // Open the image and create an image imageDecoder
       
  1084     CJPEGImageFrameDecoder* imageDecoder = NULL;
       
  1085 	TRAPD(err,imageDecoder = static_cast<CJPEGImageFrameDecoder*>( CImageDecoder::FileNewL(iFs, theSourceFilename, CImageDecoder::EOptionNone, KNullUid, KNullUid, KImageFramePluginUid)));
       
  1086 	    
       
  1087     if (err != KErrNone)
       
  1088         {
       
  1089         INFO_PRINTF3(_L("Cannot open file: %S. Unexpected Error: %d"), &theSourceFilename, err);
       
  1090         User::Leave(err);
       
  1091         }
       
  1092 
       
  1093     if (imageDecoder == NULL)
       
  1094         {
       
  1095         INFO_PRINTF1(_L("ImageDecoder is NULL!"));
       
  1096         User::Leave(err);
       
  1097         }
       
  1098     CleanupStack::PushL(imageDecoder);
       
  1099 	
       
  1100 	INFO_PRINTF2_IF_LOGS_ENABLED(_L("The file %S had been opened."), &theSourceFilename);
       
  1101     
       
  1102     	// create destination RChunk
       
  1103 	RChunk chunk;
       
  1104 	TInt imageSizeInBytes;
       
  1105 	TBool supported = imageDecoder->RecommendedBufferSize(imageSizeInBytes);
       
  1106 	if (supported == EFalse)
       
  1107 		{
       
  1108 		INFO_PRINTF1(_L("Codec does not support this image format"));		
       
  1109 		User::Leave(KErrNotSupported);
       
  1110 		}
       
  1111 		
       
  1112 	TInt res = chunk.CreateGlobal(_L("aRchunkICL"), imageSizeInBytes, imageSizeInBytes, EOwnerProcess);	
       
  1113 	User::LeaveIfError(res);
       
  1114 	
       
  1115 	CleanupClosePushL(chunk);
       
  1116   		
       
  1117 	// create an empty imageframe   
       
  1118   	CImageFrame* theImageFrame = NULL;
       
  1119 	TRAP(err, theImageFrame = CImageFrame::NewL(&chunk, imageSizeInBytes,KRChunkSize));
       
  1120 	if (err != KErrNone)
       
  1121 		{
       
  1122 		INFO_PRINTF2(_L("Could not do Create imageFrame"),err);
       
  1123 		if (theImageFrame)
       
  1124 			{
       
  1125 			delete theImageFrame;
       
  1126 			}
       
  1127 		User::Leave(err);
       
  1128 		}
       
  1129 		CleanupStack::PushL(theImageFrame);
       
  1130 	
       
  1131 	// Create an active listener and push it on the cleanup stack
       
  1132     CActiveListener* activeListener = new (ELeave) CActiveListener;
       
  1133     CleanupStack::PushL(activeListener);
       
  1134     activeListener->InitialiseActiveListener();
       
  1135     
       
  1136     // Decode the image
       
  1137     imageDecoder->ConvertFrame(&activeListener->iStatus, *theImageFrame);
       
  1138     CActiveScheduler::Start();
       
  1139 
       
  1140     err = activeListener->iStatus.Int();
       
  1141     if (err != KErrNone)
       
  1142         {
       
  1143         ERR_PRINTF2(_L("Error during Decoding of the file: %S"), &theSourceFilename);
       
  1144         User::Leave(err);
       
  1145         }
       
  1146         
       
  1147     // ENCODING //
       
  1148 	// Create the destination filename from the source filename
       
  1149 	
       
  1150 	TBuf<KLenBuffer> theExtension;
       
  1151 
       
  1152 	Directory(EOutput, iFileNameDest);
       
  1153 	iFileNameDest.Append(aFileName.Left(aFileName.Length() - 4));
       
  1154 	iFileNameDest.Append(_L("_OUT."));
       
  1155 
       
  1156 	GetImageExtension(iImageTypeUid, theExtension);
       
  1157 	iFileNameDest.Append(theExtension);
       
  1158 	
       
  1159 	// Create an object of CJPEGImageFrameEncoder
       
  1160 	CJPEGImageFrameEncoder* imageEncoder = NULL;
       
  1161 	TRAP(err, 
       
  1162 	    imageEncoder = static_cast<CJPEGImageFrameEncoder*>( CImageEncoder::FileNewL(iFs, iFileNameDest, CImageEncoder::EOptionNone, KNullUid, KNullUid, KImageFramePluginUid)));
       
  1163     
       
  1164     if (err != KErrNone)
       
  1165 		{
       
  1166 		ERR_PRINTF3(_L("Error during creating Image Encoder UId %d to file %S" ), KImageTypeGIFUid, &iFileNameDest);
       
  1167 		if (err == KErrPathNotFound)
       
  1168     		{
       
  1169     		ERR_PRINTF2(_L("Path %S not found" ), &iFileNameDest); 
       
  1170     		}
       
  1171 		
       
  1172 		if (err == KErrAccessDenied)
       
  1173     		{
       
  1174     		ERR_PRINTF1(_L("Access denied" )); 
       
  1175     		}
       
  1176 		User::Leave(err);
       
  1177 		}
       
  1178 	CleanupStack::PushL(imageEncoder);
       
  1179     
       
  1180     // Create CFrameImageData 
       
  1181     CFrameImageData* frameImageData = CFrameImageData::NewL();
       
  1182     CleanupStack::PushL(frameImageData);
       
  1183 		
       
  1184     TJpegImageData* jpegFormat = new(ELeave) TJpegImageData;
       
  1185 	CleanupStack::PushL(jpegFormat);
       
  1186 
       
  1187 	jpegFormat->iSampleScheme = TJpegImageData::EColor444;
       
  1188 	User::LeaveIfError(frameImageData->AppendImageData(jpegFormat));
       
  1189 	CleanupStack::Pop(jpegFormat);
       
  1190 	
       
  1191     // Create CActiveListener
       
  1192 	CActiveListener* activeEncodeListener = new(ELeave)CActiveListener;
       
  1193 	CleanupStack::PushL( activeEncodeListener );
       
  1194 
       
  1195 	iActiveScheduler->SetEncoder(imageEncoder, activeEncodeListener, 0);
       
  1196 	iActiveScheduler->SetStep(this);
       
  1197 
       
  1198 	activeEncodeListener->InitialiseActiveListener();
       
  1199 	
       
  1200 	// Do the Encode from YUV to JPEG
       
  1201 	imageEncoder->ConvertFrame(&activeEncodeListener->iStatus, *theImageFrame, frameImageData);
       
  1202 	CActiveScheduler::Start();
       
  1203 
       
  1204 	err = activeEncodeListener->iStatus.Int();
       
  1205 	iActiveScheduler->ResetValues();
       
  1206 	
       
  1207 	INFO_PRINTF2(_L("Encode an YUV to unsuppored image format returned Error : %d..."), err);
       
  1208     User::LeaveIfError(err);
       
  1209     
       
  1210     // Cleanup
       
  1211 	CleanupStack::PopAndDestroy(7, imageDecoder); //active sheduler
       
  1212 	return err; 
       
  1213 	}
       
  1214 
       
  1215 
       
  1216 /**
       
  1217  * 
       
  1218  * YUVEncodeCorruptRChunkL
       
  1219  * MM-ICL-FRM-I-1113-CP
       
  1220  *
       
  1221  */
       
  1222  
       
  1223  TInt CTestStepYUVConversion::YUVEncodeCorruptRChunkL(const TDesC& aFileName)
       
  1224 	{
       
  1225     User::LeaveIfError(iFs.Connect());
       
  1226 
       
  1227     // create destination RChunk
       
  1228 	RChunk chunk;
       
  1229 	TInt imageSizeInBytes = 1000;
       
  1230 	TInt res = chunk.CreateGlobal(_L("aRchunkICL"), imageSizeInBytes, imageSizeInBytes, EOwnerProcess);	
       
  1231 	User::LeaveIfError(res);
       
  1232 	
       
  1233 	CleanupClosePushL(chunk);
       
  1234   		
       
  1235 	// create an empty imageframe   
       
  1236   	CImageFrame* theImageFrame = NULL;
       
  1237 	TRAPD(err, theImageFrame = CImageFrame::NewL(&chunk, imageSizeInBytes,KRChunkSize));
       
  1238 	if (err != KErrNone)
       
  1239 		{
       
  1240 		INFO_PRINTF2(_L("Could not do Create imageFrame"),err);
       
  1241 		if (theImageFrame)
       
  1242 			{
       
  1243 			delete theImageFrame;
       
  1244 			}
       
  1245 		User::Leave(err);
       
  1246 		}
       
  1247 		CleanupStack::PushL(theImageFrame);
       
  1248     
       
  1249     // here we pass the RChunk as it is without decoding. So, it is Not a valid data.
       
  1250 
       
  1251     // ENCODING //
       
  1252     
       
  1253 	// Create the destination filename from the source filename
       
  1254 	TBuf<KLenBuffer> theExtension;
       
  1255 
       
  1256 	Directory(EOutput, iFileNameDest);
       
  1257 	iFileNameDest.Append(aFileName.Left(aFileName.Length() - 4));
       
  1258 	iFileNameDest.Append(_L("_OUT."));
       
  1259 
       
  1260 	GetImageExtension(iImageTypeUid, theExtension);
       
  1261 	iFileNameDest.Append(theExtension);
       
  1262 	
       
  1263 	// Create an object of CJPEGImageFrameEncoder
       
  1264 	CJPEGImageFrameEncoder* imageEncoder = NULL;
       
  1265 	TRAP(err, 
       
  1266 	    imageEncoder = static_cast<CJPEGImageFrameEncoder*>( CImageEncoder::FileNewL(iFs, iFileNameDest, CImageEncoder::EOptionNone, KNullUid, KNullUid,KImageFramePluginUid)));
       
  1267 
       
  1268 	if (err != KErrNone)
       
  1269 		{
       
  1270 		ERR_PRINTF3(_L("Error during creating Image Encoder UId %d to file %S" ), KImageTypeGIFUid, &iFileNameDest);
       
  1271 		if (err == KErrPathNotFound)
       
  1272     		{
       
  1273     		ERR_PRINTF2(_L("Path %S not found" ), &iFileNameDest); 
       
  1274     		}
       
  1275 		
       
  1276 		if (err == KErrAccessDenied)
       
  1277     		{
       
  1278     		ERR_PRINTF1(_L("Access denied" )); 
       
  1279     		}
       
  1280 		User::Leave(err);
       
  1281 		}
       
  1282 	CleanupStack::PushL(imageEncoder);
       
  1283     
       
  1284       
       
  1285     // Create CActiveListener
       
  1286 	CActiveListener* activeEncodeListener = new(ELeave)CActiveListener;
       
  1287 	CleanupStack::PushL( activeEncodeListener );
       
  1288 
       
  1289 	iActiveScheduler->SetEncoder(imageEncoder, activeEncodeListener, 0);
       
  1290 	iActiveScheduler->SetStep(this);
       
  1291 
       
  1292 	activeEncodeListener->InitialiseActiveListener();
       
  1293 	
       
  1294 	// Do the Encode from YUV to JPEG
       
  1295 	imageEncoder->ConvertFrame(&activeEncodeListener->iStatus, *theImageFrame);
       
  1296 	CActiveScheduler::Start();
       
  1297 
       
  1298 	err = activeEncodeListener->iStatus.Int();
       
  1299 	iActiveScheduler->ResetValues();
       
  1300     
       
  1301 	INFO_PRINTF2(_L("Encode an YUV to unsuppored image format returned Error : %d..."), err);
       
  1302 	User::LeaveIfError(err);
       
  1303 	
       
  1304     // Cleanup
       
  1305 	CleanupStack::PopAndDestroy(4, theImageFrame); //active sheduler
       
  1306 	return err; 
       
  1307 	}
       
  1308 
       
  1309 
       
  1310 /* 
       
  1311  * YUVEncodeCorruptDescriptorL
       
  1312  * MM-ICL-FRM-I-1114-CP
       
  1313  * 
       
  1314  */
       
  1315 
       
  1316 TInt CTestStepYUVConversion::YUVEncodeCorruptDescriptorL(const TDesC& aFileName)
       
  1317 	{
       
  1318    	User::LeaveIfError(iFs.Connect());
       
  1319 
       
  1320     // create destination Desc
       
  1321 	TInt imageSizeInBytes = 1000;
       
  1322 	HBufC8* buffer = HBufC8::NewMaxL(imageSizeInBytes);
       
  1323 	CleanupStack::PushL(buffer);
       
  1324 	TPtr8 ptr = buffer->Des();
       
  1325 
       
  1326 	// create an empty imageframe   
       
  1327   	CImageFrame* theImageFrame = NULL;
       
  1328 	TRAPD(err, theImageFrame = CImageFrame::NewL(ptr, imageSizeInBytes));
       
  1329 	if (err != KErrNone)
       
  1330 		{
       
  1331 		INFO_PRINTF1(_L("Could not do Create imageFrame"));
       
  1332 		if (theImageFrame)
       
  1333 			{
       
  1334 			delete theImageFrame;
       
  1335 			}
       
  1336 		User::Leave(err);
       
  1337 		}
       
  1338 		CleanupStack::PushL(theImageFrame);
       
  1339 
       
  1340 	// here we pass the Descriptor frame as it is without decoding. So, it is Not a valid data.
       
  1341 	
       
  1342     // ENCODING //
       
  1343     
       
  1344 	// Create the destination filename from the source filename
       
  1345 	
       
  1346 	TBuf<KLenBuffer> theExtension;
       
  1347 
       
  1348 	Directory(EOutput, iFileNameDest);
       
  1349 	iFileNameDest.Append(aFileName.Left(aFileName.Length() - 4));
       
  1350 	iFileNameDest.Append(_L("_OUT."));
       
  1351 
       
  1352 	GetImageExtension(iImageTypeUid, theExtension);
       
  1353 	iFileNameDest.Append(theExtension);
       
  1354 	
       
  1355 	// Create an object of CJPEGImageFrameEncoder
       
  1356 	CJPEGImageFrameEncoder* imageEncoder = NULL;
       
  1357 	TRAP(err, 
       
  1358 	    imageEncoder = static_cast<CJPEGImageFrameEncoder*>( CImageEncoder::FileNewL(iFs, iFileNameDest, CImageEncoder::EOptionNone, KNullUid, KNullUid, KImageFramePluginUid)));
       
  1359 
       
  1360 	if (err != KErrNone)
       
  1361 		{
       
  1362 		ERR_PRINTF3(_L("Error during creating Image Encoder UId %d to file %S" ), KImageTypeGIFUid, &iFileNameDest);
       
  1363 		if (err == KErrPathNotFound)
       
  1364     		{
       
  1365     		ERR_PRINTF2(_L("Path %S not found" ), &iFileNameDest); 
       
  1366     		}
       
  1367 		
       
  1368 		if (err == KErrAccessDenied)
       
  1369     		{
       
  1370     		ERR_PRINTF1(_L("Access denied" )); 
       
  1371     		}
       
  1372 		User::Leave(err);	
       
  1373 		}
       
  1374 	CleanupStack::PushL(imageEncoder);
       
  1375     
       
  1376       
       
  1377     // Create CActiveListener
       
  1378 	CActiveListener* activeEncodeListener = new(ELeave)CActiveListener;
       
  1379 	CleanupStack::PushL( activeEncodeListener );
       
  1380 
       
  1381 	iActiveScheduler->SetEncoder(imageEncoder, activeEncodeListener, 0);
       
  1382 	iActiveScheduler->SetStep(this);
       
  1383 
       
  1384 	activeEncodeListener->InitialiseActiveListener();
       
  1385 	
       
  1386 	// Do the Encode from YUV to JPEG
       
  1387 	imageEncoder->ConvertFrame(&activeEncodeListener->iStatus, *theImageFrame);
       
  1388 	CActiveScheduler::Start();
       
  1389 
       
  1390 	err = activeEncodeListener->iStatus.Int();
       
  1391 	iActiveScheduler->ResetValues();
       
  1392     
       
  1393 	INFO_PRINTF2(_L("Encode an YUV to unsuppored image format returned Error : %d..."), err);
       
  1394 	User::LeaveIfError(err);
       
  1395 		                                                                                                                                                                                  
       
  1396     // Cleanup
       
  1397 	CleanupStack::PopAndDestroy(4, buffer);
       
  1398 	return err; 
       
  1399 	}
       
  1400 
       
  1401 /* 
       
  1402  * JPEGDecodeUnsupportedYUVL
       
  1403  * MM-ICL-FRM-I-1117-CP
       
  1404  *
       
  1405  */
       
  1406 
       
  1407 TInt CTestStepYUVConversion::JPEGDecodeUnsupportedYUVL(const TDesC& aFileName)
       
  1408 	{
       
  1409     // Get the path
       
  1410     TFileName theSourceFilename;
       
  1411     Directory(EInput, theSourceFilename);
       
  1412     theSourceFilename.Append(aFileName);
       
  1413 
       
  1414     User::LeaveIfError(iFs.Connect());
       
  1415 
       
  1416     INFO_PRINTF2(_L("Opening the file %S for "), &theSourceFilename);
       
  1417 	
       
  1418 	// Create an object of CJPEGImageFrameDecoder
       
  1419 	CJPEGImageFrameDecoder* imageDecoder = NULL;
       
  1420 	TRAPD(err, 
       
  1421 	    imageDecoder = static_cast<CJPEGImageFrameDecoder*> (CImageDecoder::FileNewL(iFs, theSourceFilename, CImageDecoder::EOptionNone, KNullUid, KNullUid, KImageFramePluginUid)));
       
  1422 
       
  1423 	if (err != KErrNone)
       
  1424 		{
       
  1425 		ERR_PRINTF3(_L("Error during creating Image imageDecoder UId %d to file %S" ), KImageTypeGIFUid, &iFileNameDest);
       
  1426 		if (err == KErrPathNotFound)
       
  1427     		{
       
  1428     		ERR_PRINTF2(_L("Path %S not found" ), &theSourceFilename); 
       
  1429     		}
       
  1430 		
       
  1431 		if (err == KErrAccessDenied)
       
  1432     		{
       
  1433     		ERR_PRINTF1(_L("Access denied" )); 
       
  1434     		}
       
  1435 		User::Leave(err);	
       
  1436 		}
       
  1437 	CleanupStack::PushL(imageDecoder);
       
  1438 
       
  1439 		// create destination RChunk
       
  1440 		RChunk chunk;
       
  1441 		TInt imageSizeInBytes;
       
  1442 		TBool supported = imageDecoder->RecommendedBufferSize(imageSizeInBytes);
       
  1443 		if (supported == EFalse)
       
  1444 		{
       
  1445 			// We want to test transcoding, create chunk anyway with a dummy size
       
  1446 			imageSizeInBytes = 1000;
       
  1447 		}
       
  1448 		
       
  1449 		TInt res = chunk.CreateGlobal(_L("aRchunkICL"), imageSizeInBytes, imageSizeInBytes, EOwnerProcess);	
       
  1450 		User::LeaveIfError(res);
       
  1451 	
       
  1452 	  	CleanupClosePushL(chunk);
       
  1453   	
       
  1454 		// create an empty imageframe   
       
  1455 		CImageFrame* theImageFrame = NULL;
       
  1456 		TRAPD(allocErr, theImageFrame =	CImageFrame::NewL(&chunk, imageSizeInBytes,KRChunkSize));
       
  1457 		if (allocErr != KErrNone)
       
  1458 			{
       
  1459 			INFO_PRINTF1(_L("Could not do Create imageFrame"));
       
  1460 			if (theImageFrame)
       
  1461 				{
       
  1462 				delete theImageFrame;
       
  1463 				}
       
  1464 			return EFail;
       
  1465 			}
       
  1466 		CleanupStack::PushL(theImageFrame);
       
  1467 
       
  1468 			TFrameFormat the444FrameFormat = TFrameFormat(KUidFormatYUV444Interleaved );
       
  1469 			theImageFrame->SetFrameFormatL(the444FrameFormat);			
       
  1470 		
       
  1471       
       
  1472     // Create CActiveListener
       
  1473 	CActiveListener* activeListener = new(ELeave)CActiveListener;
       
  1474 	CleanupStack::PushL( activeListener );
       
  1475 
       
  1476 	iActiveScheduler->SetDecoder(imageDecoder, activeListener, 0);
       
  1477 	iActiveScheduler->SetStep(this);
       
  1478 
       
  1479 	activeListener->InitialiseActiveListener();
       
  1480 	
       
  1481 	// Do the Decode from JPEG to YUV
       
  1482 	imageDecoder->ConvertFrame(&activeListener->iStatus, *theImageFrame);
       
  1483 	CActiveScheduler::Start();
       
  1484 
       
  1485 	err = activeListener->iStatus.Int();
       
  1486 	iActiveScheduler->ResetValues();
       
  1487     
       
  1488 	INFO_PRINTF2(_L("JPEG Decode to unsuppored YUV returned Error : %d..."), err);                                                                                                                                                                                  
       
  1489 	User::LeaveIfError(err);
       
  1490 	
       
  1491     // Cleanup
       
  1492 	CleanupStack::PopAndDestroy(4, imageDecoder); //active sheduler
       
  1493 	return err; 
       
  1494 	}
       
  1495 	
       
  1496 
       
  1497 /* 
       
  1498  * CorruptJPEGDecodeYUVL
       
  1499  * MM-ICL-FRM-I-1118-CP
       
  1500  *
       
  1501  */
       
  1502 
       
  1503 
       
  1504 TInt CTestStepYUVConversion::CorruptJPEGDecodeYUVL(const TDesC& aFileName)
       
  1505 	{
       
  1506     // Get the path
       
  1507     TFileName theSourceFilename;
       
  1508     Directory(EInput, theSourceFilename);
       
  1509     theSourceFilename.Append(aFileName);
       
  1510 
       
  1511     User::LeaveIfError(iFs.Connect());
       
  1512 
       
  1513     INFO_PRINTF2(_L("Opening the file %S for "), &theSourceFilename);
       
  1514 
       
  1515 	// Create an object of CJPEGImageFrameDecoder
       
  1516 	CJPEGImageFrameDecoder* imageDecoder = NULL;
       
  1517 	TRAPD(err, 
       
  1518 	    imageDecoder = static_cast<CJPEGImageFrameDecoder*>( CImageDecoder::FileNewL(iFs, theSourceFilename, CImageDecoder::EOptionNone, KNullUid, KNullUid, KImageFramePluginUid)));
       
  1519     
       
  1520     if (err != KErrNone)
       
  1521 		{
       
  1522 		ERR_PRINTF3(_L("Error during creating Image Decoder UId 0x%08x to file %S" ), KImageTypeGIFUid, &theSourceFilename);
       
  1523 		if (err == KErrPathNotFound)
       
  1524     		{
       
  1525     		ERR_PRINTF2(_L("Path %S not found" ), &theSourceFilename); 
       
  1526     		}
       
  1527 		
       
  1528 		if (err == KErrAccessDenied)
       
  1529     		{
       
  1530     		ERR_PRINTF1(_L("Access denied" )); 
       
  1531     		}
       
  1532 		User::Leave(err);	
       
  1533 		}
       
  1534 	CleanupStack::PushL(imageDecoder);
       
  1535     
       
  1536     // Cleanup
       
  1537 	CleanupStack::PopAndDestroy(4, imageDecoder); //active sheduler
       
  1538 	return err; 
       
  1539 	}
       
  1540 
       
  1541 
       
  1542 /* 
       
  1543  * CorruptJPEGDecodeDescYUVL
       
  1544  * MM-ICL-FRM-I-1119-HP
       
  1545  *
       
  1546  */
       
  1547 
       
  1548 
       
  1549 TInt CTestStepYUVConversion::CorruptJPEGDecodeDescYUVL(const TDesC& aFileName)
       
  1550 	{
       
  1551     // Get the path
       
  1552     TFileName theSourceFilename;
       
  1553     Directory(EInput, theSourceFilename);
       
  1554     theSourceFilename.Append(aFileName);
       
  1555 
       
  1556     User::LeaveIfError(iFs.Connect());
       
  1557 
       
  1558     INFO_PRINTF2(_L("Opening the file %S for "), &theSourceFilename);
       
  1559     
       
  1560 	// Pass in a corrupt Descriptor
       
  1561 	TInt fileSize;
       
  1562 
       
  1563 	iFile.Open(iFs, theSourceFilename, EFileRead);
       
  1564 	iFile.Size(fileSize);
       
  1565 	HBufC8 *theImageFromFile = HBufC8::NewMaxLC(fileSize);
       
  1566 
       
  1567 	TPtr8 imageFromFilePtr = theImageFromFile->Des();
       
  1568 	iFile.Read(imageFromFilePtr);
       
  1569 	iFile.Close();
       
  1570 		
       
  1571 	// Create an object of CJPEGImageFrameDecoder
       
  1572 	CJPEGImageFrameDecoder* imageDecoder = NULL;
       
  1573 	TRAPD(err, 
       
  1574 	imageDecoder = static_cast<CJPEGImageFrameDecoder*>( CImageDecoder::DataNewL(iFs, imageFromFilePtr, CImageDecoder::EOptionNone, KNullUid, KNullUid, KImageFramePluginUid)));
       
  1575 	
       
  1576 	if (err != KErrNone)
       
  1577 		{
       
  1578 		ERR_PRINTF3(_L("Error during creating Image Decoder UId 0x%08x to file %S" ), KImageTypeGIFUid, &theSourceFilename);
       
  1579 		if (err == KErrPathNotFound)
       
  1580     		{
       
  1581     		ERR_PRINTF2(_L("Path %S not found" ), &theSourceFilename); 
       
  1582     		}
       
  1583 		
       
  1584 		if (err == KErrAccessDenied)
       
  1585     		{
       
  1586     		ERR_PRINTF1(_L("Access denied" )); 
       
  1587     		}
       
  1588     	CleanupStack::PopAndDestroy(1);
       
  1589 		User::Leave(err);	
       
  1590 		}
       
  1591 	CleanupStack::PushL(imageDecoder);
       
  1592                                                                                                                                                                                     
       
  1593     // Cleanup
       
  1594 	CleanupStack::PopAndDestroy(5, theImageFromFile); //active sheduler
       
  1595 	return err; 
       
  1596 	}
       
  1597 
       
  1598 
       
  1599 /* 
       
  1600  * GIFDecodeYUVL
       
  1601  * MM-ICL-FRM-I-1120-HP
       
  1602  *
       
  1603  */
       
  1604 
       
  1605 TInt CTestStepYUVConversion::GIFDecodeYUVL(const TDesC& aFileName)
       
  1606 	{
       
  1607     // Get the path
       
  1608     TFileName theSourceFilename;
       
  1609     Directory(EInput, theSourceFilename);
       
  1610     theSourceFilename.Append(aFileName);
       
  1611 
       
  1612     User::LeaveIfError(iFs.Connect());
       
  1613 
       
  1614     INFO_PRINTF2(_L("Opening the file %S for "), &theSourceFilename);
       
  1615 	
       
  1616 	// Create an object of CJPEGImageFrameDecoder
       
  1617 	CJPEGImageFrameDecoder* imageDecoder = NULL;
       
  1618     TRAPD(err, 
       
  1619 	imageDecoder = static_cast<CJPEGImageFrameDecoder*>( CImageDecoder::FileNewL(iFs, theSourceFilename, CImageDecoder::EOptionNone, KNullUid, KNullUid, KImageFramePluginUid)));
       
  1620 	
       
  1621 	if (err != KErrNone)
       
  1622 		{
       
  1623 		ERR_PRINTF3(_L("Error during creating Image decoder UId 0x%08x to file %S" ), KImageTypeGIFUid, &iFileNameDest);
       
  1624 		if (err == KErrPathNotFound)
       
  1625     		{
       
  1626     		ERR_PRINTF2(_L("Path %S not found" ), &theSourceFilename); 
       
  1627     		}
       
  1628 		
       
  1629 		if (err == KErrAccessDenied)
       
  1630     		{
       
  1631     		ERR_PRINTF1(_L("Access denied" )); 
       
  1632     		}
       
  1633 		User::Leave(err);	
       
  1634 		}
       
  1635 	CleanupStack::PushL(imageDecoder);
       
  1636 	
       
  1637     // Cleanup
       
  1638 	CleanupStack::PopAndDestroy(4, imageDecoder); //active sheduler
       
  1639 	return err; 
       
  1640 	}
       
  1641 
       
  1642 /**
       
  1643 *
       
  1644 * EnableLogs()
       
  1645 *
       
  1646 * @param TBool aEnable
       
  1647 *
       
  1648 */
       
  1649 inline void CTestStepYUVConversion::EnableLogs(TBool aEnable)
       
  1650 {
       
  1651 	iEnableLogs = aEnable;	
       
  1652 }
       
  1653 //
       
  1654 // CTestConvertYUVRChunk
       
  1655 //
       
  1656 
       
  1657 /**
       
  1658  * 
       
  1659  * Class Constructor
       
  1660  *
       
  1661  */
       
  1662 CTestConvertYUVRChunk::CTestConvertYUVRChunk(const TDesC& aTestName) : 
       
  1663 		 CTestStepYUVConversion(aTestName)
       
  1664 	{
       
  1665 	
       
  1666 	}
       
  1667 
       
  1668 /**
       
  1669  * 
       
  1670  * NewL Method
       
  1671  *
       
  1672  */
       
  1673 CTestConvertYUVRChunk *CTestConvertYUVRChunk::NewL(const TDesC& aTestName)
       
  1674 	{
       
  1675 	CTestConvertYUVRChunk* self = new(ELeave) CTestConvertYUVRChunk(aTestName);
       
  1676 	return self;
       
  1677 	}
       
  1678 
       
  1679 
       
  1680 
       
  1681 /**
       
  1682  * 
       
  1683  * Do the test step.
       
  1684  * Each test step must supply an implementation for DoTestStepL.
       
  1685  *
       
  1686  */
       
  1687 TVerdict CTestConvertYUVRChunk::TestStepL()
       
  1688 	{
       
  1689     TInt err = KErrNone;
       
  1690     
       
  1691 	// Call the Encoder function, whether to file or descriptor based on the test case id.
       
  1692     if ((iTestStepName.Compare(_L("MM-ICL-FRM-I-1001-CP")) == 0) || (iTestStepName.Compare(_L("MM-ICL-FRM-I-1008-HP")) == 0))
       
  1693         {
       
  1694         INFO_PRINTF1_IF_LOGS_ENABLED(_L("Decode JPEG to YUV RChunk and Encode the YUV RChunk to a JPEG descriptor."));
       
  1695         // Decode to RChunk and Encode to a JPEG descriptor
       
  1696         TRAP(err, DecodeToRChunkAndEncodeToDescL(iFileNameSrc));    
       
  1697         }
       
  1698     else if ((iTestStepName.Compare(_L("MM-ICL-FRM-I-1002-CP")) == 0) || (iTestStepName.Compare(_L("MM-ICL-FRM-I-1009-HP")) == 0))
       
  1699         {
       
  1700         INFO_PRINTF1_IF_LOGS_ENABLED(_L("encode the YUV RChunk to a JPEG file."));
       
  1701         // Encode the YUV RChunk to a JPEG file
       
  1702         TRAP(err, DecodeToRChunkAndEncodeToFileL(iFileNameSrc));
       
  1703         }
       
  1704   
       
  1705     // Error Checking
       
  1706     if (err != KErrNone)
       
  1707         {
       
  1708         INFO_PRINTF2_IF_LOGS_ENABLED(_L("Encode FAILED with error %d..."), err);
       
  1709         User::Leave(err);
       
  1710         }
       
  1711 	return EPass;
       
  1712 	}
       
  1713 
       
  1714 /**
       
  1715  * 
       
  1716  * Do the test step.
       
  1717  * Each test step must supply an implementation for DoTestStepL.
       
  1718  *
       
  1719  */
       
  1720 TVerdict CTestConvertYUVRChunk::DoTestStepL()
       
  1721     {
       
  1722     TVerdict testResult = EPass;
       
  1723     TInt err;
       
  1724     
       
  1725     if ((iTestStepName.Compare(_L("MM-ICL-FRM-I-1001-CP")) == 0) ||
       
  1726         (iTestStepName.Compare(_L("MM-ICL-FRM-I-1002-CP")) == 0))
       
  1727         {
       
  1728         TRAP(err, testResult = TestStepL());
       
  1729         if (err != KErrNone)
       
  1730 	        {
       
  1731 	        INFO_PRINTF2(_L("Encode FAILED with error %d..."), err);
       
  1732 	        testResult = EFail;
       
  1733 	        }
       
  1734         }
       
  1735      else if ((iTestStepName.Compare(_L("MM-ICL-FRM-I-1008-HP")) == 0) ||
       
  1736         (iTestStepName.Compare(_L("MM-ICL-FRM-I-1009-HP")) == 0))
       
  1737         {
       
  1738     	//Check for Alloc Test Support
       
  1739     	__UHEAP_SETFAIL(RHeap::EFailNext, 1);
       
  1740     	TAny *testAllocSupport = User::Alloc(1);
       
  1741     	if (testAllocSupport!=NULL)
       
  1742     		{
       
  1743     		delete testAllocSupport;
       
  1744     		testAllocSupport=NULL;
       
  1745     		INFO_PRINTF1(_L("This build does not support ALLOC testing"));
       
  1746     		return EInconclusive;
       
  1747     		}
       
  1748     	
       
  1749     	//Initialise Variables
       
  1750     	TVerdict iAllocTestStepResult=EPass;
       
  1751     	TInt err = KErrNone;
       
  1752     	TBool badResult = EFalse;
       
  1753     	
       
  1754     	//>>>>>>>>>>>>>>>>>>>>>>>>Test Method Call<<<<<<<<<<<<<<<<<<<<<<<<<<
       
  1755     	INFO_PRINTF1(_L("Executing the Test Method call Outside the FOR LOOP."));
       
  1756     	TRAP(err, iAllocTestStepResult = TestStepL());
       
  1757     	if (err != KErrNone)
       
  1758     		{
       
  1759     		INFO_PRINTF2(_L("Decoding error, returned error code =  %d"), err);
       
  1760     		return EFail;
       
  1761     		}
       
  1762     	else
       
  1763     		{
       
  1764     		//Check the iAllocTestStepResult
       
  1765     		if (iAllocTestStepResult != EPass)
       
  1766     			{
       
  1767     			badResult = ETrue;
       
  1768     			}
       
  1769     		}
       
  1770     	
       
  1771     	TInt failCount = 1;
       
  1772     	TBool completed = EFalse;
       
  1773     	iAllocTestStepResult = EPass; // reinitialise
       
  1774     	TBool reachedEnd = EFalse; // Note: declare outside loop to help with debugging
       
  1775     	EnableLogs(EFalse);
       
  1776     	for(;;)	
       
  1777     		{
       
  1778     		__UHEAP_SETFAIL(RHeap::EFailNext, failCount);
       
  1779     		//__MM_HEAP_MARK;
       
  1780 
       
  1781     		//>>>>>>>>>>>>>>>>>>>>>>>>Test Method Call<<<<<<<<<<<<<<<<<<<<<<<<<<
       
  1782     		INFO_PRINTF2_IF_LOGS_ENABLED(_L("Executing the Test Method call #%d."), failCount);	
       
  1783       		TRAP(err, iAllocTestStepResult = TestStepL());
       
  1784     		
       
  1785     		completed = EFalse;
       
  1786     		if (err == KErrNone)
       
  1787     			{
       
  1788     			TAny *testAlloc = NULL;
       
  1789     			testAlloc = User::Alloc(1); // when this fails, we passed through all allocs within test
       
  1790     			if (testAlloc == NULL)
       
  1791     				{
       
  1792     				reachedEnd = ETrue;
       
  1793     				failCount -= 1;
       
  1794     				}
       
  1795     			else
       
  1796     				{
       
  1797     				User::Free(testAlloc);
       
  1798     				testAlloc=NULL;
       
  1799     				}			
       
  1800     			
       
  1801     			//Check the iAllocTestStepResult
       
  1802     			if (iAllocTestStepResult != EPass)
       
  1803     				{
       
  1804     				badResult = ETrue;
       
  1805     				}
       
  1806     			
       
  1807     			completed = reachedEnd || badResult;
       
  1808     			}
       
  1809     		else if (err != KErrNoMemory) // bad error code
       
  1810     			{
       
  1811     			completed = ETrue;
       
  1812     			badResult = EFail;
       
  1813     			}			
       
  1814 
       
  1815     		//__MM_HEAP_MARKEND;
       
  1816     		__UHEAP_SETFAIL(RHeap::ENone, 0);
       
  1817 
       
  1818     		if (completed)
       
  1819     			{
       
  1820     			break; // exit loop
       
  1821     			}
       
  1822 
       
  1823     		failCount++;
       
  1824     		}
       
  1825 
       
  1826     	//failCount -= 1; // Failcount of 1 equates to 0 successful allocs, etc
       
  1827 
       
  1828     	if (err != KErrNone || badResult)
       
  1829     		{
       
  1830     		if (badResult)
       
  1831     			{
       
  1832     			INFO_PRINTF3(_L("  Bad result with %d memory allocations tested. The Error returned is %d"), failCount, err);
       
  1833     			}
       
  1834     		else
       
  1835     			{
       
  1836     			INFO_PRINTF3(_L("  Error(%d) with %d memory allocations tested\n"), err, failCount);
       
  1837     			}
       
  1838     		iAllocTestStepResult = EFail;
       
  1839     		}
       
  1840     	else 
       
  1841     		{
       
  1842     		INFO_PRINTF2(_L("  Completed OK with %d memory allocations tested\n"), failCount);
       
  1843     		iAllocTestStepResult = EPass;
       
  1844     		}
       
  1845     		testResult = iAllocTestStepResult;
       
  1846         }
       
  1847     return testResult;
       
  1848 	}
       
  1849 
       
  1850 //
       
  1851 // CTestConvertYUVDesc
       
  1852 //
       
  1853 /**
       
  1854  * 
       
  1855  *
       
  1856  * Class Constructor
       
  1857  *
       
  1858  */
       
  1859 CTestConvertYUVDesc::CTestConvertYUVDesc(const TDesC& aTestName) : 
       
  1860 		 CTestStepYUVConversion(aTestName)
       
  1861 	{
       
  1862 	
       
  1863 	}
       
  1864 
       
  1865 /**
       
  1866  * 
       
  1867  *
       
  1868  * NewL Method
       
  1869  *
       
  1870  */
       
  1871 CTestConvertYUVDesc *CTestConvertYUVDesc::NewL(const TDesC& aTestName)
       
  1872 	{
       
  1873 	CTestConvertYUVDesc* self = new(ELeave) CTestConvertYUVDesc(aTestName);
       
  1874 	return self;
       
  1875 	}
       
  1876 
       
  1877 /**
       
  1878  * 
       
  1879  *
       
  1880  * DoTestStepL Method
       
  1881  *
       
  1882  */
       
  1883 TVerdict CTestConvertYUVDesc::TestStepL()
       
  1884 	{
       
  1885     TInt err = KErrNone;
       
  1886     
       
  1887     // Call the Encoder function, whether to file or descriptor based on the test case id.
       
  1888     if ((iTestStepName.Compare(_L("MM-ICL-FRM-I-1003-CP")) == 0) || (iTestStepName.Compare(_L("MM-ICL-FRM-I-1010-HP")) == 0))
       
  1889         {
       
  1890         INFO_PRINTF1_IF_LOGS_ENABLED(_L("Decode to YUV Desc and Encode to a JPEG descriptor."));
       
  1891         // Encode the YUV RChunk to a JPEG descriptor
       
  1892         TRAP(err, DecodeToDescAndEncodeToDescL(iFileNameSrc));
       
  1893         }
       
  1894     else if ((iTestStepName.Compare(_L("MM-ICL-FRM-I-1004-CP")) == 0) || (iTestStepName.Compare(_L("MM-ICL-FRM-I-1011-HP")) == 0))
       
  1895         {
       
  1896         INFO_PRINTF1_IF_LOGS_ENABLED(_L("Decode to YUV Desc and Encode to a JPEG file."));
       
  1897         // Encode the YUV RChunk to a JPEG descriptor
       
  1898         TRAP(err, DecodeToDescAndEncodeToFileL(iFileNameSrc));
       
  1899         }
       
  1900     
       
  1901     // Error Checking
       
  1902     if (err != KErrNone)
       
  1903         {
       
  1904         INFO_PRINTF2_IF_LOGS_ENABLED(_L("Encode FAILED with error %d..."), err);
       
  1905         User::Leave(err);
       
  1906         }
       
  1907 	return EPass;
       
  1908 	}
       
  1909 
       
  1910 /**
       
  1911  * 
       
  1912  *
       
  1913  * DoTestStepL Method
       
  1914  *
       
  1915  */
       
  1916 TVerdict CTestConvertYUVDesc::DoTestStepL()
       
  1917 	{
       
  1918 	TVerdict testResult = EPass;
       
  1919     if ((iTestStepName.Compare(_L("MM-ICL-FRM-I-1003-CP")) == 0) ||
       
  1920         (iTestStepName.Compare(_L("MM-ICL-FRM-I-1004-CP")) == 0))
       
  1921         {
       
  1922         testResult = TestStepL();
       
  1923         }
       
  1924      else if ((iTestStepName.Compare(_L("MM-ICL-FRM-I-1010-HP")) == 0) ||
       
  1925         (iTestStepName.Compare(_L("MM-ICL-FRM-I-1011-HP")) == 0))
       
  1926         {
       
  1927     	//Check for Alloc Test Support
       
  1928     	__UHEAP_SETFAIL(RHeap::EFailNext, 1);
       
  1929     	TAny *testAllocSupport = User::Alloc(1);
       
  1930     	if (testAllocSupport!=NULL)
       
  1931     		{
       
  1932     		delete testAllocSupport;
       
  1933     		testAllocSupport=NULL;
       
  1934     		INFO_PRINTF1(_L("This build does not support ALLOC testing"));
       
  1935     		return EInconclusive;
       
  1936     		}
       
  1937     	
       
  1938     	//Initialise Variables
       
  1939     	TVerdict iAllocTestStepResult=EPass;
       
  1940     	TInt err = KErrNone;
       
  1941     	TBool badResult = EFalse;
       
  1942     	
       
  1943     	//>>>>>>>>>>>>>>>>>>>>>>>>Test Method Call<<<<<<<<<<<<<<<<<<<<<<<<<<
       
  1944     	INFO_PRINTF1(_L("Executing the Test Method call Outside the FOR LOOP."));
       
  1945     	TRAP(err, iAllocTestStepResult = TestStepL());
       
  1946     	if (err != KErrNone)
       
  1947     		{
       
  1948     		INFO_PRINTF2(_L("Decoding error, returned error code =  %d"), err);
       
  1949     		return EFail;
       
  1950     		}
       
  1951     	else
       
  1952     		{
       
  1953     		//Check the iAllocTestStepResult
       
  1954     		if (iAllocTestStepResult != EPass)
       
  1955     			{
       
  1956     			badResult = ETrue;
       
  1957     			}
       
  1958     		}
       
  1959     	
       
  1960     	TInt failCount = 1;
       
  1961     	TBool completed = EFalse;
       
  1962     	iAllocTestStepResult = EPass; // reinitialise
       
  1963     	TBool reachedEnd = EFalse; // Note: declare outside loop to help with debugging
       
  1964     	EnableLogs(EFalse);
       
  1965     	for(;;)	
       
  1966     		{
       
  1967     		__UHEAP_SETFAIL(RHeap::EFailNext, failCount);
       
  1968     		//__MM_HEAP_MARK;
       
  1969 
       
  1970     		//>>>>>>>>>>>>>>>>>>>>>>>>Test Method Call<<<<<<<<<<<<<<<<<<<<<<<<<<
       
  1971     		INFO_PRINTF2_IF_LOGS_ENABLED(_L("Executing the Test Method call #%d."), failCount);
       
  1972     		TRAP(err, iAllocTestStepResult = TestStepL());
       
  1973     		
       
  1974     		completed = EFalse;
       
  1975     		if (err == KErrNone)
       
  1976     			{
       
  1977     			TAny *testAlloc = NULL;
       
  1978     			testAlloc = User::Alloc(1); // when this fails, we passed through all allocs within test
       
  1979     			if (testAlloc == NULL)
       
  1980     				{
       
  1981     				reachedEnd = ETrue;
       
  1982     				failCount -= 1;
       
  1983     				}
       
  1984     			else
       
  1985     				{
       
  1986     				User::Free(testAlloc);
       
  1987     				testAlloc=NULL;
       
  1988     				}			
       
  1989     			
       
  1990     			//Check the iAllocTestStepResult
       
  1991     			if (iAllocTestStepResult != EPass)
       
  1992     				{
       
  1993     				badResult = ETrue;
       
  1994     				}
       
  1995     			
       
  1996     			completed = reachedEnd || badResult;
       
  1997     			}
       
  1998     		else if (err != KErrNoMemory) // bad error code
       
  1999     			{
       
  2000     			completed = ETrue;
       
  2001     			badResult = EFail;
       
  2002     			}			
       
  2003 
       
  2004     		//__MM_HEAP_MARKEND;
       
  2005     		__UHEAP_SETFAIL(RHeap::ENone, 0);
       
  2006 
       
  2007     		if (completed)
       
  2008     			{
       
  2009     			break; // exit loop
       
  2010     			}
       
  2011 
       
  2012     		failCount++;
       
  2013     		}
       
  2014 
       
  2015     	//failCount -= 1; // Failcount of 1 equates to 0 successful allocs, etc
       
  2016 
       
  2017     	if (err != KErrNone || badResult)
       
  2018     		{
       
  2019     		if (badResult)
       
  2020     			{
       
  2021     			INFO_PRINTF3(_L("  Bad result with %d memory allocations tested. The Error returned is %d"), failCount, err);
       
  2022     			}
       
  2023     		else
       
  2024     			{
       
  2025     			INFO_PRINTF3(_L("  Error(%d) with %d memory allocations tested\n"), err, failCount);
       
  2026     			}
       
  2027     		iAllocTestStepResult = EFail;
       
  2028     		}
       
  2029     	else 
       
  2030     		{
       
  2031     		INFO_PRINTF2(_L("  Completed OK with %d memory allocations tested\n"), failCount);
       
  2032     		iAllocTestStepResult = EPass;
       
  2033     		}
       
  2034     		testResult = iAllocTestStepResult;
       
  2035         }
       
  2036         return testResult;
       
  2037 	}
       
  2038 
       
  2039 
       
  2040 //
       
  2041 // CTestCSEncodeYUVExtraParams
       
  2042 //
       
  2043 
       
  2044 /**
       
  2045  *
       
  2046  * Class Constructor
       
  2047  *
       
  2048  */
       
  2049 CTestCSEncodeYUVExtraParams::CTestCSEncodeYUVExtraParams(const TDesC& aTestName) : 
       
  2050 		 CTestStepYUVConversion(aTestName)
       
  2051 	{
       
  2052 	
       
  2053 	}
       
  2054 
       
  2055 /**
       
  2056  * 
       
  2057  * NewL Method
       
  2058  *
       
  2059  */
       
  2060 CTestCSEncodeYUVExtraParams *CTestCSEncodeYUVExtraParams::NewL(const TDesC& aTestName)
       
  2061 	{
       
  2062 	CTestCSEncodeYUVExtraParams* self = new(ELeave) CTestCSEncodeYUVExtraParams(aTestName);
       
  2063 	return self;
       
  2064 	}
       
  2065 
       
  2066 /**
       
  2067  *
       
  2068  * DoTestStepL Method
       
  2069  *
       
  2070  */
       
  2071 TVerdict CTestCSEncodeYUVExtraParams::DoTestStepL()
       
  2072 	{
       
  2073     TInt err1 = KErrNone;
       
  2074     
       
  2075     // Decode a Jpeg file to YUV Descriptor
       
  2076     TRAPD(err, err1 = DecodeToRChunkAndEncodeToFileXtraParamsL(iFileNameSrc));
       
  2077 	if (err1 != KErrNone)
       
  2078 		{
       
  2079 		err = err1;
       
  2080 		}
       
  2081 	
       
  2082     // Error Checking
       
  2083     if (err != KErrNone)
       
  2084         {
       
  2085         INFO_PRINTF2(_L("Conversion Failed with error %d..."), err);
       
  2086         return EFail;
       
  2087         }
       
  2088     return EPass;  
       
  2089 	}
       
  2090 
       
  2091 
       
  2092 /**
       
  2093  * 
       
  2094  *
       
  2095  * Class Constructor
       
  2096  *
       
  2097  */
       
  2098 CTestCSGetPluginUID::CTestCSGetPluginUID(const TDesC& aTestName) : 
       
  2099 		 CTestStepYUVConversion(aTestName)
       
  2100 	{
       
  2101 	
       
  2102 	}
       
  2103 
       
  2104 /**
       
  2105  * 
       
  2106  *
       
  2107  * NewL Method
       
  2108  *
       
  2109  */
       
  2110 CTestCSGetPluginUID *CTestCSGetPluginUID::NewL(const TDesC& aTestName)
       
  2111 	{
       
  2112 	CTestCSGetPluginUID* self = new(ELeave) CTestCSGetPluginUID(aTestName);
       
  2113 	return self;
       
  2114 	}
       
  2115 
       
  2116 /**
       
  2117  * 
       
  2118  *
       
  2119  * DoTestStepL Method
       
  2120  *
       
  2121  */
       
  2122 TVerdict CTestCSGetPluginUID::DoTestStepL()
       
  2123 	{
       
  2124 	TInt err = KErrNone;
       
  2125     
       
  2126     // Enquire the encoder UID
       
  2127     TRAP(err, EnquireYUVDecoderPluginUIDL(iFileNameSrc));
       
  2128     if (err != KErrNone)
       
  2129         {
       
  2130         INFO_PRINTF2(_L("Enquire the imageDecoder UID FAILED with error %d..."), err);
       
  2131         return EFail;
       
  2132         }
       
  2133           
       
  2134     // Enquire about the encoder UID
       
  2135     TRAP(err, EnquireYUVEncoderPluginUIDL(iFileNameSrc));
       
  2136     if (err != KErrNone)
       
  2137         {
       
  2138         INFO_PRINTF2(_L("Enquire the Encoder UID FAILED with error %d..."), err);
       
  2139         return EFail;
       
  2140         }
       
  2141     return EPass;
       
  2142 	}
       
  2143 
       
  2144 /**
       
  2145  * 
       
  2146  *
       
  2147  * Class Constructor
       
  2148  *
       
  2149  */
       
  2150 CTestCSGetSupportedYUVFormats::CTestCSGetSupportedYUVFormats(const TDesC& aTestName) : 
       
  2151 		 CTestStepYUVConversion(aTestName)
       
  2152 	{
       
  2153 	
       
  2154 	}
       
  2155 
       
  2156 /**
       
  2157  * 
       
  2158  *
       
  2159  * NewL Method
       
  2160  *
       
  2161  */
       
  2162 CTestCSGetSupportedYUVFormats *CTestCSGetSupportedYUVFormats::NewL(const TDesC& aTestName)
       
  2163 	{
       
  2164 	CTestCSGetSupportedYUVFormats* self = new(ELeave) CTestCSGetSupportedYUVFormats(aTestName);
       
  2165 	return self;
       
  2166 	}
       
  2167 
       
  2168 /**
       
  2169  * 
       
  2170  *
       
  2171  * DoTestStepL Method
       
  2172  *
       
  2173  */
       
  2174 TVerdict CTestCSGetSupportedYUVFormats::DoTestStepL()
       
  2175 	{
       
  2176 		TInt err = KErrNone;
       
  2177     
       
  2178     // Enquire  the list of YUV Formats supported for encoding
       
  2179     err = ListYUVEncoderSupportedFormats();
       
  2180     if (err != KErrNone)
       
  2181         {
       
  2182         INFO_PRINTF2(_L("Enquire the imageDecoder UID FAILED with error %d..."), err);
       
  2183         return EFail;
       
  2184         }
       
  2185           
       
  2186     // Enquire  the list of YUV Formats supported decoding
       
  2187     err = ListYUVDecoderSupportedFormats();
       
  2188     if (err != KErrNone)
       
  2189         {
       
  2190         INFO_PRINTF2(_L("Enquire the Encoder UID FAILED with error %d..."), err);
       
  2191         return EFail;
       
  2192         }
       
  2193     return EPass;
       
  2194 	}
       
  2195 
       
  2196 /**
       
  2197  * 
       
  2198  *
       
  2199  * Class Constructor
       
  2200  *
       
  2201  */
       
  2202  CTestCSYUVEncoderNegative:: CTestCSYUVEncoderNegative(const TDesC& aTestName) : 
       
  2203 		  CTestStepYUVConversion(aTestName)
       
  2204 	{
       
  2205 	
       
  2206 	}
       
  2207 
       
  2208 /**
       
  2209  * 
       
  2210  *
       
  2211  * NewL Method
       
  2212  *
       
  2213  */
       
  2214  CTestCSYUVEncoderNegative * CTestCSYUVEncoderNegative::NewL(const TDesC& aTestName)
       
  2215 	{
       
  2216 	 CTestCSYUVEncoderNegative* self = new(ELeave)  CTestCSYUVEncoderNegative(aTestName);
       
  2217 	return self;
       
  2218 	}
       
  2219 
       
  2220 /**
       
  2221  * 
       
  2222  *
       
  2223  * DoTestStepL Method
       
  2224  *
       
  2225  */
       
  2226 TVerdict  CTestCSYUVEncoderNegative::DoTestStepL()
       
  2227 	{
       
  2228 	    
       
  2229     TInt err = KErrNone;
       
  2230     
       
  2231     if (iTestStepName.Compare(_L("MM-ICL-FRM-I-1112-CP")) == 0)
       
  2232 	    {     
       
  2233 	    //Encode an YUV to supported Image but unsuppored Frame format
       
  2234 	    TRAP(err, YUVEncodeUnsupportedFrameL(iFileNameSrc));
       
  2235 	    if (err != KErrNotSupported)
       
  2236 	        {
       
  2237 	        ERR_PRINTF2(_L("Encode an YUV to unsuppored image format - Error: %d..."), err);
       
  2238 	        return EFail;
       
  2239 	        }
       
  2240 	    }
       
  2241 	else if (iTestStepName.Compare(_L("MM-ICL-FRM-I-1113-CP")) == 0)
       
  2242 	    {        
       
  2243 	    //Encode with valid YUV file but corrupt RChunk
       
  2244 	    TRAP(err, YUVEncodeCorruptRChunkL(iFileNameSrc));
       
  2245 	    if (err != KErrNotSupported)
       
  2246 	        {
       
  2247 	        ERR_PRINTF2(_L("Encode an YUV to unsuppored image format - Error: %d..."), err);
       
  2248 	        return EFail;
       
  2249 	        }
       
  2250         }  
       
  2251 	else if (iTestStepName.Compare(_L("MM-ICL-FRM-I-1114-CP")) == 0)
       
  2252 	    {        
       
  2253 	    //Encode with valid YUV file but corrupt Descriptor
       
  2254 	    TRAP(err, YUVEncodeCorruptDescriptorL(iFileNameSrc));
       
  2255 	    if (err != KErrNotSupported)
       
  2256 	        {
       
  2257 	        ERR_PRINTF2(_L("Encode an YUV to unsuppored image format - Error: %d..."), err);
       
  2258 	        return EFail;
       
  2259 	        }
       
  2260 		}
       
  2261 	return EPass;
       
  2262 	}
       
  2263 
       
  2264 /**
       
  2265  * 
       
  2266  *
       
  2267  * Class Constructor
       
  2268  *
       
  2269  */
       
  2270 CTestCSYUVDecoderNegative::CTestCSYUVDecoderNegative(const TDesC& aTestName) : 
       
  2271 		 CTestStepYUVConversion(aTestName)
       
  2272 	{
       
  2273 	
       
  2274 	}
       
  2275 
       
  2276 /**
       
  2277  * 
       
  2278  *
       
  2279  * NewL Method
       
  2280  *
       
  2281  */
       
  2282 CTestCSYUVDecoderNegative *CTestCSYUVDecoderNegative::NewL(const TDesC& aTestName)
       
  2283 	{
       
  2284 	CTestCSYUVDecoderNegative* self = new(ELeave) CTestCSYUVDecoderNegative(aTestName);
       
  2285 	return self;
       
  2286 	}
       
  2287 
       
  2288 /**
       
  2289  * 
       
  2290  *
       
  2291  * DoTestStepL Method
       
  2292  *
       
  2293  */
       
  2294 TVerdict CTestCSYUVDecoderNegative::DoTestStepL()
       
  2295 	{
       
  2296     	TInt err = KErrNone;
       
  2297     
       
  2298 	    if (iTestStepName.Compare(_L("MM-ICL-FRM-I-1117-CP")) == 0)
       
  2299 	    {
       
  2300 	    //Decode from JPEG to unsupported image.
       
  2301 	    TRAP(err, JPEGDecodeUnsupportedYUVL(iFileNameSrc));
       
  2302 	    if (err != KErrNotSupported)
       
  2303 	        {
       
  2304 	        INFO_PRINTF2(_L("Decode from JPEG to unsupported image - Error: %d..."), err);
       
  2305 	        return EFail;
       
  2306 	        }
       
  2307 	    }
       
  2308 	    else if (iTestStepName.Compare(_L("MM-ICL-FRM-I-1118-CP")) == 0)
       
  2309 	    {
       
  2310 	    //Decode from corrupt JPEG to YUV.
       
  2311 	    TRAP(err, CorruptJPEGDecodeYUVL(iFileNameSrc));
       
  2312 	    if (err != KErrNotFound)
       
  2313 	        {
       
  2314 	        INFO_PRINTF2(_L("Decode from corrupt JPEG to YUV - Error: %d..."), err);
       
  2315 	        return EFail;
       
  2316 	        }
       
  2317 	    }
       
  2318 	    else if (iTestStepName.Compare(_L("MM-ICL-FRM-I-1119-CP")) == 0)
       
  2319 	    {
       
  2320 	    //Decode from corrupt JPEG descriptor to YUV
       
  2321 	    TRAP(err, CorruptJPEGDecodeDescYUVL(iFileNameSrc));
       
  2322 	    if (err != KErrNotFound)
       
  2323 	        {
       
  2324 	        INFO_PRINTF2(_L("Decode from corrupt JPEG descriptor to YUV - Error: %d..."), err);
       
  2325 	        return EFail;
       
  2326 	        }  
       
  2327 	     }
       
  2328 	    else if (iTestStepName.Compare(_L("MM-ICL-FRM-I-1120-CP")) == 0)
       
  2329 	    {
       
  2330 	    //Decode from GIF to YUV
       
  2331 	    TRAP(err, GIFDecodeYUVL(iFileNameSrc));
       
  2332 	    if (err != KErrNotFound)
       
  2333 	        {
       
  2334 	        INFO_PRINTF2(_L("Decode from GIF to YUV - Error: %d..."), err);
       
  2335 	        return EFail;
       
  2336 	        } 
       
  2337 	    }
       
  2338 	return EPass;            
       
  2339 	}
       
  2340 	
       
  2341