diff -r 000000000000 -r 40261b775718 mmplugins/imagingplugins/codecs/GifCodec/GIFcodec.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mmplugins/imagingplugins/codecs/GifCodec/GIFcodec.h Tue Feb 02 01:56:55 2010 +0200 @@ -0,0 +1,234 @@ +// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Licensed under US Patent No 4,558,302 and foreign counterparts +// +// + +#ifndef GIFCODEC_H +#define GIFCODEC_H + +#include +#include +#include + +#include "GIFConvert.h" +#include "GIFFormat.h" + +// Constants. +const TInt KGifMaxBits = 12; +const TInt KGifConversionTableSize = 1< + inline TUint8* WriteGifBuffer(TUint8* aOutputStringPtr, TUint8* aOutputStringLimit); + +private: + + T64KPixel* i64KPalette; + const TRgb* iPalette; + + TInt iBackgroundColorIndex; + TUint32 iOpaqueMask; + TUint16 iTranspColIdx; + TUint16 iBufMode; + TInt16* iPrefixIndex; + TUint8* iSuffixCode; + TUint8* iOutputString; + + TUint32* iPixelBuffer; + TInt iPixBufCount; + TInt iPixRead; + TInt iPixBufferSize; + + TUint32* iMaskBuffer; + +// do not change data members layout without a reason +// it is to have more efficient CPU caching + TInt iNextFree; + TInt iBitBuffSize; + TInt iCurrentCodeLength; + TBitBuffer iBitBuffer; + + const TUint8* iDataPtr; + const TUint8* iDataPtrLimit; + + CImageProcessor* iImgProc; // not owned + CImageProcessor* iMaskProc; // not owned + TUint8 iFirstChar; + TUint8 iLatestPixSize; + TInt iPreviousCode; + TInt iClearCode; + TInt iEoiCode; + TPoint* iPPos; + + TBool iComplete; + TInt iPass; + TInt iYPosIncrement; + + TPoint iPositionOffset; + TInt iReductionFactor; + const TSize iScreenSize; + + TBool iTableReset; + TInt iBlockId; + TBool iReadingExtensionBlock; + TBool iReadingCommentExtensionBlock; + TBool iReadingOtherExtensionBlock; + TBool iReadingLoopIterationExtensionBlock; + +// Local frame settings. + TFrameInfo *iFrameInfo; + CFrameImageData *iFrameData; + TRgb* iGlobalPalette; + TUint8* iStartDataPtr; //startDataPtr; + + RPointerArray iComment; + TInt iCommentIndex; + + // Temporary ImageData pointers. (Not owned by the codec) + // These ones are used by convert only. + TGifImageControl *iGifImageControl; + TGifImageDescriptor *iGifImageDesc; + TGifColorTable *iGifColorTable; + TGifLZWInfo *iGifLZWInfo; + + // These ones are used by header processing only. + TGifImageControl *iFrameImageControl; + TGifImageDescriptor *iFrameImageDesc; + TGifLZWInfo *iFrameLZWInfo; + + TSize iFirstFrameSize; + TRect iFirstFrameCoords; + + TSize iFrameSize; + TRect iFrameCoords; + TPoint iFrameOffset; + TBool iUseFrameSizeInPixels; + TBool iFast64kMode; + const TBool iFastDecode; + TBool iFastAccessMode; + }; + + +// Write codec. +const TInt KGifBlockSize = 255; +const TInt KGifBufferSize = KGifBlockSize + 9; +class CGifEncoder; +class CGifWriteCodec : public CImageWriteCodec + { +public: + static CGifWriteCodec* NewL(const CGifEncoder& aEncoder); + + //From CImageWriteCodec + virtual TFrameState ProcessFrameL(TBufPtr8& aDst); +protected: + CGifWriteCodec(const CGifEncoder& aEncoder); + +private: + void InitFrameL(TBufPtr8& aDst, const CFbsBitmap& aSource); + void AddToTableL(TInt aIndex, TUint32 aHashValue); + TBool TableEntry(TInt16 aWaitingCode, TUint8 aNewCode, TInt& aIndex, TUint32& aHashValue); + void ResetTable(); + void WriteData(TInt aIndex); + void FillBufferL(const CFbsBitmap& aFrame); + TBool WriteBuffer(); + TBool WriteTerminator(); +private: + TRect iSourceRect; + TPoint iPos; + TInt16 iWaitingCode; + TInt16 iHashCode[KGifHashTableSize]; // must hold -1..(KGifConversionTableSize-1) + TUint32 iHashValue[KGifHashTableSize]; // must hold 0..(KGifConversionTableSize-1)<<8|TUint8 + TUint8 iBuffer[KGifBufferSize]; + TUint8* iBufferPtr; + TInt iBufferSize; + TBool iBufferFull; + TBool iImageComplete; + TInt iCodeLength; + TInt iNextLimit; + TInt iClearCode; + TInt iNextFree; + TInt iBitsPerPixel; + TInt iBitOffset; + TUint8* iDestStartPtr; + TUint8* iDestPtr; + TUint8* iDestPtrLimit; + const CGifEncoder& iEncoder; + }; + +#endif // GIFCODEC_H +