videoeditorengine/vedengine/videoprocessor/inc/movieprocessorimpl.h
changeset 0 951a5db380a0
equal deleted inserted replaced
-1:000000000000 0:951a5db380a0
       
     1 /*
       
     2 * Copyright (c) 2010 Ixonos Plc.
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - Initial contribution
       
    11 *
       
    12 * Contributors:
       
    13 * Ixonos Plc
       
    14 *
       
    15 * Description:  
       
    16 * Header file for movie processor implementation.
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 #ifndef     __MOVIEPROCESSORIMPL_H__
       
    22 #define     __MOVIEPROCESSORIMPL_H__
       
    23 
       
    24 #ifndef __E32BASE_H__
       
    25 #include <e32base.h>
       
    26 #endif
       
    27 
       
    28 #include "mp4demux.h"
       
    29 #include "parser.h"
       
    30 #include "videoprocessor.h"
       
    31 #include "VedCommon.h"
       
    32 #include "VedMovieImp.h"
       
    33 #include "VedVideoClipInfoImp.h"
       
    34 #include "VedVideoClipGenerator.h"
       
    35 #include "VedRgb2YuvConverter.h"
       
    36 
       
    37 //  FORWARD DECLARATIONS
       
    38 class CStatusMonitor;
       
    39 class CActiveQueue;
       
    40 class CVideoProcessor;
       
    41 class CDemultiplexer; 
       
    42 class CComposer; 
       
    43 class CVideoEncoder;
       
    44 class CVedMovie;
       
    45 class MVedMovieProcessingObserver;
       
    46 class CDisplayChain;
       
    47 class CTranscoder;
       
    48 class CAudioProcessor;
       
    49 class CSizeEstimate;
       
    50 class CVedAVCEdit;
       
    51 
       
    52 // audio operation
       
    53 enum TAudioOperation
       
    54 {
       
    55 	EAudioRetain = 0,
       
    56 	EAudioMute,
       
    57 	EAudioReplace
       
    58 };
       
    59 
       
    60 enum TVideoOperation  // used in image insertion
       
    61 {
       
    62     EVideoEncodeFrame = 0,
       
    63     EVideoWriteFrameToFile
       
    64 };
       
    65 		
       
    66 // video frame parameters
       
    67 struct TFrameParameters
       
    68 {	
       
    69 	TInt64 iTimeStamp;
       
    70 	TUint8 iType;	
       
    71 };
       
    72 
       
    73 // H.263 TR parameters
       
    74 struct TTrParameters
       
    75 {
       
    76 	TInt iTrPrevNew; 
       
    77 	TInt iTrPrevOrig; 
       
    78 };
       
    79 
       
    80 // video clip parameters
       
    81 struct TVideoClipParameters
       
    82 {
       
    83 	TInt64 iStartTime; 
       
    84 	TInt64 iEndTime; 
       
    85 }; 
       
    86    
       
    87 
       
    88 //  CLASS DEFINITIONS
       
    89 class CMovieProcessorImpl : public CActive, public MVedVideoClipGeneratorFrameObserver,
       
    90                             public MThumbnailObserver
       
    91 {
       
    92 public:
       
    93 
       
    94     // Error codes
       
    95     enum TErrorCode
       
    96     {
       
    97         EInvalidProcessorState = -1000,
       
    98         EUnsupportedFormat = -1001,
       
    99         EVideoTooLarge = -1002,                                
       
   100         EStreamCorrupted = -1003,        
       
   101         EInvalidStreamData = -1004,
       
   102         EInvalidInternalState = -1050
       
   103         // Also error codes <EInvalidInternalState may be returned, they can be
       
   104         // considered fatal internal errors.
       
   105     };
       
   106 
       
   107     // Input data format
       
   108     enum TDataFormat
       
   109     {    
       
   110         EData3GP,  // 3GP
       
   111         EDataAutoDetect // autodetect type
       
   112     };    
       
   113 
       
   114 
       
   115 public:  // Functions from base classes
       
   116 
       
   117     /**
       
   118     * From CActive Active object running method
       
   119     */
       
   120     void RunL();
       
   121 
       
   122     /**
       
   123     * From CActive Active object cancelling method
       
   124     */    
       
   125     void DoCancel();
       
   126 
       
   127     /**
       
   128     * From CActive Active Error handling method
       
   129     */    
       
   130     TInt RunError(TInt aError);
       
   131 
       
   132     /** Frame insertion support 
       
   133 	 * From CVedVideoClipGenerator, this function is callback indicating image is ready
       
   134 	 * @param aError      <code>KErrNone</code>, if frame was completed successfully; 
       
   135 	 *                    one of the system wide error codes, if frame generation failed
       
   136      * @param aFrame      pointer to frame, if it was completed successfully;
       
   137 	 *                    <code>NULL</code>, if frame generation failed
       
   138 	 */
       
   139 	void NotifyVideoClipGeneratorFrameCompleted(CVedVideoClipGenerator& aGenerator, 
       
   140         TInt aError, CFbsBitmap* aFrame);    
       
   141     
       
   142     /**
       
   143     * From MThumbnailObserver
       
   144 	* 
       
   145 	* Called when thumbnail generation is ready
       
   146 	*	
       
   147     * @param aError error code
       
   148     */ 
       
   149     void NotifyThumbnailReady(TInt aError);
       
   150 
       
   151 public:  // New functions
       
   152 	
       
   153     /** 
       
   154      * Constructors for instantiating new video processors.
       
   155      * Should reserve as little resources as possible at this point.
       
   156 	 */
       
   157 	static CMovieProcessorImpl* NewL();
       
   158 	static CMovieProcessorImpl* NewLC();
       
   159 	
       
   160 	/** 
       
   161 	 * Destructor can be called at any time (i.e., also in the middle of a processing operation)
       
   162 	 * Should release all allocated resources, including releasing all allocated memory and 
       
   163 	 * *deleting* all output files that are currently being processed but not yet completed.
       
   164 	 */
       
   165 	virtual ~CMovieProcessorImpl();
       
   166 		
       
   167 	/**
       
   168 	 * Do all initializations necessary to start processing a movie, e.g. open files, allocate memory.
       
   169 	 * If this method leaves, destructor should be called to free allocated resources. 
       
   170      * Starts processing after initializations are done.
       
   171      *
       
   172 	 * @param aMovie  movie to process
       
   173 	 * @param aFilename  output file name
       
   174 	 * @param aFileHandle output file handle
       
   175      * @param aObserver observer object    
       
   176      *
       
   177 	 */
       
   178 	void StartMovieL(CVedMovieImp* aMovie, const TDesC& aFileName, RFile* aFileHandle,
       
   179 	                 MVedMovieProcessingObserver *aObserver);			
       
   180 
       
   181     /** Create 3gp generated clips 
       
   182      * Create all the necessary 3gp files before inserting them into the actual movie
       
   183      * If this method leaves, destructor should be called to free allocated resources. 
       
   184      * Starts processing after initializations are done.
       
   185      *
       
   186      * @param aCreateMode mode of operation of the create image files function
       
   187      */
       
   188 	TInt CreateImage3GPFilesL(TVideoOperation aCreateMode);
       
   189 
       
   190 	/** Prepare for 3gp generated clips
       
   191 	 * Create all the data structures necessary for 3gp files creation before calling create.
       
   192 	 * If this method leaves, destructor should be called to free allocated resources. 
       
   193      * Starts processing after initializations are done.
       
   194      *
       
   195 	 * @param aCreateMode        mode of operation of the create image files function
       
   196 	 */
       
   197 	TInt ProcessImageSetsL(TVideoOperation aCreateMode);
       
   198 
       
   199 	/** Encode raw frames for 3gp generated clips
       
   200 	 * This method is used to encode a raw frame for 3gp generated clips
       
   201 	 * If this method leaves, destructor should be called to free allocated resources. 
       
   202      * VideEncoder should be created and initialized before using this function
       
   203      * 
       
   204 	 */
       
   205 	TInt EncodeImageFrameL();
       
   206 
       
   207 	/** Process raw frames for 3gp generated clips
       
   208 	 * Decide what to do in this function - whether to call encoder or compose output
       
   209 	 * If this method leaves, destructor should be called to free allocated resources. 
       
   210      * Starts processing after initializations are done.
       
   211      *
       
   212 	 */
       
   213 	void DoImageSetProcessL();
       
   214 
       
   215 	
       
   216 	/**
       
   217 	 * Do all initializations necessary to start generating a thumbnail, e.g. open files, 
       
   218 	 * allocate memory. The video clip file should be opened with EFileShareReadersOnly 
       
   219 	 * share mode. The thumbnail should be scaled to the specified resolution and 
       
   220 	 * converted to the specified display mode. If this method leaves, destructor should be called to free 
       
   221 	 * allocated resources.
       
   222 	 * 
       
   223 	 * Possible leave codes:
       
   224 	 *	- <code>KErrNoMemory</code> if memory allocation fails
       
   225 	 *	- <code>KErrNotFound</code> if there is no file with the specified name
       
   226 	 *    in the specified directory (but the directory exists)
       
   227 	 *	- <code>KErrPathNotFound</code> if the specified directory
       
   228 	 *    does not exist
       
   229 	 *	- <code>KErrUnknown</code> if the specified file is of unknown format
       
   230 	 *  - <code>KErrNotSupported</code> if the specified combination of parameters
       
   231 	 *                                  is not supported
       
   232 	 *
       
   233 	 * @param aFileName  name of the file to generate thumbnail from
       
   234 	 * @param aFileHandle  handle of the file to generate thumbnail from
       
   235      * @param aIndex       Frame index for selecting the thumbnail frame
       
   236      *                     -1 means the best thumbnail is retrieved
       
   237  	 * @param aResolution  resolution of the desired thumbnail bitmap, or
       
   238 	 *                     <code>NULL</code> if the thumbnail should be
       
   239 	 *                     in the original resolution
       
   240 	 * @param aDisplayMode desired display mode; or <code>ENone</code> if 
       
   241 	 *                     any display mode is acceptable
       
   242 	 * @param aEnhance	   apply image enhancement algorithms to improve
       
   243 	 *                     thumbnail quality; note that this may considerably
       
   244 	 *                     increase the processing time needed to prepare
       
   245 	 *                     the thumbnail
       
   246 	 */
       
   247 	void StartThumbL(const TDesC& aFileName, RFile* aFileHandle, TInt aIndex, TSize aResolution, 
       
   248 		TDisplayMode aDisplayMode, TBool aEnhance);		
       
   249 	
       
   250 	/**
       
   251 	 * Starts thumbnail generation. Thumbnail generation is an asynchronous operation,
       
   252 	 * and its completion is informed to the caller via Active object request completion;
       
   253 	 * the iStatus member of the caller is passed as a parameter to this method.
       
   254 	 *
       
   255 	 * This method may leave if an error occurs in initiating the thumbnail generation.	
       
   256 	 * If this method leaves, destructor should be called to free allocated resources.	
       
   257 	 * 
       
   258 	 * @param aStatus     Reference to caller's iStatus member variable
       
   259 	 * @param aFactor     Pointer to a TVedTranscodeFactor structure, which is updated by this method
       
   260 	 *
       
   261 	 * @return  
       
   262 	 *          
       
   263 	 */
       
   264 	void ProcessThumbL(TRequestStatus &aStatus, TVedTranscodeFactor* aFactor);
       
   265 		
       
   266 	 /** 
       
   267 	 * Method for retrieving the completed thumbnail bitmap.
       
   268 	 * 
       
   269 	 * Video processor should not free the CFbsBitmap instance after it has passed it on 
       
   270 	 * as a return value of this function 
       
   271 	 *	 
       
   272 	 */
       
   273 	void FetchThumb(CFbsBitmap*& aThumb);
       
   274 	
       
   275 	/**
       
   276 	 * Read clip header from the specified file and return its properties.	 
       
   277 	 * This method should leave if clip is invalid, cannot be opened, etc.
       
   278 	 *
       
   279 	 * @param aFileName  name of the file to read
       
   280 	 * @param aFileHandle handle of file to read
       
   281 	 * @param aVideoFormat  for returning the video format
       
   282      * @param aVideoType Type of video data
       
   283 	 * @param aResolution  for returning the resolution
       
   284 	 * @param aAudioType Type of audio data
       
   285      * @param aDuration  for returning the duration
       
   286      * @param aVideoFrameCount Number of video frames in the clip	 
       
   287 	 * @param aSamplingRate Audio sampling rate
       
   288 	 * @param aChannelMode Audio channel mode
       
   289 	 */
       
   290 	void GetClipPropertiesL(const TDesC& aFileName, RFile* aFileHandle, TVedVideoFormat& aFormat,
       
   291 		TVedVideoType& aVideoType, TSize& aResolution, TVedAudioType& aAudioType, 
       
   292 		TTimeIntervalMicroSeconds& aDuration, TInt& aVideoFrameCount,TInt& aSamplingRate, 
       
   293 		TVedAudioChannelMode& aChannelMode);	
       
   294 
       
   295     /**
       
   296 	 * Read video frame information from the specified video clip file and fills array of info for 
       
   297      * all frames in video.The file should be opened with EFileShareReadersOnly share mode. Video processor 
       
   298 	 * should not free the video frame info array after it has passed it on as a return value 
       
   299 	 * of this function. Returned array should be allocated with User::AllocL() and should be 
       
   300 	 * freed by the caller of this method with User::Free(). 
       
   301 	 *
       
   302 	 * Possible leave codes:
       
   303 	 *	- <code>KErrNoMemory</code> if memory allocation fails
       
   304 	 *	- <code>KErrNotFound</code> if there is no file with the specified name
       
   305 	 *    in the specified directory (but the directory exists)
       
   306 	 *	- <code>KErrPathNotFound</code> if the specified directory
       
   307 	 *    does not exist
       
   308 	 *	- <code>KErrUnknown</code> if the specified file is of unknown format
       
   309 	 *
       
   310 	 * @param aFileName             name of the file to read
       
   311 	 * @param aFileHandle           handle of the file to read
       
   312 	 * @param aVideoFrameInfoArray  Array for video frame parameters
       
   313 	 */
       
   314     void GenerateVideoFrameInfoArrayL(const TDesC& aFileName, RFile* aFileHandle, TVedVideoFrameInfo*& aVideoFrameInfoArray);
       
   315 
       
   316     /**
       
   317      * Get movie size estimate
       
   318      *
       
   319      * @param aMovie Movie for which the estimate is done
       
   320      * @return Movie size in bytes
       
   321      */
       
   322 
       
   323     TInt GetMovieSizeEstimateL(const CVedMovie* aMovie);    
       
   324 
       
   325     /**
       
   326      * Calculate movie size estimate for MMS
       
   327      *          
       
   328      * @param aMovie			Movie object 
       
   329      * @param aTargetSize		Maximum size allowed
       
   330      * @param aStartTime		Time of the first frame included in the MMS output
       
   331      * @param aEndTime			Time of the last frame included in the MMS output
       
   332      * @return Error code
       
   333      */
       
   334     TInt GetMovieSizeEstimateForMMSL(const CVedMovie* aMovie, TInt aTargetSize, 
       
   335 		TTimeIntervalMicroSeconds aStartTime, TTimeIntervalMicroSeconds& aEndTime);
       
   336 
       
   337     /**
       
   338 	 *  Cancels the processing of a movie	 
       
   339 	 */
       
   340     void CancelProcessingL();
       
   341 
       
   342     /**
       
   343      * Enhances the visual quality of the frame
       
   344      *     
       
   345      */				
       
   346 	void EnhanceThumbnailL(const CFbsBitmap* aInBitmap, CFbsBitmap* aTargetBitmap); 
       
   347 
       
   348     /**
       
   349      * Get number of frames in output movie
       
   350      *     
       
   351      * @return Number of output frames
       
   352      */				
       
   353 	inline TInt GetOutputNumberOfFrames() const { return iOutputNumberOfFrames; }
       
   354 
       
   355 	/**
       
   356 	* Get the file name of the current clip
       
   357 	*     
       
   358 	* @return File name of the current clip
       
   359 	*/				
       
   360 	inline TFileName GetCurrentClipFileName() const { return iClipFileName; }
       
   361 
       
   362     /**
       
   363      * Get number of frames in current clip
       
   364      *     
       
   365      * @return Number of frames in clip
       
   366      */
       
   367     inline TInt GetClipNumberOfFrames() const { return iParser->GetNumberOfFramesInClip(); }	
       
   368 	
       
   369 	/**
       
   370      * Get the timescale of the current video clip
       
   371      *     
       
   372      * @return Timescale
       
   373      */
       
   374 	inline TInt GetVideoClipTimeScale() const { return iParser->iStreamParameters.iVideoTimeScale; }
       
   375 
       
   376     /**
       
   377      * Get color effect for the current clip
       
   378      *     
       
   379      * @return Color effect
       
   380      */
       
   381 	inline TVedColorEffect GetColorEffect() const { return iColorEffect; } 
       
   382 	
       
   383 	inline void GetColorTone(TInt& aU, TInt& aV) { aU=iColorToneU; aV=iColorToneV; }
       
   384 
       
   385     /**
       
   386      * Get number of audio frames in one 3gp sample
       
   387      *     
       
   388      * @return Number of frames in sample
       
   389      */
       
   390     inline TInt GetAudioFramesInSample() const { return iAudioFramesInSample; }
       
   391 
       
   392     /**
       
   393      * Finalize processing a clip
       
   394      *     
       
   395      */
       
   396     void FinalizeVideoClip();
       
   397 
       
   398     /**
       
   399      * Set frame type 
       
   400      *
       
   401      * @param aFrameIndex Index to the frame
       
   402      * @param aType P frame = 0, I frame = 1
       
   403      */    
       
   404     void SetFrameType(TInt aFrameIndex, TUint8 aType);
       
   405 	
       
   406     /**
       
   407      * Get video timestamp in ms from timestamp in ticks
       
   408      *
       
   409      * @param aTimeStampInTicks Time in ticks
       
   410      * @param aCommonTimeScale ETrue for using the output time scale
       
   411      *                         EFalse for using the scale of current clip
       
   412      * @return Timestamp in milliseconds
       
   413      */        
       
   414     TInt64 GetVideoTimeInMsFromTicks(TInt64 aTimeStampInTicks, TBool aCommonTimeScale) const;    
       
   415     
       
   416     /**
       
   417      * Get video timestamp in ticks from timestamp in ms
       
   418      *
       
   419      * @param aTimeStampInMs Time in ms
       
   420      * @param aCommonTimeScale ETrue for using the output time scale
       
   421      *                         EFalse for using the scale of current clip
       
   422      * @return Timestamp in ticks
       
   423      */        
       
   424     TInt64 GetVideoTimeInTicksFromMs(TInt64 aTimeStampInMs, TBool aCommonTimeScale) const;
       
   425     
       
   426     /**
       
   427      * Get audio timestamp in ticks from timestamp in ms
       
   428 	 *
       
   429 	 * @param aTimeStampInMs Time in ms 		
       
   430 	 * @return Timestamp in ticks
       
   431 	 */ 	 
       
   432 	TUint GetAudioTimeInTicksFromMs(TUint aTimeStampInMs) const;        
       
   433 	
       
   434 	/**
       
   435      * Get audio timestamp in ms from timestamp in ticks
       
   436 	 *
       
   437 	 * @param aTimeStampInTicks Time in ticks 		
       
   438 	 * @return Timestamp in milliseconds
       
   439 	 */ 	 
       
   440 	TUint GetAudioTimeInMsFromTicks(TUint aTimeStampInTicks) const;
       
   441 
       
   442     /**
       
   443      * Get video frame index based on timestamp
       
   444      *
       
   445      * @param aTime Frame timestamp in microseconds
       
   446      * @return Frame index
       
   447      */    
       
   448     TInt GetVideoFrameIndex(TTimeIntervalMicroSeconds aTime) const;
       
   449 
       
   450     /**
       
   451      * Get frame index for the first frame in current clip
       
   452      *
       
   453      * @param aTime Timestamp in microseconds
       
   454      * @return Frame index
       
   455      */
       
   456     inline TInt GetStartFrameIndex() const { return iStartFrameIndex; }
       
   457 
       
   458     /**
       
   459      * Get frame type at specified index
       
   460      *
       
   461      * @param aIndex Frame index
       
   462      * @return Frame type
       
   463      */
       
   464     inline TInt8 GetVideoFrameType(TInt aIndex) const { return iParser->GetVideoFrameType(aIndex); };
       
   465 
       
   466     inline TInt8 VideoFrameType(TInt aIndex) const
       
   467         {
       
   468         if (iThumbnailInProgress || (iFrameParameters == 0))
       
   469             {
       
   470             return iParser->GetVideoFrameType(iParser->GetStartFrameIndex() + aIndex);
       
   471             }
       
   472             
       
   473         return (TInt8) iFrameParameters[aIndex].iType;
       
   474         }
       
   475 
       
   476      /**
       
   477      * Get frame timestamp at specified index, in ticks
       
   478      *
       
   479      * @param aIndex Frame index
       
   480      * @return timestamp in ticks
       
   481      */
       
   482     inline TInt64 VideoFrameTimeStamp(TInt aIndex)
       
   483         {
       
   484         if (iThumbnailInProgress || (iFrameParameters == 0))
       
   485             {
       
   486             TInt startTimeInTicks = 0;
       
   487             iParser->GetVideoFrameStartTime(iParser->GetStartFrameIndex() + aIndex, &startTimeInTicks);
       
   488             return startTimeInTicks;
       
   489             }
       
   490         
       
   491         return (TInt64) iFrameParameters[aIndex].iTimeStamp;
       
   492         }
       
   493 
       
   494     inline void SetTrPrevNew(TInt aTr) { iTr.iTrPrevNew = aTr; }
       
   495 
       
   496     inline void SetTrPrevOrig(TInt aTr) { iTr.iTrPrevOrig = aTr; }
       
   497 
       
   498     inline TInt GetTrPrevNew() const { return iTr.iTrPrevNew; }
       
   499 
       
   500     inline TInt GetTrPrevOrig() const { return iTr.iTrPrevOrig; }
       
   501 
       
   502     /**
       
   503      * Get pointer to demultiplexer object
       
   504      *     
       
   505      * @return demux pointer
       
   506      */
       
   507     inline CDemultiplexer* GetDemux() const { return iDemux; }
       
   508 	
       
   509     /**
       
   510      * Get the start time for the current clip
       
   511      *     
       
   512      * @return Time in microseconds
       
   513      */
       
   514 	inline TTimeIntervalMicroSeconds GetStartCutTime() const { return iStartCutTime; }
       
   515 
       
   516      /**
       
   517      * Get thumbnail processing status
       
   518      * 
       
   519      * @return ETrue if thumbnail is being processed, EFalse otherwise
       
   520      */
       
   521     inline TBool IsThumbnailInProgress() const { return iThumbnailInProgress; }
       
   522 
       
   523     /**
       
   524      * Get the end time for the current clip
       
   525      *     
       
   526      * @return Time in microseconds
       
   527      */
       
   528 	inline TTimeIntervalMicroSeconds GetEndCutTime() const { return iEndCutTime; }	
       
   529 
       
   530 	/**
       
   531      * Get current metadata size
       
   532      *     
       
   533      * @return Metadata size in bytes
       
   534      */
       
   535 	TUint CurrentMetadataSize();
       
   536        
       
   537     /**
       
   538      * Write video frame to output 3gp file
       
   539      * @param aBuf Descriptor containing the frame
       
   540      * @param aTimeStampInTicks Time stamp of the frame in ticks
       
   541      * @param aDurationInTicks Frame duration in ticks
       
   542      * @param aKeyFrame ETrue if the frame is a keyframe     
       
   543      * @param aCommonTimeScale if ETrue, output movie timescale will
       
   544      *         be used, otherwise the current clip's timescale is used
       
   545      * @param aColorTransitionFlag ETrue if writing frames from latter
       
   546      *        clip in a color transition (wipe/crossfade)
       
   547      * @return Error code
       
   548      */
       
   549     TInt WriteVideoFrameToFile(TDesC8& aBuf, TInt64 aTimeStampInTicks, 
       
   550                                TInt aDurationInTicks, TBool aKeyFrame,
       
   551                                TBool aCommonTimeScale, TBool aColorTransitionFlag,
       
   552                                TBool aFromEncoder);
       
   553 
       
   554 	/**
       
   555      * Save a video YUV frame to the tmp file
       
   556      * @param aBuf Descriptor containing the YUV frame
       
   557      * @param aDuration The frame duration
       
   558      * @param aTimeStamp The frame timestamp
       
   559      * @return Error code
       
   560      */
       
   561     TInt SaveVideoFrameToFile(TDesC8& aBuf, TInt aDuration, TInt64 aTimeStamp);
       
   562 
       
   563 	/**
       
   564      * Retrieve a video YUV frame from the tmp file
       
   565      * @param aBuf Descriptor containing the YUV frame
       
   566      * @param aLength Length of the descriptor
       
   567      * @param aDuration The frame duration
       
   568      * @param aTimeStamp The frame timestamp
       
   569      * @return Error code
       
   570      */
       
   571     TInt GetVideoFrameFromFile(TDes8& aBuf, TInt aLength, TInt& aDuration, TInt64& aTimeStamp);
       
   572 
       
   573 	/**
       
   574      * Get the next frame duration and timestamp
       
   575      * @param aDuration The frame duration
       
   576      * @param aTimeStamp The frame timestamp
       
   577      * @param aIndex Index of timestamp to get
       
   578      * @param aTimeStampOffset Offset for timestamp
       
   579      * @return Error code
       
   580      */
       
   581     void GetNextFrameDuration(TInt& aDuration, TInt64& aTimeStamp, TInt aIndex, TInt& aTimeStampOffset);
       
   582 
       
   583     /**
       
   584      * Append the next frame duration and timestamp
       
   585      * @param aDuration The frame duration
       
   586      * @param aTimeStamp The frame timestamp
       
   587      * @return Error code
       
   588      */
       
   589     void AppendNextFrameDuration(TInt aDuration, TInt64 aTimeStamp);
       
   590 
       
   591     /**
       
   592      * Get the number of transition duration in the list
       
   593      * @return Number of transition
       
   594      */
       
   595     TInt NumberOfTransition() { return iCurClipDurationList.Count(); }
       
   596 
       
   597     /**
       
   598      * Get the number of transition at the start of next clip
       
   599      * @return Number of transition number
       
   600      */
       
   601     TInt NextClipStartTransitionNumber();
       
   602 
       
   603     /**
       
   604      * Get the transition duration of the current clip
       
   605      * @return Transition duration
       
   606      */
       
   607     TInt TransitionDuration();
       
   608 
       
   609     /**
       
   610      * Release all internal data hold for transition effect
       
   611      */
       
   612     void CloseTransitionInfoL();
       
   613 
       
   614 	/**
       
   615      * Update progress based on time processed so far
       
   616      *          
       
   617      */
       
   618 	void IncProgressBar();
       
   619     
       
   620      /**
       
   621      * Get the number of the audio clip being processed
       
   622      * 
       
   623      * @return Clip number
       
   624      */
       
   625     inline TInt GetAudioClipNumber() const  { return iAudioClipNumber; }	
       
   626 	
       
   627 	/**
       
   628 	* Get the output type of audio in the movie
       
   629 	* 
       
   630 	* @return Audio type
       
   631 	*/
       
   632 	TVedAudioType GetOutputAudioType();		
       
   633      
       
   634     /**
       
   635      * Get the number of the video clip being processed
       
   636      *          
       
   637      * @return Clip number
       
   638      */
       
   639 	inline TInt GetVideoClipNumber() const { return iVideoClipNumber; }    
       
   640 
       
   641     /**
       
   642      * Get the total number of the video clips in movie
       
   643      *          
       
   644      * @return Number of clips
       
   645      */
       
   646     inline TInt GetNumberOfVideoClips() const { return iNumberOfVideoClips; }
       
   647         
       
   648     /**
       
   649      * Get the starting transition effect for the current clip
       
   650      *          
       
   651      * @return Transition effect
       
   652      */
       
   653 	inline TVedStartTransitionEffect GetStartTransitionEffect() const { return iStartTransitionEffect; }
       
   654 
       
   655     /**
       
   656      * Get the middle transition effect for the current clip
       
   657      *          
       
   658      * @return Transition effect
       
   659      */
       
   660 	inline TVedMiddleTransitionEffect GetMiddleTransitionEffect() const { return iMiddleTransitionEffect; }
       
   661 
       
   662     /**
       
   663      * Get the middle transition effect for the previous clip
       
   664      *          
       
   665      * @return Transition effect
       
   666      */
       
   667 	inline TVedMiddleTransitionEffect GetPreviousMiddleTransitionEffect() const { return iPreviousMiddleTransitionEffect; }
       
   668 
       
   669     /**
       
   670      * Get the ending transition effect for the current clip
       
   671      *          
       
   672      * @return Transition effect
       
   673      */
       
   674 	inline TVedEndTransitionEffect GetEndTransitionEffect() const { return iEndTransitionEffect; }
       
   675 
       
   676     /**
       
   677      * Get the slow motion speed of the current clip
       
   678      *          
       
   679      * @return Speed
       
   680      */
       
   681     inline TInt GetSlowMotionSpeed() const { return iVideoClip->Speed(); }
       
   682 
       
   683     /**
       
   684      * Get the duration of the current video clip
       
   685      *          
       
   686      * @return duration
       
   687      */
       
   688     inline TInt64 GetVideoClipDuration() { return iVideoClipDuration; }
       
   689 
       
   690 	/**
       
   691      * Get the resolution of the current video clip
       
   692      *          
       
   693      * @return resolution
       
   694      */
       
   695 	TSize GetVideoClipResolution();
       
   696 	
       
   697 	/**
       
   698      * Get the resolution of the output movie
       
   699      *          
       
   700      * @return resolution
       
   701      */
       
   702 	TSize GetMovieResolution();
       
   703 
       
   704     /**
       
   705      * Get sync interval in picture setting from movie
       
   706      *
       
   707      * @return sync interval (H.263 GOB header frequency)
       
   708      */
       
   709     TInt GetSyncIntervalInPicture();
       
   710     
       
   711     /**
       
   712      * Get random access rate setting from movie
       
   713      *
       
   714      * @return random access rate in pictures per second
       
   715      */
       
   716     TReal GetRandomAccessRate();
       
   717 
       
   718 	/**
       
   719      * Get the format of the output video
       
   720      *          
       
   721      * @return format
       
   722      */
       
   723 	TVedVideoType GetOutputVideoType();
       
   724 
       
   725     /**
       
   726      * Get the format of the current video clip
       
   727      *          
       
   728      * @return format
       
   729      */
       
   730 	TVedVideoType GetCurrentClipVideoType();
       
   731 
       
   732 	/**	
       
   733      * Get the transcoding information of the video clip being processed
       
   734      *          
       
   735 	 * @param aNum         video clip number in the movie
       
   736 	 *
       
   737      * @return pointer to TTrascodeFactor object
       
   738      */
       
   739 	TVedTranscodeFactor GetVideoClipTranscodeFactor(TInt aNum);		
       
   740 
       
   741 	/** 
       
   742      * Get the flag that indicates if mode translation is required for the MPEG-4 video clip
       
   743      *          
       
   744      * @return duration
       
   745      */
       
   746 	inline TBool GetModeTranslationMpeg4() { return iModeTranslationRequired; }
       
   747 
       
   748 	/** 
       
   749      * Set the flag to indicate that the clip was transcoded
       
   750      *   
       
   751      * @param aModeChanged         ETrue if mode is changed
       
   752      */
       
   753 	inline void SetClipModeChanged(TBool aModeChanged) { iModeChanged = aModeChanged; }
       
   754 
       
   755     /**
       
   756      * Stops processing
       
   757      *
       
   758      * @return Error code
       
   759      */
       
   760 	TInt Stop();    
       
   761 
       
   762     /**
       
   763      * Stops processing and closes all submodules except status monitor & video encoder
       
   764      *
       
   765      * @return Error code
       
   766      */
       
   767     TInt Close();
       
   768 
       
   769     /**
       
   770      * Gets the average frame rate of current video clip
       
   771      *
       
   772      * @return Frame rate
       
   773      */
       
   774     TReal GetVideoClipFrameRate();
       
   775     
       
   776     /**
       
   777      * Gets the target movie frame rate
       
   778      *
       
   779      * @return Frame rate
       
   780      */
       
   781     TReal GetMovieFrameRate();
       
   782     
       
   783     /**
       
   784      * Get the target video bitrate
       
   785      *
       
   786      * @return bitrate
       
   787      */
       
   788     TInt GetMovieVideoBitrate();
       
   789     
       
   790     TInt GetMovieStandardVideoBitrate();
       
   791     
       
   792     /**
       
   793      * Sets the maximum size for the movie
       
   794      * 
       
   795      * @param aLimit Maximum size in bytes
       
   796      */
       
   797     void SetMovieSizeLimit(TInt aLimit);
       
   798     
       
   799      /**
       
   800       * Get the ColorTone value in Rgb for the clip and convert to YUV
       
   801 	  *
       
   802 	  * @param aColorEffect 			 TVedColorEffect type (B&W or ColorTone)			
       
   803 	  * @param aColorToneRgb			 Rgb value for the colortone
       
   804 	  */													 
       
   805 	void ConvertColorToneRGBToYUV(TVedColorEffect aColorEffect,TRgb aColorToneRgb);
       
   806 	
       
   807      /**
       
   808       * Adjust the U,V color tone value for H.263 video format
       
   809 	  *
       
   810 	  * @param aValue The color to adjustTVedColorEffect type (B&W or ColorTone)			
       
   811 	  */													 
       
   812     void CMovieProcessorImpl::AdjustH263UV(TInt& aValue);
       
   813         
       
   814     /**
       
   815      * Process audio frames
       
   816 	 *
       
   817 	 */													 
       
   818     void ProcessAudioL();
       
   819     
       
   820     /**    	
       
   821 	* Called when audio clip has been processed
       
   822 	*
       
   823     * @param aError error code
       
   824     */         
       
   825     void AudioProcessingComplete(TInt aError);
       
   826     
       
   827     /**
       
   828      * Returns the MIME-type for the video in the movie
       
   829      * 
       
   830      * @return Video codec MIME-type
       
   831      */
       
   832     TPtrC8& GetOutputVideoMimeType();
       
   833         
       
   834     /**
       
   835      * Returns the number of saved frames from previous clip
       
   836      * 
       
   837      * @return number of frames 
       
   838      */
       
   839     inline TInt GetNumberOfSavedFrames() const { return iCurClipTimeStampList.Count(); }            
       
   840     
       
   841      /**
       
   842      * Returns the length (in bytes) of decoder specific info
       
   843      * 
       
   844      * @return Decoder specific info size
       
   845      */
       
   846     inline TInt GetDecoderSpecificInfoSize() const { return iParser->GetDecoderSpecificInfoSize(); }
       
   847     
       
   848      /**
       
   849      * Suspends demux. New output can arrive from transcoder, but no new
       
   850      * input is fed there.
       
   851      *
       
   852      * @return TInt error code
       
   853      */
       
   854     TInt SuspendProcessing();
       
   855     
       
   856     /**
       
   857      * Resumes processing, restoring the state. Input to transcoder
       
   858      * goes to the position before the suspend or the last I-frame before that.
       
   859      *
       
   860      * @param aStartIndex Index of the first frame to be decoded
       
   861      * @param aSuspendTime Frame number of last written frame
       
   862      *
       
   863      * @return TInt error code
       
   864      */
       
   865     TInt ResumeProcessing(TInt& aStartFrameIndex, TInt aFrameNumber);    
       
   866     
       
   867     /**
       
   868      * Check if video transcoder is needed any longer. If not, suspend is not necessary.
       
   869      *
       
   870      * @return TBool ETrue if needed, EFalse if not
       
   871      */
       
   872     TBool NeedTranscoderAnyMore();
       
   873 								
       
   874 private: // Constants
       
   875 	
       
   876 	// state	
       
   877     enum TProcessorState
       
   878         {
       
   879             EStateIdle = 0,		
       
   880             EStateOpened,   // clip is open at the decoder (?)
       
   881             EStatePreparing,
       
   882             EStateReadyToProcess,
       
   883             EStateProcessing        
       
   884         };
       
   885 	
       
   886 	// Audio types
       
   887 	enum TAudioType
       
   888 	{
       
   889 		EAudioNone = 0,
       
   890 		EAudioAMR,
       
   891 		EAudioAAC
       
   892 	};
       
   893 	
       
   894 	// Video types
       
   895 	enum TVideoType
       
   896 	{
       
   897 		EVideoNone = 0,
       
   898 		EVideoH263Profile0Level10,
       
   899 		EVideoH263Profile0Level45,
       
   900 		EVideoMPEG4,
       
   901 		EVideoAVCProfileBaseline
       
   902 	};
       
   903 	
       
   904 	// Multiplex types
       
   905 	enum TMuxType
       
   906 	{
       
   907         EMuxNone = 0,
       
   908 		EMux3GP		
       
   909 	};     
       
   910 	
       
   911 private: // Private methods
       
   912 
       
   913     /**
       
   914     * By default Symbian OS constructor is private.
       
   915 	*/
       
   916     void ConstructL();
       
   917 
       
   918     /**
       
   919     * c++ default constructor
       
   920 	*/
       
   921     CMovieProcessorImpl();    
       
   922 
       
   923     /**
       
   924      * Set the number of output frames
       
   925      *          
       
   926      * @param aOutputNumberOfFrames No. of output frames     
       
   927      */
       
   928     inline void SetOutputNumberOfFrames(TInt aOutputNumberOfFrames) {
       
   929         iOutputNumberOfFrames = aOutputNumberOfFrames; }
       
   930     
       
   931     /**
       
   932      * Opens a 3gp clip for processing
       
   933      *
       
   934      * @param aFileName Clip filename
       
   935      * @param aFileHandle Clip file handle
       
   936      * @param aDataFormat Clip file format
       
   937      *
       
   938      * @return Error code
       
   939      */
       
   940 	TInt OpenStream(TFileName aFileName, RFile* aFileHandle, TDataFormat aDataFormat);
       
   941 
       
   942     /**
       
   943      * Closes the processed clip from parser
       
   944      *
       
   945      * @return Error code
       
   946      */
       
   947 	TInt CloseStream();
       
   948 
       
   949     /**
       
   950      * Prepares the processor for processing a movie
       
   951      *
       
   952      * @return Error code
       
   953      */
       
   954 	TInt Prepare();
       
   955     
       
   956     /**
       
   957      * Deletes objects used in processing
       
   958      *     
       
   959      */
       
   960     void DoCloseVideoL();
       
   961 
       
   962     /**
       
   963      * Finalizes movie processing, creates the output 3gp file
       
   964      * 
       
   965      */
       
   966 	void FinalizeVideoSequenceL();
       
   967 
       
   968     /**
       
   969      * Starts processing the movie
       
   970      *          
       
   971      */
       
   972     void DoStartProcessing();
       
   973 
       
   974     /**
       
   975      * Sets suitable default values for parameters
       
   976      *          
       
   977      */
       
   978     void SetHeaderDefaults();
       
   979 
       
   980 	/**
       
   981      * Sets output audio & video formats
       
   982      *          
       
   983      */
       
   984 	void SetOutputMediaTypesL();
       
   985 
       
   986 	/**
       
   987      * Gets bitstream modes of input clips
       
   988      *          
       
   989      */
       
   990 	void GetTranscodeFactorsL();
       
   991 
       
   992 	/**
       
   993      * Sets video transcoding parameters
       
   994      *          
       
   995      */
       
   996 	void SetupTranscodingL();
       
   997 
       
   998     /**
       
   999      * Resets modules & variables used in processing
       
  1000      *          
       
  1001      */
       
  1002     void ResetL();
       
  1003 
       
  1004     /**
       
  1005      * Processes the movie when no video clips are present
       
  1006      *          
       
  1007      */
       
  1008     void ProcessAudioOnly();
       
  1009 
       
  1010     /**
       
  1011      * Parses the clip header
       
  1012      *
       
  1013      * @param aStreamParams Destination structure for stream parameters
       
  1014      * @param Filename of the clip
       
  1015      * @param FileHandle of the clip
       
  1016      *          
       
  1017      */
       
  1018 	void ParseHeaderOnlyL(CParser::TStreamParameters& aStreamParams, TFileName& aFileName, RFile* aFileHandle); 
       
  1019 
       
  1020     /**
       
  1021      * Copies stream parameters from source to destination structure
       
  1022      *
       
  1023      * @param aDestParameters Destination structure
       
  1024      * @param aSrcParameters Source structure     
       
  1025      *          
       
  1026      */
       
  1027 	void UpdateStreamParameters(CParser::TStreamParameters& aDestParameters, 
       
  1028 		CParser::TStreamParameters& aSrcParameters);    
       
  1029 	
       
  1030     /**
       
  1031      * Parse the clip header & update internal variables accordingly
       
  1032      *     
       
  1033      */
       
  1034 	void ParseHeaderL();	
       
  1035     
       
  1036     /**
       
  1037      * Initializes the video queue and decoder
       
  1038      *
       
  1039      * @param aQueueBlocks Number of video queue blocks
       
  1040      * @param aQueueBlockSize Size of one video queue block
       
  1041      */
       
  1042 	void InitVideoL(TUint aQueueBlocks, TUint aQueueBlockSize);
       
  1043 
       
  1044 	/**
       
  1045      * Initializes the demultiplexer
       
  1046      *     
       
  1047      */
       
  1048 	void InitDemuxL();
       
  1049 
       
  1050     /**
       
  1051      * Initializes the processor for the next clip to be processed,
       
  1052      * called for each clip    
       
  1053      */
       
  1054 	void InitializeClipL();
       
  1055 
       
  1056     /**
       
  1057      * Initializes structures for movie processing, called once per movie
       
  1058      *
       
  1059      * @param iAudioDataArray Array containing parameters for audio clips     
       
  1060      *
       
  1061      */
       
  1062     void InitializeClipStructuresL();
       
  1063 
       
  1064     /**
       
  1065      * Initializes the processor for the generated clip to be processed.
       
  1066      * Called for each Image clip    
       
  1067      */
       
  1068 	void InitializeGeneratedClipL();
       
  1069 
       
  1070 	/**
       
  1071      * Initializes the processor for creating the temporary 3gp file (clip).
       
  1072      * Called for each Image clip 
       
  1073      */
       
  1074 	void TemporaryInitializeGeneratedClipL();
       
  1075 
       
  1076     /**
       
  1077      * Frees memory allocated for movie processing
       
  1078      *
       
  1079      */   
       
  1080     void DeleteClipStructures();
       
  1081 
       
  1082     /**
       
  1083      * Fills an array containing video frame parameters
       
  1084      *
       
  1085      */   
       
  1086     void FillVideoFrameInfoArrayL(TInt& aVideoFrameCount, TVedVideoFrameInfo*& aVideoFrameInfoArray);
       
  1087 
       
  1088     /**
       
  1089      * Fills internal frame parameter structure
       
  1090      *
       
  1091      */
       
  1092     void FillFrameParametersL(TInt aCurrentFrameIndex);    
       
  1093 
       
  1094     /**
       
  1095      * Writes the remaining audio frames to file
       
  1096      *          
       
  1097      * @return Error code
       
  1098      */
       
  1099     TInt FinalizeAudioWrite();	
       
  1100 
       
  1101 	/**
       
  1102 	* Decide the type of Audio in terms of the common types
       
  1103 	* 
       
  1104 	* @return Audio type
       
  1105 	*/
       
  1106 	TVedAudioType DecideAudioType(TAudioType aAudioType);	
       
  1107 	
       
  1108 	/**
       
  1109     * Write an audio frame to internal buffer (AMR)
       
  1110     * or to output file (AAC)
       
  1111 	*
       
  1112 	* @param aBuf Source buffer
       
  1113 	* @param aDuration duration of the current frame
       
  1114 	*
       
  1115 	 @return Error code
       
  1116 	*/		
       
  1117 	TInt WriteAllAudioFrames(TDesC8& aBuf, TInt aDuration);
       
  1118 
       
  1119 	/**
       
  1120 	* Add a number of AMR frames to internal buffer
       
  1121 	*
       
  1122 	* @param aBuf Source buffer
       
  1123 	* @param aNumFrames Number of frames in buffer
       
  1124 	*
       
  1125 	* @return Error code
       
  1126 	*/
       
  1127 	TInt BufferAMRFrames(const TDesC8& aBuf, TInt aNumFrames, TInt aDuration);	
       
  1128 
       
  1129 	/**
       
  1130 	* Purge AMR frames from internal buffer to output file
       
  1131 	*
       
  1132 	*
       
  1133 	* @return Error code
       
  1134 	*/
       
  1135 	TInt WriteAMRSamplesToFile();    
       
  1136 
       
  1137     /**
       
  1138      * Get the target audio bitrate
       
  1139      *
       
  1140      * @return bitrate
       
  1141      */
       
  1142     TInt GetMovieAudioBitrate();
       
  1143     
       
  1144     /**
       
  1145      * Writes a buffered frame to output file
       
  1146      *
       
  1147      * @param aDuration Duration of the frame being written from buffer,
       
  1148      *        expressed in timescale of the output movie
       
  1149      * @param aColorTransitionFlag ETrue if writing frames from latter
       
  1150      *        clip in a color transition (wipe/crossfade)     
       
  1151      * @return Error code
       
  1152      */
       
  1153     TInt WriteVideoFrameFromBuffer(TReal aDuration, TBool aColorTransitionFlag);
       
  1154 
       
  1155     /**
       
  1156      * Writes the last buffered frame to file
       
  1157      *
       
  1158      * @return Error code
       
  1159      */
       
  1160     TInt FinalizeVideoWrite();
       
  1161     
       
  1162     /**
       
  1163      * Reports an error in thumbnail generator
       
  1164      * to the caller
       
  1165      *
       
  1166      * @return ETrue if error was reported, EFalse otherwise
       
  1167      */
       
  1168     TBool HandleThumbnailError(TInt aError);
       
  1169     
       
  1170     /**
       
  1171      * Get output AVC level
       
  1172      *
       
  1173      * @return Level
       
  1174      */
       
  1175     TInt GetOutputAVCLevel();
       
  1176 
       
  1177 private:  // Data
       
  1178 
       
  1179 	// True if processing has been cancelled
       
  1180 	TBool iProcessingCancelled;
       
  1181 
       
  1182 	// True if video encoder initialisation is ongoing
       
  1183 	TBool iEncoderInitPending;
       
  1184 
       
  1185 	// timestamp for encoding ending black frames
       
  1186 	TTimeIntervalMicroSeconds iTimeStamp;
       
  1187 
       
  1188 	// Duration by which audio is longer than video
       
  1189 	TInt64 iLeftOverDuration;
       
  1190 
       
  1191     // Video frame parameters
       
  1192 	TFrameParameters* iFrameParameters;
       
  1193 	
       
  1194 	// Size of the video frame parameters array
       
  1195 	TInt iFrameParametersSize;
       
  1196 
       
  1197     // number of frames in output movie
       
  1198 	TInt iOutputNumberOfFrames;	
       
  1199 
       
  1200     // TR parameters
       
  1201 	TTrParameters iTr;
       
  1202 
       
  1203     // Thumbnail resolution
       
  1204 	TSize iOutputThumbResolution;    
       
  1205 
       
  1206 	// Thumbnail index
       
  1207 	TInt iThumbIndex; 
       
  1208 
       
  1209 	// Thumbnail display mode
       
  1210 	TDisplayMode iThumbDisplayMode; 
       
  1211 
       
  1212 	// Thumbnail enhance
       
  1213 	TBool iThumbEnhance; 
       
  1214 
       
  1215     // stream duration: max. of audio,video
       
  1216 	TInt64 iVideoClipDuration;
       
  1217 
       
  1218 	// output audio buffer	
       
  1219     // stores output raw amr data for processed clip
       
  1220 	HBufC8 *iOutAudioBuffer;
       
  1221     
       
  1222     // output video buffer for one frame
       
  1223     HBufC8 *iOutVideoBuffer;
       
  1224 
       
  1225     // Is there a frame in buffer ?
       
  1226     TBool iFrameBuffered;
       
  1227 
       
  1228     // Timestamp of buffered frame
       
  1229     TInt64 iBufferedTimeStamp;
       
  1230 
       
  1231     // key frame info of buffered frame
       
  1232     TBool iBufferedKeyFrame;
       
  1233     
       
  1234     TBool iBufferedFromEncoder;
       
  1235 
       
  1236     TBool iFirstFrameBuffered;
       
  1237 
       
  1238     // number of audio frames in the buffer currently
       
  1239     TInt iAudioFramesInBuffer;
       
  1240 	
       
  1241     // Composer object 
       
  1242 	CComposer *iComposer;
       
  1243 
       
  1244     // Filename of the current clip
       
  1245     TFileName iClipFileName;
       
  1246     
       
  1247     // File handle of the current clip
       
  1248     RFile* iClipFileHandle;
       
  1249     
       
  1250     // Output movie filename
       
  1251 	TFileName iOutputMovieFileName; 
       
  1252 	
       
  1253 	// Output movie filehandle
       
  1254 	RFile* iOutputFileHandle;
       
  1255 
       
  1256     // status monitor object
       
  1257     CStatusMonitor* iMonitor;
       
  1258     // Movie processing observer used
       
  1259     MVedMovieProcessingObserver *iObserver; 
       
  1260     // Are we processing a thumbnail ?
       
  1261 	TBool iThumbnailInProgress; 
       
  1262 		
       
  1263     // number of frames processes so far
       
  1264     TUint iFramesProcessed;
       
  1265     // number of current video clip
       
  1266 	TInt iVideoClipNumber; 
       
  1267     // total number of video frames
       
  1268 	TInt iNumberOfVideoClips; 
       
  1269     // index of the first frame in clip
       
  1270     TInt iStartFrameIndex;	
       
  1271     // video timescale for output movie
       
  1272 	TUint iOutputVideoTimeScale;
       
  1273     
       
  1274     // progress percentage
       
  1275     TInt iProgress;
       
  1276     // is the current disk full ?
       
  1277     TBool iDiskFull;
       
  1278 
       
  1279     // starting cut time for the current video clip
       
  1280 	TTimeIntervalMicroSeconds iStartCutTime; 
       
  1281     // ending cut time for the current video clip
       
  1282 	TTimeIntervalMicroSeconds iEndCutTime;     
       
  1283 	
       
  1284     // Current video clip
       
  1285 	CVedVideoClip* iVideoClip; 
       
  1286     // Movie
       
  1287 	CVedMovieImp* iMovie; 
       
  1288 
       
  1289     // buffer pointers for thumbnail generation
       
  1290     TUint8* iYuvBuf;
       
  1291     TUint8* iRgbBuf;
       
  1292 
       
  1293     // Transition effect parameters
       
  1294 	TVedStartTransitionEffect iStartTransitionEffect; 
       
  1295 	TVedMiddleTransitionEffect iMiddleTransitionEffect; 
       
  1296 	TVedMiddleTransitionEffect iPreviousMiddleTransitionEffect; 
       
  1297 	TVedEndTransitionEffect iEndTransitionEffect; 
       
  1298 
       
  1299 	// Indicates if an image is being encoded
       
  1300 	TInt iImageEncodedFlag;  
       
  1301 
       
  1302     // finished creating the image 3GP file
       
  1303 	TInt iImageEncodeProcFinished;
       
  1304 
       
  1305 	// for storing the converted YUV image in generation case
       
  1306 	TUint8 *iYuvImageBuf; 
       
  1307 
       
  1308 	// image size for generated frames
       
  1309 	TInt iImageSize;
       
  1310 
       
  1311 	// Descriptor holding the image to be encoded
       
  1312 	TPtr8 iReadImageDes;
       
  1313 
       
  1314 	// Image composer
       
  1315 	CComposer* iImageComposer;
       
  1316 
       
  1317 	// images processed in generation case
       
  1318 	TInt iTotalImagesProcessed;
       
  1319 
       
  1320 	// Time scale for generated frames
       
  1321 	TInt iImageVideoTimeScale;
       
  1322 
       
  1323     // Generated clip has been created
       
  1324     TInt iImageClipCreated;
       
  1325 
       
  1326 	// Are we starting to process generated images
       
  1327 	TInt iFirstTimeProcessing;
       
  1328 
       
  1329 	// The name of the current clip is constant for image clips and 0 if buffer supported
       
  1330 	TFileName iCurrentMovieName;
       
  1331 
       
  1332 	// number of images from the generator
       
  1333 	TInt iNumOfImages;
       
  1334 
       
  1335 	// is getFrame() from generator in progress
       
  1336 	TInt iGetFrameInProgress;
       
  1337 	
       
  1338 	// Are output timescales set ?
       
  1339 	TInt iOutputVideoTimeSet;
       
  1340 	TInt iOutputAudioTimeSet;
       
  1341 
       
  1342 	// Are all clips generated ?
       
  1343 	TInt iAllGeneratedClips;
       
  1344 
       
  1345 	// Is generated clip image being encoded ?
       
  1346 	TInt iEncodeInProgress;	
       
  1347 
       
  1348 	// in ms, audio and video durations added up for progress bar indication
       
  1349 	TInt64 iTotalMovieDuration;  
       
  1350 
       
  1351 	// Is the first clip generated
       
  1352     TBool iFirstClipIsGen;
       
  1353 
       
  1354     TAudioType iOutputAudioType;
       
  1355 
       
  1356 	TVideoType iOutputVideoType;
       
  1357 
       
  1358 	TInt iMP4SpecificSize; 
       
  1359 
       
  1360 	// Is it the first frame of a clip
       
  1361     TBool iFirstFrameOfClip;
       
  1362 
       
  1363     // for setting the first frame flag
       
  1364     // when doing wipe/crossfade transitions
       
  1365     TBool iFirstFrameFlagSet;
       
  1366 
       
  1367 	/*Indicates whether mode translation in between MPEG4 modes is required(NOTE in between MPEG4 modes only)*/
       
  1368 	TBool iModeTranslationRequired;
       
  1369 
       
  1370 	/*This is set by the decoder indicating he changed either the format or mode so Mp4Specific size may not be right  */
       
  1371 	TBool iModeChanged;	//This for the composer to know that mode was changed for Mp4Specific size
       
  1372 
       
  1373     // Speed for the current clip, 1000 = normal speed
       
  1374 	TUint iSpeed;
       
  1375     // Color effect for the current clip
       
  1376 	TVedColorEffect iColorEffect;    
       
  1377 
       
  1378     // total number of audio clips
       
  1379 	TInt iNumberOfAudioClips; 
       
  1380 
       
  1381     // Current audio clip number
       
  1382     TInt iAudioClipNumber; 
       
  1383 
       
  1384     // Current replacement clip number
       
  1385     TInt iAudioReplaceClipNumber;
       
  1386 
       
  1387     TInt iAudioFrameNumber;
       
  1388     TInt iVideoFrameNumber;
       
  1389     TInt iVideoIntraFrameNumber;
       
  1390 
       
  1391     // Current audio time
       
  1392 	TInt64 iCurrentAudioTimeInMs;
       
  1393 
       
  1394 	// total time in ms of audio written, 
       
  1395 	// for the whole movie
       
  1396 	TInt64 iTotalAudioTimeWrittenMs;
       
  1397 
       
  1398     // Current video time
       
  1399 	TReal iCurrentVideoTimeInTicks; 
       
  1400 
       
  1401     // duration processed for generated clips
       
  1402     TInt64 iGeneratedProcessed;
       
  1403 
       
  1404 	// Duration of current audio clip written, 
       
  1405 	// reseted after a clip has been processed
       
  1406 	TInt64 iAudioClipWritten;
       
  1407 
       
  1408     // Duration of current video clip written, 
       
  1409 	// reseted after a clip has been processed
       
  1410     TInt64 iVideoClipWritten;
       
  1411 
       
  1412     // video clip parameters
       
  1413 	TVideoClipParameters *iVideoClipParameters; 
       
  1414     TInt iNumberOfAudioClipsCreated;
       
  1415     // number of audio frames per sample
       
  1416     TInt iAudioFramesInSample; 
       
  1417     // output audio timescale
       
  1418     TInt iOutputAudioTimeScale;
       
  1419 
       
  1420     // time stamp for current video clip
       
  1421     TInt64 iInitialClipStartTimeStamp;
       
  1422     // ETrue if movie processing is starting
       
  1423     TBool iStartingProcessing;    
       
  1424 
       
  1425 	// Used by AAC to handle writing decoder specific info, 
       
  1426 	// if it does not exist, to default value */	
       
  1427 	TBool iFirstClipHasNoDecInfo;
       
  1428     
       
  1429     // the demultiplexer    
       
  1430     CDemultiplexer *iDemux; 
       
  1431      // the video decoder
       
  1432     CVideoProcessor *iVideoProcessor;
       
  1433     // the video decoder input queue
       
  1434     CActiveQueue *iVideoQueue; 
       
  1435      // file format parser
       
  1436     CParser *iParser;   
       
  1437     // video encoder
       
  1438     CVideoEncoder *iVideoEncoder;  	
       
  1439     
       
  1440     // audio processor
       
  1441     CAudioProcessor *iAudioProcessor;
       
  1442     
       
  1443     // audio processing done ?
       
  1444     TBool iAudioProcessingCompleted;
       
  1445 
       
  1446     // frame enhancement
       
  1447     CDisplayChain *iEnhancer;  
       
  1448 
       
  1449     // Video encoder input buffer
       
  1450     TUint8 *iEncoderBuffer;
       
  1451     // ETrue if video encoding is pending
       
  1452     TBool iEncodePending;
       
  1453     
       
  1454     // does the stream have video?
       
  1455     TBool iHaveVideo; 
       
  1456     // video stream type
       
  1457 	TVideoType iVideoType; 
       
  1458     // does the stream have audio?
       
  1459 	TBool iHaveAudio; 
       
  1460 	
       
  1461 	// : is this needed ??
       
  1462     // audio stream type
       
  1463 	TAudioType iAudioType; 	    
       
  1464 	
       
  1465     // is the stream multiplexed?
       
  1466 	TBool iIsMuxed; 
       
  1467     // multiplex type					
       
  1468 	TMuxType iMuxType; 
       
  1469 		
       
  1470     // current processor state
       
  1471 	TProcessorState iState; 
       
  1472      // current stream data format	
       
  1473 	TDataFormat iDataFormat;
       
  1474 
       
  1475 	// stream start reading buffer
       
  1476 	TUint8 *iReadBuf; 
       
  1477     // buffer length
       
  1478 	TUint iBufLength; 
       
  1479     // amount of data in buffer
       
  1480 	TUint iBufData; 
       
  1481     // reading descriptor	
       
  1482 	TPtr8 iReadDes; 
       
  1483 			
       
  1484     // number of demux channels used
       
  1485 	TUint iNumDemuxChannels; 
       
  1486     // demux parameters read
       
  1487 	CMP4Demux::TStreamParameters iMP4Parameters; 
       
  1488 	CMP4Demux::TOutputChannel iMP4Channels[2];
       
  1489 		
       
  1490     // H.263 stream parameters
       
  1491 	CVideoProcessor::TStreamParameters iVideoParameters; 
       
  1492 
       
  1493     // stream length in milliseconds
       
  1494 	TUint iStreamLength; 
       
  1495     // stream size in bytes
       
  1496 	TUint iStreamSize; 
       
  1497     // stream average bitrate
       
  1498 	TUint iStreamBitrate; 
       
  1499     // is it possible to seek in the file	
       
  1500 	TBool iCanSeek; 
       
  1501 
       
  1502     // ETrue when all video of the movie has been processed
       
  1503     TBool iAllVideoProcessed;
       
  1504     
       
  1505 	// tmp file used for Transition Effect
       
  1506 	TFileName iCurClipFileName;
       
  1507     TFileName iNextClipFileName;
       
  1508 
       
  1509 	RFile iCurClip;
       
  1510     RFile iNextClip;
       
  1511     RFs   iFs;
       
  1512     TBool iFsConnected;	
       
  1513 
       
  1514     RArray<TInt>   iCurClipDurationList;
       
  1515     RArray<TInt>   iNextClipDurationList;
       
  1516     RArray<TInt64> iCurClipTimeStampList;
       
  1517     RArray<TInt64> iNextClipTimeStampList;
       
  1518 
       
  1519     TInt           iCurClipIndex;
       
  1520     TUint          iPreviousTimeScale;
       
  1521     TInt64         iOffsetTimeStamp;
       
  1522 
       
  1523 	// This flag is set to true if first clip uses encoder such as cut 
       
  1524 	// as Resynch bit needs to be reset
       
  1525 	TBool iFirstClipUsesEncoder;	// For changing Vos in case of Mpeg4 transcoding
       
  1526 	TBool iMpeg4ModeTranscoded;
       
  1527 
       
  1528 	// Is true if first clip is cut
       
  1529 	TBool iFirstClipIsCut;
       
  1530 	
       
  1531 	TInt iCurrentVideoSize;
       
  1532 	TInt iCurrentAudioSize;
       
  1533 	TInt iMovieSizeLimit;
       
  1534 	TBool iMovieSizeLimitExceeded;
       
  1535 
       
  1536     CActiveSchedulerWait *iWaitScheduler;
       
  1537     TBool iWaitSchedulerStarted;
       
  1538 
       
  1539     TBool iAudioProcessingCancelled;
       
  1540     
       
  1541     TRequestStatus *iThumbnailRequestStatus;
       
  1542     CFbsBitmap* iOutBitmap;
       
  1543     
       
  1544     // Duration of all samples in buffered AMR
       
  1545     TInt iTotalDurationInSample;
       
  1546     
       
  1547     // ColorTone value as RGB
       
  1548     TRgb iColorToneRgb;
       
  1549     
       
  1550 	// ColorTone values as U,V
       
  1551 	TInt iColorToneU;
       
  1552 	TInt iColorToneV;
       
  1553 	
       
  1554 	// for scaling the timestamp list
       
  1555 	TBool iTimeStampListScaled;
       
  1556 	
       
  1557 	// true if we are encoding black ending frames
       
  1558 	TBool iEncodingBlackFrames;
       
  1559 	
       
  1560 	// For calculating movie size estimates
       
  1561 	CSizeEstimate *iSizeEstimate;
       
  1562 		    
       
  1563     // Slow motion is not applied for ending black frames or the last frame of a clip
       
  1564     TBool iApplySlowMotion;  
       
  1565 
       
  1566     // True if writing the first color transition frame    
       
  1567     TBool iWriting1stColorTransitionFrame;
       
  1568     
       
  1569     // Timestamp of the first color transition frame    
       
  1570     TInt64 i1stColorTransitionFrameTS;
       
  1571 
       
  1572     // AVC editing instance for movie    
       
  1573     CVedAVCEdit* iAvcEdit;
       
  1574     
       
  1575     // AVC editing instance for a generated clip
       
  1576     CVedAVCEdit* iImageAvcEdit;
       
  1577     
       
  1578     // Bitmap-to-YUV converter
       
  1579     CVSFbsBitmapYUV420Converter* iImageYuvConverter;  
       
  1580 
       
  1581     friend class CMP4Parser;
       
  1582     friend class CAudioProcessor;        
       
  1583 		
       
  1584 };
       
  1585 
       
  1586 
       
  1587 #endif      //  __MOVIEPROCESSORIMPL_H__
       
  1588 
       
  1589 // End of File