mmplugins/imagingplugins/codecs/JPEGCodec/JpegConsts.h
changeset 0 40261b775718
equal deleted inserted replaced
-1:000000000000 0:40261b775718
       
     1 // Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #ifndef __JPEGCONSTS_H__
       
    17 #define __JPEGCONSTS_H__
       
    18 
       
    19 	
       
    20 // Constants.
       
    21 const TUint16 KJpgMarker = 0xff00;
       
    22 const TUint16 KJpgMarkerMask = 0xff00;
       
    23 const TUint16 KJpgSOISignature = 0xffd8;
       
    24 const TUint16 KJpgApp0Signature = 0xffe0;
       
    25 const TUint16 KJpgApp1Signature = 0xffe1;
       
    26 const TUint16 KJpgAppESignature = 0xffee;
       
    27 const TUint16 KJpgDHTSignature = 0xffc4;
       
    28 const TUint16 KJpgDQTSignature = 0xffdb;
       
    29 const TUint16 KJpgBaselineDCTSOFSignature = 0xffc0;
       
    30 const TUint16 KJpgExtendedDCTSOFSignature = 0xffc1;
       
    31 const TUint16 KJpgProgressiveDCTSOFSignature = 0xffc2;
       
    32 const TUint16 KJpgLosslessDCTSOFSignature = 0xffc3;
       
    33 const TUint16 KJpgSOSSignature = 0xffda;
       
    34 const TUint16 KJpgRestartIntervalSignature = 0xffdd;
       
    35 const TUint16 KJpgEOISignature = 0xffd9;
       
    36 const TUint16 KJpgCommentSignature = 0xfffe;
       
    37 const TUint16 KJpgAppSignatureMask = 0xfff0;
       
    38 const TInt KJpgPixelRatio = 1;
       
    39 const TUint8  KJpgMarkerByte = ( KJpgMarker >> 8 );
       
    40 
       
    41 const TInt KJpgHuffmanLookAhead = 8;
       
    42 const TInt KJpgHuffmanMaxCodeSize = 16;
       
    43 const TUint32 KJpgHuffmanLookAheadMask = (1<<KJpgHuffmanLookAhead)-1;
       
    44 
       
    45 _LIT8(KJfifId,"JFIF");
       
    46 _LIT8(KJfifExtId,"JFXX");
       
    47 _LIT8(KAdobeId,"Adobe");
       
    48 const TInt KJpgApp0IdSize = 4;
       
    49 const TInt KJpgAppEIdSize = 5;
       
    50 
       
    51 const TUint16 KJfifVersion0100 = 0x0100;
       
    52 const TUint16 KJfifVersion0101 = 0x0101;
       
    53 const TUint16 KJfifVersion0102 = 0x0102;
       
    54 
       
    55 const TInt KAdobeColorTransformYCbCr = 1;
       
    56 const TInt KAdobeColorTransformRGB = 0;
       
    57 
       
    58 const TInt KJfifInitialHeaderSize = 6;
       
    59 const TInt KJfifApp0DataSize = 16;
       
    60 const TInt KJfifHeaderBlockSizeInBytes = 4096;
       
    61 const TInt KJfifDataBlockSizeInBytes = 1024*8; // 8K
       
    62 const TInt KJfifLengthOffset = 4;
       
    63 const TInt KJfifThumbnailXYOffset = 18;
       
    64 
       
    65 const TInt KJpgNumberOfComponents = 3;
       
    66 const TInt KJpgMinNumberOfComponents = 1;
       
    67 const TInt KJpgMaxNumberOfTables = 4;
       
    68 const TInt KJpgHuffmanTableBitsSize = 16;
       
    69 const TInt KJpgHuffmanTableSize = 256;
       
    70 const TInt KJpgDCTBlockWidth = 8;
       
    71 const TInt KJpgDCTBlockHeight = 8;
       
    72 const TInt KJpgDCTBlockSize = 64;
       
    73 const TInt KJpgMinSampleFactor = 1;
       
    74 const TInt KJpgMaxSampleFactor = 4;
       
    75 const TInt KJpgZeroRunValue = 0xf0;
       
    76 const TInt KJpgMaxNumOfDataUnits = 6;
       
    77 const TInt KJpgMonochromeDataUnitCount = 1;
       
    78 const TInt KJpgEColor444DataUnitCount = 3;
       
    79 const TInt KJpgColor422DataUnitCount = 4;
       
    80 const TInt KJpgColor420DataUnitCount = 6;
       
    81 
       
    82 const TUint KRotation90DegreesClockwise = 0x01;
       
    83 const TUint KRotation180DegreesClockwise = 0x02;
       
    84 const TUint KRotation270DegreesClockwise = 0x04;
       
    85 const TUint KMirrorHorizontalAxis = 0x08;
       
    86 const TUint KMirrorVerticalAxis = 0x10;
       
    87 
       
    88 const TUint KJpgEncoderCapabilities = 0x1F;
       
    89 
       
    90 class TAlignedZigZag
       
    91     {
       
    92 public:
       
    93     union 
       
    94         {
       
    95         TUint8  iZigZag[KJpgDCTBlockSize];
       
    96         TUint64 iAligment;    
       
    97         };
       
    98     };
       
    99 
       
   100 extern const TAlignedZigZag KZigZagSequence;
       
   101 	
       
   102 const TUint KJPEGInterchangeFormat = 0x0201;
       
   103 const TUint KJPEGInterchangeFormatLength = 0x0202;
       
   104 
       
   105 const TInt KYComp = 0;	// index of Y component
       
   106 const TInt KUComp = 1;	// index of U component
       
   107 const TInt KVComp = 2;	// index of V component
       
   108 
       
   109 /**
       
   110 Capabilities for different color sampling schemes.
       
   111 */
       
   112 const TInt KSamplingMonoMCUWidthInPixels = 8;
       
   113 const TInt KSamplingMonoMCUHeightInPixels = 8;
       
   114 /**
       
   115 The optimal input pixel buffer width was calculated emprically by determining the average number of compressed MCUs that can fit in the 4096(KMaxDstBufferSize) encoded 
       
   116 destination buffer provided by framework.
       
   117 The calculation is roughly: (KMaxDstBufferSize) / (Size of Image in bytes/(MCU count x * MCU count y))
       
   118 */
       
   119 
       
   120 const TInt KSampling422MCUWidthInPixels = 16;
       
   121 const TInt KSampling422MCUHeightInPixels = 8;
       
   122 
       
   123 const TInt KSampling420MCUWidthInPixels = 16;
       
   124 const TInt KSampling420MCUHeightInPixels = 16;
       
   125 
       
   126 const TInt KOptimalBlockSize = 256;
       
   127 
       
   128 #if defined(__ARMCC__)
       
   129 #define FORCEDINLINE __forceinline
       
   130 #else
       
   131 #define FORCEDINLINE inline
       
   132 #endif
       
   133 
       
   134 #endif // __JPEGCONSTS_H__