mmplugins/imagingplugins/codecs/JPEGCodec/Jpgdct.cpp
changeset 0 40261b775718
equal deleted inserted replaced
-1:000000000000 0:40261b775718
       
     1 // Copyright (c) 1997-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 // TDCT::Transform() is based heavily on jpeg_fdct_islow() from jfdctint.c
       
    17 // in the IJG code, Copyright (C) 1991-1998, Thomas G. Lane.
       
    18 // TDCT::InverseTransform() is based heavily on jpeg_idct_islow() from jidctint.c
       
    19 // in the IJG code, Copyright (C) 1991-1998, Thomas G. Lane.
       
    20 
       
    21 #include <e32base.h>
       
    22 
       
    23 #include "JpegTypes.h"
       
    24 
       
    25 // Constants.
       
    26 const TInt CONST_BITS = 13;
       
    27 const TInt PASS1_BITS = 1;
       
    28 const TInt FIX_0_298631336 = 2446;
       
    29 const TInt FIX_0_390180644 = 3196;
       
    30 const TInt FIX_0_541196100 = 4433;
       
    31 const TInt FIX_0_765366865 = 6270;
       
    32 const TInt FIX_0_899976223 = 7373;
       
    33 const TInt FIX_1_175875602 = 9633;
       
    34 const TInt FIX_1_501321110 = 12299;
       
    35 const TInt FIX_1_847759065 = 15137;
       
    36 const TInt FIX_1_961570560 = 16069;
       
    37 const TInt FIX_2_053119869 = 16819;
       
    38 const TInt FIX_2_562915447 = 20995;
       
    39 const TInt FIX_3_072711026 = 25172;
       
    40 // for fast dct
       
    41 const TInt FIX_0_707106781 = 5793;
       
    42 const TInt FIX_0_382683433 = 3135;
       
    43 const TInt FIX_1_306562965 = 10703;
       
    44 
       
    45 //
       
    46 // this file contains many performance-critical code, so use ARM instruction set for it
       
    47 //
       
    48 #ifdef __ARMCC__
       
    49 #pragma push
       
    50 #pragma arm 
       
    51 #pragma O3 
       
    52 #pragma Otime
       
    53 #endif
       
    54 
       
    55 void TDCT::Transform(TDataUnit& aDestination,const TDataUnit& aSource, TBool aHighSpeedMode) const
       
    56 	{
       
    57 	TAligned64Du temp;
       
    58     if (!aHighSpeedMode) 
       
    59 		{
       
    60 		DoFirstStep(temp, aSource);
       
    61 		DoSecondStep(aDestination, temp);
       
    62 		}
       
    63 	else 
       
    64 		{
       
    65 		DoFastFirstStep(temp, aSource);
       
    66 		DoFastSecondStep(aDestination, temp);
       
    67 		}
       
    68 	}
       
    69 
       
    70 void TDCT::DoFirstStep(TAligned64Du& aDestination,const TDataUnit& aSource) const
       
    71     {
       
    72 	const TDataUnit::TDataUnitElemType* srcPtr = aSource.iCoeff;
       
    73 
       
    74 	TInt* tempPtr = aDestination.iData;
       
    75 	const TDataUnit::TDataUnitElemType* const srcPtrLimit = srcPtr + KJpgDCTBlockSize;
       
    76 
       
    77 	do
       
    78 		{
       
    79 		const TInt KDblShift = KDefPrecShift << 1;
       
    80 		TInt tmp0 = srcPtr[0] + srcPtr[7] - KDblShift;
       
    81 		TInt tmp7 = srcPtr[0] - srcPtr[7];
       
    82 		TInt tmp1 = srcPtr[1] + srcPtr[6] - KDblShift;
       
    83 		TInt tmp6 = srcPtr[1] - srcPtr[6];
       
    84 		TInt tmp2 = srcPtr[2] + srcPtr[5] - KDblShift;
       
    85 		TInt tmp5 = srcPtr[2] - srcPtr[5];
       
    86 		TInt tmp3 = srcPtr[3] + srcPtr[4] - KDblShift;
       
    87 		TInt tmp4 = srcPtr[3] - srcPtr[4];
       
    88 
       
    89 		TInt tmp10 = tmp0 + tmp3;
       
    90 		TInt tmp13 = tmp0 - tmp3;
       
    91 		TInt tmp11 = tmp1 + tmp2;
       
    92 		TInt tmp12 = tmp1 - tmp2;
       
    93 
       
    94 		tempPtr[0 * KJpgDCTBlockWidth] = ((tmp10 + tmp11) << PASS1_BITS);
       
    95 		tempPtr[4 * KJpgDCTBlockWidth] = ((tmp10 - tmp11) << PASS1_BITS);
       
    96 
       
    97 		TInt z1 = (tmp12 + tmp13) * FIX_0_541196100;
       
    98 		tempPtr[2 * KJpgDCTBlockWidth] = DESCALE(z1 + (tmp13 * FIX_0_765366865),CONST_BITS - PASS1_BITS);
       
    99 		tempPtr[6 * KJpgDCTBlockWidth] = DESCALE(z1 + (tmp12 * - FIX_1_847759065),CONST_BITS - PASS1_BITS);
       
   100 
       
   101 		z1 = tmp4 + tmp7;
       
   102 		TInt z2 = tmp5 + tmp6;
       
   103 		TInt z3 = tmp4 + tmp6;
       
   104 		TInt z4 = tmp5 + tmp7;
       
   105 		TInt z5 = (z3 + z4) * FIX_1_175875602; /* sqrt(2) * c3 */
       
   106 
       
   107 		tmp4 = tmp4 * FIX_0_298631336; /* sqrt(2) * (-c1+c3+c5-c7) */
       
   108 		tmp5 = tmp5 * FIX_2_053119869; /* sqrt(2) * ( c1+c3-c5+c7) */
       
   109 		tmp6 = tmp6 * FIX_3_072711026; /* sqrt(2) * ( c1+c3+c5-c7) */
       
   110 		tmp7 = tmp7 * FIX_1_501321110; /* sqrt(2) * ( c1+c3-c5-c7) */
       
   111 		z1 = z1 * - FIX_0_899976223; /* sqrt(2) * (c7-c3) */
       
   112 		z2 = z2 * - FIX_2_562915447; /* sqrt(2) * (-c1-c3) */
       
   113 		z3 = z3 * - FIX_1_961570560; /* sqrt(2) * (-c3-c5) */
       
   114 		z4 = z4 * - FIX_0_390180644; /* sqrt(2) * (c5-c3) */
       
   115 
       
   116 		z3 += z5;
       
   117 		z4 += z5;
       
   118 
       
   119 		tempPtr[7 * KJpgDCTBlockWidth] = DESCALE(tmp4 + z1 + z3, CONST_BITS - PASS1_BITS);
       
   120 		tempPtr[5 * KJpgDCTBlockWidth] = DESCALE(tmp5 + z2 + z4, CONST_BITS - PASS1_BITS);
       
   121 		tempPtr[3 * KJpgDCTBlockWidth] = DESCALE(tmp6 + z2 + z3, CONST_BITS - PASS1_BITS);
       
   122 		tempPtr[1 * KJpgDCTBlockWidth] = DESCALE(tmp7 + z1 + z4, CONST_BITS - PASS1_BITS);
       
   123 
       
   124 		srcPtr  += KJpgDCTBlockWidth;
       
   125 		tempPtr += 1;
       
   126 		} while (srcPtr < srcPtrLimit);
       
   127     }
       
   128 
       
   129 // based on code from jfdctfst.c
       
   130 void TDCT::DoFastFirstStep(TAligned64Du& aDestination,const TDataUnit& aSource) const
       
   131     {
       
   132 	const TDataUnit::TDataUnitElemType* srcPtr = aSource.iCoeff;
       
   133 
       
   134 	TInt* tempPtr = aDestination.iData;
       
   135 	const TDataUnit::TDataUnitElemType* const srcPtrLimit = srcPtr + KJpgDCTBlockSize;
       
   136 
       
   137 	do
       
   138 		{
       
   139 		const TInt KDblShift = KDefPrecShift << 1;
       
   140 		TInt tmp0 = srcPtr[0] + srcPtr[7] - KDblShift;
       
   141 		TInt tmp7 = srcPtr[0] - srcPtr[7];
       
   142 		TInt tmp1 = srcPtr[1] + srcPtr[6] - KDblShift;
       
   143 		TInt tmp6 = srcPtr[1] - srcPtr[6];
       
   144 		TInt tmp2 = srcPtr[2] + srcPtr[5] - KDblShift;
       
   145 		TInt tmp5 = srcPtr[2] - srcPtr[5];
       
   146 		TInt tmp3 = srcPtr[3] + srcPtr[4] - KDblShift;
       
   147 		TInt tmp4 = srcPtr[3] - srcPtr[4];
       
   148 
       
   149 		// Even part
       
   150 		TInt tmp10 = tmp0 + tmp3;	// phase 2
       
   151 		TInt tmp13 = tmp0 - tmp3;
       
   152 		TInt tmp11 = tmp1 + tmp2;
       
   153 		TInt tmp12 = tmp1 - tmp2;
       
   154 
       
   155 		tempPtr[0 * KJpgDCTBlockWidth] = ((tmp10 + tmp11) << PASS1_BITS);	// phase 3
       
   156 		tempPtr[4 * KJpgDCTBlockWidth] = ((tmp10 - tmp11) << PASS1_BITS);
       
   157 
       
   158 		TInt z1 = (tmp12 + tmp13) * FIX_0_707106781;
       
   159 		tempPtr[2 * KJpgDCTBlockWidth] = DESCALE(tmp13 + z1, CONST_BITS-PASS1_BITS); // phase 5
       
   160 		tempPtr[6 * KJpgDCTBlockWidth] = DESCALE(tmp13 - z1, CONST_BITS-PASS1_BITS);
       
   161 
       
   162 		// Odd part
       
   163 		tmp10 = tmp4 + tmp5;        // phase 2
       
   164 		tmp11 = tmp5 + tmp6;
       
   165 		tmp12 = tmp6 + tmp7;
       
   166 
       
   167 		// The rotator is modified from fig 4-8 to avoid extra negations.
       
   168 		TInt z5 = (tmp10 - tmp12) * FIX_0_382683433; // c6
       
   169 		TInt z2 = tmp10 * FIX_0_541196100 + z5; // c2-c6 
       
   170 		TInt z4 = tmp12 * FIX_1_306562965 + z5; // c2+c6 
       
   171 		TInt z3 = tmp11 * FIX_0_707106781; // c4 
       
   172 
       
   173 		TInt z11 = tmp7 + z3;            // phase 5 
       
   174 		TInt z13 = tmp7 - z3;
       
   175 
       
   176 		tempPtr[5 * KJpgDCTBlockWidth] = DESCALE(z13 + z2,CONST_BITS - PASS1_BITS);      // phase 6 
       
   177 		tempPtr[3 * KJpgDCTBlockWidth] = DESCALE(z13 - z2,CONST_BITS - PASS1_BITS);
       
   178 		tempPtr[1 * KJpgDCTBlockWidth] = DESCALE(z11 + z4,CONST_BITS - PASS1_BITS);
       
   179 		tempPtr[7 * KJpgDCTBlockWidth] = DESCALE(z11 - z4,CONST_BITS - PASS1_BITS);
       
   180 
       
   181 		srcPtr  += KJpgDCTBlockWidth;
       
   182 		tempPtr++;
       
   183 		} while (srcPtr < srcPtrLimit);
       
   184     }
       
   185 
       
   186 
       
   187 void TDCT::DoSecondStep(TDataUnit& aDestination,const TAligned64Du& aSource) const
       
   188     {
       
   189     TDataUnit::TDataUnitElemType* dstPtr= aDestination.iCoeff;
       
   190     const TInt* srcPtr                  = aSource.iData;
       
   191     const TInt* const srcPtrLimit       = srcPtr + KJpgDCTBlockSize;
       
   192 	do
       
   193 		{
       
   194 
       
   195         register TAligned64TwoCoeff tmp = *( reinterpret_cast<const TAligned64TwoCoeff*>(srcPtr + 0) );
       
   196         
       
   197 		TInt tmp0 = tmp.iData[0] + srcPtr[7];
       
   198 		TInt tmp7 = tmp.iData[0] - srcPtr[7];
       
   199 		TInt tmp1 = tmp.iData[1] + srcPtr[6];
       
   200 		TInt tmp6 = tmp.iData[1] - srcPtr[6];
       
   201 		
       
   202 		tmp = *( reinterpret_cast<const TAligned64TwoCoeff*>(srcPtr + 2) );
       
   203 		TInt tmp2 = tmp.iData[0] + srcPtr[5];
       
   204 		TInt tmp5 = tmp.iData[0] - srcPtr[5];
       
   205 		TInt tmp3 = tmp.iData[1] + srcPtr[4];
       
   206 		TInt tmp4 = tmp.iData[1] - srcPtr[4];
       
   207 
       
   208 		TInt tmp10 = tmp0 + tmp3;
       
   209 		TInt tmp13 = tmp0 - tmp3;
       
   210 		TInt tmp11 = tmp1 + tmp2;
       
   211 		TInt tmp12 = tmp1 - tmp2;
       
   212 
       
   213 		dstPtr[0 * KJpgDCTBlockWidth] = TInt16(DESCALE(tmp10 + tmp11, PASS1_BITS+3));
       
   214 		dstPtr[4 * KJpgDCTBlockWidth] = TInt16(DESCALE(tmp10 - tmp11, PASS1_BITS+3));
       
   215 
       
   216 		TInt z1 = (tmp12 + tmp13) * FIX_0_541196100;
       
   217 		dstPtr[2 * KJpgDCTBlockWidth] = TInt16(DESCALE(z1 + (tmp13 * FIX_0_765366865),CONST_BITS+PASS1_BITS+3));
       
   218 		dstPtr[6 * KJpgDCTBlockWidth] = TInt16(DESCALE(z1 + (tmp12 * - FIX_1_847759065),CONST_BITS+PASS1_BITS+3));
       
   219 
       
   220 		z1 = tmp4 + tmp7;
       
   221 		TInt z2 = tmp5 + tmp6;
       
   222 		TInt z3 = tmp4 + tmp6;
       
   223 		TInt z4 = tmp5 + tmp7;
       
   224 		TInt z5 = (z3 + z4) * FIX_1_175875602; /* sqrt(2) * c3 */
       
   225 
       
   226 		tmp4 = tmp4 * FIX_0_298631336; /* sqrt(2) * (-c1+c3+c5-c7) */
       
   227 		tmp5 = tmp5 * FIX_2_053119869; /* sqrt(2) * ( c1+c3-c5+c7) */
       
   228 		tmp6 = tmp6 * FIX_3_072711026; /* sqrt(2) * ( c1+c3+c5-c7) */
       
   229 		tmp7 = tmp7 * FIX_1_501321110; /* sqrt(2) * ( c1+c3-c5-c7) */
       
   230 		z1 = z1 * - FIX_0_899976223; /* sqrt(2) * (c7-c3) */
       
   231 		z2 = z2 * - FIX_2_562915447; /* sqrt(2) * (-c1-c3) */
       
   232 		z3 = z3 * - FIX_1_961570560; /* sqrt(2) * (-c3-c5) */
       
   233 		z4 = z4 * - FIX_0_390180644; /* sqrt(2) * (c5-c3) */
       
   234 
       
   235 		z3 += z5;
       
   236 		z4 += z5;
       
   237 
       
   238 		dstPtr[7 * KJpgDCTBlockWidth] = TInt16(DESCALE(tmp4 + z1 + z3,CONST_BITS+PASS1_BITS+3));
       
   239 		dstPtr[5 * KJpgDCTBlockWidth] = TInt16(DESCALE(tmp5 + z2 + z4,CONST_BITS+PASS1_BITS+3));
       
   240 		dstPtr[3 * KJpgDCTBlockWidth] = TInt16(DESCALE(tmp6 + z2 + z3,CONST_BITS+PASS1_BITS+3));
       
   241 		dstPtr[1 * KJpgDCTBlockWidth] = TInt16(DESCALE(tmp7 + z1 + z4,CONST_BITS+PASS1_BITS+3));
       
   242 
       
   243 		srcPtr+=KJpgDCTBlockWidth;
       
   244 		dstPtr++;
       
   245 		} while (srcPtr < srcPtrLimit);
       
   246     }
       
   247 
       
   248 // based on code from jfdctfst.c
       
   249 void TDCT::DoFastSecondStep(TDataUnit& aDestination,const TAligned64Du& aSource) const
       
   250     {
       
   251     TDataUnit::TDataUnitElemType* dstPtr= aDestination.iCoeff;
       
   252     const TInt* srcPtr                  = aSource.iData;
       
   253     const TInt* const srcPtrLimit       = srcPtr + KJpgDCTBlockSize;
       
   254 	do
       
   255 		{
       
   256 		register TAligned64TwoCoeff tmp = *( reinterpret_cast<const TAligned64TwoCoeff*>(srcPtr + 0) );
       
   257         
       
   258 		TInt tmp0 = tmp.iData[0] + srcPtr[7];
       
   259 		TInt tmp7 = tmp.iData[0] - srcPtr[7];
       
   260 		TInt tmp1 = tmp.iData[1] + srcPtr[6];
       
   261 		TInt tmp6 = tmp.iData[1] - srcPtr[6];
       
   262 		
       
   263 		tmp = *( reinterpret_cast<const TAligned64TwoCoeff*>(srcPtr + 2) );
       
   264 		TInt tmp2 = tmp.iData[0] + srcPtr[5];
       
   265 		TInt tmp5 = tmp.iData[0] - srcPtr[5];
       
   266 		TInt tmp3 = tmp.iData[1] + srcPtr[4];
       
   267 		TInt tmp4 = tmp.iData[1] - srcPtr[4];
       
   268 
       
   269 		TInt tmp10 = tmp0 + tmp3; // phase 2
       
   270 		TInt tmp13 = tmp0 - tmp3;
       
   271 		TInt tmp11 = tmp1 + tmp2;
       
   272 		TInt tmp12 = tmp1 - tmp2;
       
   273 
       
   274 		dstPtr[0 * KJpgDCTBlockWidth] = TInt16(DESCALE(tmp10 + tmp11, PASS1_BITS+3)); // phase 3
       
   275 		dstPtr[4 * KJpgDCTBlockWidth] = TInt16(DESCALE(tmp10 - tmp11, PASS1_BITS+3));
       
   276 
       
   277 		TInt z1 = (tmp12 + tmp13) * FIX_0_707106781; // c4
       
   278 		dstPtr[2 * KJpgDCTBlockWidth] = TInt16(DESCALE(tmp13 + z1, CONST_BITS+PASS1_BITS+3)); // phase 5
       
   279 		dstPtr[6 * KJpgDCTBlockWidth] = TInt16(DESCALE(tmp13 - z1, CONST_BITS+PASS1_BITS+3));
       
   280 
       
   281 		
       
   282 		// Odd part
       
   283 		tmp10 = tmp4 + tmp5;        // phase 2
       
   284 		tmp11 = tmp5 + tmp6;
       
   285 		tmp12 = tmp6 + tmp7;
       
   286 
       
   287 		// The rotator is modified from fig 4-8 to avoid extra negations.
       
   288 		TInt z5 = (tmp10 - tmp12) * FIX_0_382683433; // c6
       
   289 		TInt z2 = tmp10 * FIX_0_541196100 + z5; // c2-c6
       
   290 		TInt z4 = tmp12 * FIX_1_306562965 + z5; // c2+c6
       
   291 		TInt z3 = tmp11 * FIX_0_707106781; // c4
       
   292 
       
   293 		TInt z11 = tmp7 + z3;            // phase 5
       
   294 		TInt z13 = tmp7 - z3;
       
   295 
       
   296 		dstPtr[5 * KJpgDCTBlockWidth] = TInt16(DESCALE(z13 + z2, CONST_BITS+PASS1_BITS+3)); // phase 6
       
   297 		dstPtr[3 * KJpgDCTBlockWidth] = TInt16(DESCALE(z13 - z2, CONST_BITS+PASS1_BITS+3));
       
   298 		dstPtr[1 * KJpgDCTBlockWidth] = TInt16(DESCALE(z11 + z4, CONST_BITS+PASS1_BITS+3));
       
   299 		dstPtr[7 * KJpgDCTBlockWidth] = TInt16(DESCALE(z11 - z4, CONST_BITS+PASS1_BITS+3));
       
   300 
       
   301 		srcPtr+=KJpgDCTBlockWidth;
       
   302 		dstPtr++;
       
   303 		} while (srcPtr < srcPtrLimit);
       
   304     }
       
   305 
       
   306 
       
   307 void TDCT::InverseTransform(TDataUnit& aDestination,const TDataUnit& aSource) const
       
   308 	{
       
   309 	const TInt16* srcPtr = aSource.iCoeff;
       
   310 	TInt16* dstPtr = aDestination.iCoeff;
       
   311 
       
   312 	TInt temp[KJpgDCTBlockSize];
       
   313 	TInt* tempPtr = temp;
       
   314 	TInt* tempPtrLimit = temp + KJpgDCTBlockWidth;
       
   315 
       
   316 	do
       
   317 		{
       
   318 		TInt z2 = srcPtr[2 * KJpgDCTBlockWidth];
       
   319 		TInt z3 = srcPtr[6 * KJpgDCTBlockWidth];
       
   320 
       
   321 		if (z2 == 0 && z3 == 0 && srcPtr[1 * KJpgDCTBlockWidth] == 0 && 
       
   322 			srcPtr[3 * KJpgDCTBlockWidth] == 0 && srcPtr[4 * KJpgDCTBlockWidth] == 0 &&
       
   323 			srcPtr[5 * KJpgDCTBlockWidth] == 0 && 
       
   324 			srcPtr[7 * KJpgDCTBlockWidth] == 0)
       
   325 			{
       
   326 			TInt dcval = srcPtr[0] << PASS1_BITS;
       
   327 
       
   328 			tempPtr[0 * KJpgDCTBlockWidth] = dcval;
       
   329 			tempPtr[1 * KJpgDCTBlockWidth] = dcval;
       
   330 			tempPtr[2 * KJpgDCTBlockWidth] = dcval;
       
   331 			tempPtr[3 * KJpgDCTBlockWidth] = dcval;
       
   332 			tempPtr[4 * KJpgDCTBlockWidth] = dcval;
       
   333 			tempPtr[5 * KJpgDCTBlockWidth] = dcval;
       
   334 			tempPtr[6 * KJpgDCTBlockWidth] = dcval;
       
   335 			tempPtr[7 * KJpgDCTBlockWidth] = dcval;
       
   336 
       
   337 			srcPtr++;
       
   338 			tempPtr++;
       
   339 			continue;
       
   340 			}
       
   341 
       
   342 		TInt z1 = (z2 + z3) * FIX_0_541196100;
       
   343 		TInt tmp2 = z1 + (z3 * - FIX_1_847759065);
       
   344 		TInt tmp3 = z1 + (z2 * FIX_0_765366865);
       
   345 
       
   346 		z2 = srcPtr[0 * KJpgDCTBlockWidth];
       
   347 		z3 = srcPtr[4 * KJpgDCTBlockWidth];
       
   348 
       
   349 		TInt tmp0 = (z2 + z3) << CONST_BITS;
       
   350 		TInt tmp1 = (z2 - z3) << CONST_BITS;
       
   351 
       
   352 		const TInt tmp10 = tmp0 + tmp3;
       
   353 		const TInt tmp13 = tmp0 - tmp3;
       
   354 		const TInt tmp11 = tmp1 + tmp2;
       
   355 		const TInt tmp12 = tmp1 - tmp2;
       
   356 
       
   357 		tmp0 = srcPtr[7 * KJpgDCTBlockWidth];
       
   358 		tmp1 = srcPtr[5 * KJpgDCTBlockWidth];
       
   359 		tmp2 = srcPtr[3 * KJpgDCTBlockWidth];
       
   360 		tmp3 = srcPtr[1 * KJpgDCTBlockWidth];
       
   361 
       
   362 		z1 = tmp0 + tmp3;
       
   363 		z2 = tmp1 + tmp2;
       
   364 		z3 = tmp0 + tmp2;
       
   365 		TInt z4 = tmp1 + tmp3;
       
   366 		const TInt z5 = (z3 + z4) * FIX_1_175875602;
       
   367 
       
   368 		tmp0 = tmp0 * FIX_0_298631336;
       
   369 		tmp1 = tmp1 * FIX_2_053119869;
       
   370 		tmp2 = tmp2 * FIX_3_072711026;
       
   371 		tmp3 = tmp3 * FIX_1_501321110;
       
   372 		z1 = z1 * - FIX_0_899976223;
       
   373 		z2 = z2 * - FIX_2_562915447;
       
   374 		z3 = z3 * - FIX_1_961570560;
       
   375 		z4 = z4 * - FIX_0_390180644;
       
   376 
       
   377 		z3 += z5;
       
   378 		z4 += z5;
       
   379 
       
   380 		tmp0 += z1 + z3;
       
   381 		tmp1 += z2 + z4;
       
   382 		tmp2 += z2 + z3;
       
   383 		tmp3 += z1 + z4;
       
   384 
       
   385 		tempPtr[0 * KJpgDCTBlockWidth] = DESCALE(tmp10 + tmp3, CONST_BITS - PASS1_BITS);
       
   386 		tempPtr[7 * KJpgDCTBlockWidth] = DESCALE(tmp10 - tmp3, CONST_BITS - PASS1_BITS);
       
   387 		tempPtr[1 * KJpgDCTBlockWidth] = DESCALE(tmp11 + tmp2, CONST_BITS - PASS1_BITS);
       
   388 		tempPtr[6 * KJpgDCTBlockWidth] = DESCALE(tmp11 - tmp2, CONST_BITS - PASS1_BITS);
       
   389 		tempPtr[2 * KJpgDCTBlockWidth] = DESCALE(tmp12 + tmp1, CONST_BITS - PASS1_BITS);
       
   390 		tempPtr[5 * KJpgDCTBlockWidth] = DESCALE(tmp12 - tmp1, CONST_BITS - PASS1_BITS);
       
   391 		tempPtr[3 * KJpgDCTBlockWidth] = DESCALE(tmp13 + tmp0, CONST_BITS - PASS1_BITS);
       
   392 		tempPtr[4 * KJpgDCTBlockWidth] = DESCALE(tmp13 - tmp0, CONST_BITS - PASS1_BITS);
       
   393 
       
   394 		srcPtr++;
       
   395 		tempPtr++;
       
   396 		} while (tempPtr < tempPtrLimit);
       
   397 
       
   398 	tempPtr = temp;
       
   399 	tempPtrLimit = temp + KJpgDCTBlockSize;
       
   400 
       
   401 	do
       
   402 		{
       
   403 		TInt z2 = tempPtr[2];
       
   404 		TInt z3 = tempPtr[6];
       
   405 		const TInt t4 = tempPtr[4];
       
   406 		
       
   407 		if (z2 == 0 && z3 == 0 && tempPtr[1] == 0 && t4 == 0 && tempPtr[3] == 0 && 
       
   408 			tempPtr[5] == 0 && tempPtr[7] == 0)
       
   409 			{
       
   410 			TUint16 dcval = TUint16( TInt16(DESCALE(tempPtr[0], PASS1_BITS+3) + iLevelShift) );
       
   411 			TUint64 w=MAKE_TUINT64( ((dcval << 16) | (dcval)), ((dcval << 16) | dcval) );
       
   412 
       
   413 			*(0 + reinterpret_cast<TUint64*>(dstPtr) ) = w;
       
   414 			*(1 + reinterpret_cast<TUint64*>(dstPtr) ) = w;
       
   415 			
       
   416 			dstPtr += KJpgDCTBlockWidth;
       
   417 			tempPtr += KJpgDCTBlockWidth;
       
   418 			continue;
       
   419 			}
       
   420 
       
   421 		TInt z1 = (z2 + z3) * FIX_0_541196100;
       
   422 		TInt tmp2 = z1 + (z3 * - FIX_1_847759065);
       
   423 		TInt tmp3 = z1 + (z2 * FIX_0_765366865);
       
   424 
       
   425 		TInt tmp0 = (tempPtr[0] + t4) << CONST_BITS;
       
   426 		TInt tmp1 = (tempPtr[0] - t4) << CONST_BITS;
       
   427 
       
   428 		const TInt tmp10 = tmp0 + tmp3;
       
   429 		const TInt tmp13 = tmp0 - tmp3;
       
   430 		const TInt tmp11 = tmp1 + tmp2;
       
   431 		const TInt tmp12 = tmp1 - tmp2;
       
   432 
       
   433 		tmp0 = tempPtr[7];
       
   434 		tmp1 = tempPtr[5];
       
   435 		tmp2 = tempPtr[3];
       
   436 		tmp3 = tempPtr[1];
       
   437 
       
   438 		z1 = tmp0 + tmp3;
       
   439 		z2 = tmp1 + tmp2;
       
   440 		z3 = tmp0 + tmp2;
       
   441 		TInt z4 = tmp1 + tmp3;
       
   442 		const TInt z5 = (z3 + z4) * FIX_1_175875602;
       
   443 
       
   444 		tmp0 = tmp0 * FIX_0_298631336;
       
   445 		tmp1 = tmp1 * FIX_2_053119869;
       
   446 		tmp2 = tmp2 * FIX_3_072711026;
       
   447 		tmp3 = tmp3 * FIX_1_501321110;
       
   448 
       
   449 		z1 = z1 * - FIX_0_899976223;
       
   450 		z2 = z2 * - FIX_2_562915447;
       
   451 		z3 = z3 * - FIX_1_961570560;
       
   452 		z4 = z4 * - FIX_0_390180644;
       
   453 
       
   454 		z3 += z5;
       
   455 		z4 += z5;
       
   456 
       
   457 		tmp0 += z1 + z3;
       
   458 		tmp1 += z2 + z4;
       
   459 		tmp2 += z2 + z3;
       
   460 		tmp3 += z1 + z4;
       
   461 
       
   462 		const TInt KLevelShift = iLevelShift;
       
   463 		dstPtr[0] = TInt16(DESCALE(tmp10 + tmp3,CONST_BITS+PASS1_BITS+3) + KLevelShift);
       
   464 		dstPtr[7] = TInt16(DESCALE(tmp10 - tmp3,CONST_BITS+PASS1_BITS+3) + KLevelShift);
       
   465 		dstPtr[1] = TInt16(DESCALE(tmp11 + tmp2,CONST_BITS+PASS1_BITS+3) + KLevelShift);
       
   466 		dstPtr[6] = TInt16(DESCALE(tmp11 - tmp2,CONST_BITS+PASS1_BITS+3) + KLevelShift);
       
   467 		dstPtr[2] = TInt16(DESCALE(tmp12 + tmp1,CONST_BITS+PASS1_BITS+3) + KLevelShift);
       
   468 		dstPtr[5] = TInt16(DESCALE(tmp12 - tmp1,CONST_BITS+PASS1_BITS+3) + KLevelShift);
       
   469 		dstPtr[3] = TInt16(DESCALE(tmp13 + tmp0,CONST_BITS+PASS1_BITS+3) + KLevelShift);
       
   470 		dstPtr[4] = TInt16(DESCALE(tmp13 - tmp0,CONST_BITS+PASS1_BITS+3) + KLevelShift);
       
   471 
       
   472 		tempPtr += KJpgDCTBlockWidth;
       
   473 		dstPtr += KJpgDCTBlockWidth;
       
   474 		} while (tempPtr < tempPtrLimit);
       
   475 	}
       
   476 
       
   477 
       
   478 // THalfDCT
       
   479 void THalfDCT::InverseTransform(TDataUnit& aDestination,const TDataUnit& aSource) const
       
   480 	{
       
   481 	const TInt16* srcPtr = aSource.iCoeff;
       
   482 	TInt16* dstPtr = aDestination.iCoeff;
       
   483 
       
   484 	TInt temp[KJpgDCTBlockSize];
       
   485 	TInt* tempPtr = temp;
       
   486 	TInt* tempPtrLimit = temp + KJpgDCTBlockWidth;
       
   487 
       
   488 	while (tempPtr < tempPtrLimit)
       
   489 		{
       
   490 		TInt z2 = srcPtr[2 * KJpgDCTBlockWidth];
       
   491 		
       
   492 		if (z2 == 0 && srcPtr[1 * KJpgDCTBlockWidth] == 0 && 
       
   493 			srcPtr[3 * KJpgDCTBlockWidth] == 0)
       
   494 			{
       
   495 			TInt dcval = srcPtr[0] << PASS1_BITS;
       
   496 
       
   497 			tempPtr[0 * KJpgDCTBlockWidth] = dcval;
       
   498 			tempPtr[1 * KJpgDCTBlockWidth] = dcval;
       
   499 			tempPtr[2 * KJpgDCTBlockWidth] = dcval;
       
   500 			tempPtr[3 * KJpgDCTBlockWidth] = dcval;
       
   501 			tempPtr[4 * KJpgDCTBlockWidth] = dcval;
       
   502 			tempPtr[5 * KJpgDCTBlockWidth] = dcval;
       
   503 			tempPtr[6 * KJpgDCTBlockWidth] = dcval;
       
   504 			tempPtr[7 * KJpgDCTBlockWidth] = dcval;
       
   505 
       
   506 			srcPtr++;
       
   507 			tempPtr++;
       
   508 			continue;
       
   509 			}
       
   510 
       
   511 		TInt z1 = z2 * FIX_0_541196100;
       
   512 		TInt tmp2 = z1;
       
   513 		TInt tmp3 = z1 + (z2 * FIX_0_765366865);
       
   514 
       
   515 		z2 = srcPtr[0 * KJpgDCTBlockWidth];
       
   516 
       
   517 		TInt tmp0 = z2 << CONST_BITS;
       
   518 
       
   519 		const TInt tmp10 = tmp0 + tmp3;
       
   520 		const TInt tmp13 = tmp0 - tmp3;
       
   521 		const TInt tmp11 = tmp0 + tmp2;
       
   522 		const TInt tmp12 = tmp0 - tmp2;
       
   523 
       
   524 		tmp2 = srcPtr[3 * KJpgDCTBlockWidth];
       
   525 		tmp3 = srcPtr[1 * KJpgDCTBlockWidth];
       
   526 
       
   527 		z1 = tmp3;
       
   528 		z2 = tmp2;
       
   529 		TInt z3 = tmp2;
       
   530 		TInt z4 = tmp3;
       
   531 		const TInt z5 = (z3 + z4) * FIX_1_175875602;
       
   532 
       
   533 		tmp2 = tmp2 * FIX_3_072711026;
       
   534 		tmp3 = tmp3 * FIX_1_501321110;
       
   535 		z1 = z1 * - FIX_0_899976223;
       
   536 		z2 = z2 * - FIX_2_562915447;
       
   537 		z3 = z3 * - FIX_1_961570560;
       
   538 		z4 = z4 * - FIX_0_390180644;
       
   539 
       
   540 		z3 += z5;
       
   541 		z4 += z5;
       
   542 
       
   543 		tmp0 = z1 + z3;
       
   544 		const TInt tmp1 = z2 + z4;
       
   545 		tmp2 += z2 + z3;
       
   546 		tmp3 += z1 + z4;
       
   547 
       
   548 		tempPtr[0 * KJpgDCTBlockWidth] = DESCALE(tmp10 + tmp3, CONST_BITS - PASS1_BITS);
       
   549 		tempPtr[7 * KJpgDCTBlockWidth] = DESCALE(tmp10 - tmp3, CONST_BITS - PASS1_BITS);
       
   550 		tempPtr[1 * KJpgDCTBlockWidth] = DESCALE(tmp11 + tmp2, CONST_BITS - PASS1_BITS);
       
   551 		tempPtr[6 * KJpgDCTBlockWidth] = DESCALE(tmp11 - tmp2, CONST_BITS - PASS1_BITS);
       
   552 		tempPtr[2 * KJpgDCTBlockWidth] = DESCALE(tmp12 + tmp1, CONST_BITS - PASS1_BITS);
       
   553 		tempPtr[5 * KJpgDCTBlockWidth] = DESCALE(tmp12 - tmp1, CONST_BITS - PASS1_BITS);
       
   554 		tempPtr[3 * KJpgDCTBlockWidth] = DESCALE(tmp13 + tmp0, CONST_BITS - PASS1_BITS);
       
   555 		tempPtr[4 * KJpgDCTBlockWidth] = DESCALE(tmp13 - tmp0, CONST_BITS - PASS1_BITS);
       
   556 
       
   557 		srcPtr++;
       
   558 		tempPtr++;
       
   559 		}
       
   560 
       
   561 	tempPtr = temp;
       
   562 	tempPtrLimit = temp + KJpgDCTBlockSize;
       
   563 
       
   564 	while (tempPtr < tempPtrLimit)
       
   565 		{
       
   566 		TInt z2 = tempPtr[2];
       
   567 		
       
   568 		if (z2 == 0 && tempPtr[1] == 0 && tempPtr[3] == 0)
       
   569 			{
       
   570 			TUint16 dcval = TUint16( TInt16(DESCALE(tempPtr[0], PASS1_BITS+3) + iLevelShift) );
       
   571 			TUint64 w=MAKE_TUINT64( ((dcval << 16) | (dcval)), ((dcval << 16) | dcval) );
       
   572 
       
   573 			*(0 + reinterpret_cast<TUint64*>(dstPtr) ) = w;
       
   574 			*(1 + reinterpret_cast<TUint64*>(dstPtr) ) = w;
       
   575 			
       
   576 			dstPtr += KJpgDCTBlockWidth;
       
   577 			tempPtr += KJpgDCTBlockWidth;
       
   578 			continue;
       
   579 			}
       
   580 
       
   581 		TInt z1 = z2 * FIX_0_541196100;
       
   582 		TInt tmp2 = z1;
       
   583 		TInt tmp3 = z1 + (z2 * FIX_0_765366865);
       
   584 
       
   585 		TInt tmp0 = tempPtr[0] << CONST_BITS;
       
   586 
       
   587 		const TInt tmp10 = tmp0 + tmp3;
       
   588 		const TInt tmp13 = tmp0 - tmp3;
       
   589 		const TInt tmp11 = tmp0 + tmp2;
       
   590 		const TInt tmp12 = tmp0 - tmp2;
       
   591 
       
   592 		tmp2 = tempPtr[3];
       
   593 		tmp3 = tempPtr[1];
       
   594 
       
   595 		z1 = tmp3;
       
   596 		z2 = tmp2;
       
   597 		TInt z3 = tmp2;
       
   598 		TInt z4 = tmp3;
       
   599 		const TInt z5 = (z3 + z4) * FIX_1_175875602;
       
   600 
       
   601 		tmp2 = tmp2 * FIX_3_072711026;
       
   602 		tmp3 = tmp3 * FIX_1_501321110;
       
   603 
       
   604 		z1 = z1 * - FIX_0_899976223;
       
   605 		z2 = z2 * - FIX_2_562915447;
       
   606 		z3 = z3 * - FIX_1_961570560;
       
   607 		z4 = z4 * - FIX_0_390180644;
       
   608 
       
   609 		z3 += z5;
       
   610 		z4 += z5;
       
   611 
       
   612 		tmp0 = z1 + z3;
       
   613 		const TInt tmp1 = z2 + z4;
       
   614 		tmp2 += z2 + z3;
       
   615 		tmp3 += z1 + z4;
       
   616 
       
   617 		const TInt KLevelShift = iLevelShift;
       
   618 		dstPtr[0] = TInt16(DESCALE(tmp10 + tmp3,CONST_BITS+PASS1_BITS+3) + KLevelShift);
       
   619 		dstPtr[7] = TInt16(DESCALE(tmp10 - tmp3,CONST_BITS+PASS1_BITS+3) + KLevelShift);
       
   620 		dstPtr[1] = TInt16(DESCALE(tmp11 + tmp2,CONST_BITS+PASS1_BITS+3) + KLevelShift);
       
   621 		dstPtr[6] = TInt16(DESCALE(tmp11 - tmp2,CONST_BITS+PASS1_BITS+3) + KLevelShift);
       
   622 		dstPtr[2] = TInt16(DESCALE(tmp12 + tmp1,CONST_BITS+PASS1_BITS+3) + KLevelShift);
       
   623 		dstPtr[5] = TInt16(DESCALE(tmp12 - tmp1,CONST_BITS+PASS1_BITS+3) + KLevelShift);
       
   624 		dstPtr[3] = TInt16(DESCALE(tmp13 + tmp0,CONST_BITS+PASS1_BITS+3) + KLevelShift);
       
   625 		dstPtr[4] = TInt16(DESCALE(tmp13 - tmp0,CONST_BITS+PASS1_BITS+3) + KLevelShift);
       
   626 
       
   627 		tempPtr += KJpgDCTBlockWidth;
       
   628 		dstPtr += KJpgDCTBlockWidth;
       
   629 		}
       
   630 	}
       
   631 
       
   632 //TFastHalfDCT 
       
   633 void TFastHalfDCT::InverseTransform(TDataUnit& aDestination,const TDataUnit& aSource) const
       
   634 	{
       
   635 	const TInt KScalingFactor = 2;
       
   636 	const TInt16* srcPtr = aSource.iCoeff;
       
   637 	TInt16* dstPtr = aDestination.iCoeff;
       
   638 	
       
   639 	TInt temp[KJpgDCTBlockSize/KScalingFactor];
       
   640 	
       
   641 	TInt* tempPtr = temp;
       
   642 	TInt* tempPtrLimit = temp + KJpgDCTBlockWidth / KScalingFactor; // scaling factor
       
   643 
       
   644 	do 
       
   645 		{
       
   646 		TInt z2 = srcPtr[2 * KJpgDCTBlockWidth];
       
   647 		
       
   648 		if ( z2 == 0 && srcPtr[1 * KJpgDCTBlockWidth] == 0 && srcPtr[3 * KJpgDCTBlockWidth] == 0)
       
   649 			{
       
   650 			TInt dcval = srcPtr[0] << PASS1_BITS;
       
   651 
       
   652 			tempPtr[0 * KJpgDCTBlockWidth / KScalingFactor] = dcval;
       
   653 			tempPtr[2 * KJpgDCTBlockWidth / KScalingFactor] = dcval;
       
   654 			tempPtr[4 * KJpgDCTBlockWidth / KScalingFactor] = dcval;
       
   655 			tempPtr[6 * KJpgDCTBlockWidth / KScalingFactor] = dcval;
       
   656 
       
   657 			srcPtr++;
       
   658 			tempPtr++;
       
   659 			continue;
       
   660 			}
       
   661 
       
   662 		TInt z1 	= z2 * FIX_0_541196100;
       
   663 		TInt tmp2 	= z1;
       
   664 		TInt tmp3 	= z1 + (z2 * FIX_0_765366865);
       
   665 
       
   666 		z2 = srcPtr[0 * KJpgDCTBlockWidth];
       
   667 
       
   668 		TInt tmp0 = z2 << CONST_BITS;
       
   669 
       
   670 		const TInt tmp10 = tmp0 + tmp3;
       
   671 		const TInt tmp13 = tmp0 - tmp3;
       
   672 		const TInt tmp11 = tmp0 + tmp2;
       
   673 		const TInt tmp12 = tmp0 - tmp2;
       
   674 
       
   675 		tmp2 = srcPtr[3 * KJpgDCTBlockWidth];
       
   676 		tmp3 = srcPtr[1 * KJpgDCTBlockWidth];
       
   677 
       
   678 		z1 = tmp3;
       
   679 		z2 = tmp2;
       
   680 		TInt z3 = tmp2;
       
   681 		TInt z4 = tmp3;
       
   682 		const TInt z5 = (z3 + z4) * FIX_1_175875602;
       
   683 
       
   684 		tmp2 = tmp2 * FIX_3_072711026;
       
   685 		tmp3 = tmp3 * FIX_1_501321110;
       
   686 		z1 = z1 * - FIX_0_899976223;
       
   687 		z2 = z2 * - FIX_2_562915447;
       
   688 		z3 = z3 * - FIX_1_961570560;
       
   689 		z4 = z4 * - FIX_0_390180644;
       
   690 
       
   691 		z3 += z5;
       
   692 		z4 += z5;
       
   693 
       
   694 		tmp0 = z1 + z3;
       
   695 		const TInt tmp1 = z2 + z4;
       
   696 		tmp2 += z2 + z3;
       
   697 		tmp3 += z1 + z4;
       
   698 
       
   699 		tempPtr[0 * KJpgDCTBlockWidth / KScalingFactor] = DESCALE(tmp10 + tmp3, CONST_BITS - PASS1_BITS);
       
   700 		tempPtr[2 * KJpgDCTBlockWidth / KScalingFactor] = DESCALE(tmp12 + tmp1, CONST_BITS - PASS1_BITS);
       
   701 		tempPtr[4 * KJpgDCTBlockWidth / KScalingFactor] = DESCALE(tmp13 - tmp0, CONST_BITS - PASS1_BITS);
       
   702 		tempPtr[6 * KJpgDCTBlockWidth / KScalingFactor] = DESCALE(tmp11 - tmp2, CONST_BITS - PASS1_BITS);
       
   703 		
       
   704 		srcPtr++;
       
   705 		tempPtr++;
       
   706 		
       
   707 		} while (tempPtr < tempPtrLimit);
       
   708 		
       
   709 	tempPtr = temp;
       
   710 	tempPtrLimit = temp + KJpgDCTBlockSize / KScalingFactor;
       
   711 
       
   712 	do 
       
   713 		{
       
   714 		TInt z2 = tempPtr[2];
       
   715 
       
   716 		if ( z2 == 0 && tempPtr[1] == 0 && tempPtr[3] == 0)
       
   717 			{
       
   718 			TInt16 dcval = TInt16(DESCALE(tempPtr[0], PASS1_BITS+3) + iLevelShift);
       
   719 
       
   720 			dstPtr[0] = dcval;
       
   721 			dstPtr[2] = dcval;
       
   722 			dstPtr[4] = dcval;
       
   723 			dstPtr[6] = dcval;
       
   724 
       
   725 			tempPtr += KJpgDCTBlockWidth;
       
   726 			dstPtr 	+= KScalingFactor*KJpgDCTBlockWidth;
       
   727 			continue;
       
   728 			}
       
   729 
       
   730 		TInt z1 = z2 * FIX_0_541196100;
       
   731 		TInt tmp2 = z1;
       
   732 		TInt tmp3 = z1 + (z2 * FIX_0_765366865);
       
   733 
       
   734 		TInt tmp0 = tempPtr[0] << CONST_BITS;
       
   735 
       
   736 		const TInt tmp10 = tmp0 + tmp3;
       
   737 		const TInt tmp13 = tmp0 - tmp3;
       
   738 		const TInt tmp11 = tmp0 + tmp2;
       
   739 		const TInt tmp12 = tmp0 - tmp2;
       
   740 
       
   741 		tmp2 = tempPtr[3];
       
   742 		tmp3 = tempPtr[1];
       
   743 
       
   744 		z1 = tmp3;
       
   745 		z2 = tmp2;
       
   746 		TInt z3 = tmp2;
       
   747 		TInt z4 = tmp3;
       
   748 		TInt z5 = (z3 + z4) * FIX_1_175875602;
       
   749 
       
   750 		tmp2 = tmp2 * FIX_3_072711026;
       
   751 		tmp3 = tmp3 * FIX_1_501321110;
       
   752 
       
   753 		z1 = z1 * - FIX_0_899976223;
       
   754 		z2 = z2 * - FIX_2_562915447;
       
   755 		z3 = z3 * - FIX_1_961570560;
       
   756 		z4 = z4 * - FIX_0_390180644;
       
   757 
       
   758 		z3 += z5;
       
   759 		z4 += z5;
       
   760 
       
   761 		tmp0 = z1 + z3;
       
   762 		const TInt tmp1 = z2 + z4;
       
   763 		tmp2 += z2 + z3;
       
   764 		tmp3 += z1 + z4;
       
   765 
       
   766 		const TInt KLevelShift = iLevelShift;
       
   767 		dstPtr[0] = TInt16(DESCALE(tmp10 + tmp3,CONST_BITS+PASS1_BITS+3) + KLevelShift);
       
   768 		dstPtr[2] = TInt16(DESCALE(tmp12 + tmp1,CONST_BITS+PASS1_BITS+3) + KLevelShift);
       
   769 		dstPtr[4] = TInt16(DESCALE(tmp13 - tmp0,CONST_BITS+PASS1_BITS+3) + KLevelShift);
       
   770 		dstPtr[6] = TInt16(DESCALE(tmp11 - tmp2,CONST_BITS+PASS1_BITS+3) + KLevelShift);
       
   771 
       
   772 		tempPtr += KJpgDCTBlockWidth;
       
   773 		dstPtr 	+= KScalingFactor*KJpgDCTBlockWidth;
       
   774 		
       
   775 		} while (tempPtr < tempPtrLimit);
       
   776 	}
       
   777 
       
   778 // TQuarterDCT
       
   779 void TQuarterDCT::InverseTransform(TDataUnit& aDestination,const TDataUnit& aSource) const
       
   780 	{
       
   781 	const TInt16* srcPtr = aSource.iCoeff;
       
   782 	TInt16* dstPtr = aDestination.iCoeff;
       
   783 	
       
   784 	TInt temp[KJpgDCTBlockSize];
       
   785 	TInt* tempPtr = temp;
       
   786 	TInt* tempPtrLimit = temp + KJpgDCTBlockWidth;
       
   787 
       
   788 	do
       
   789 		{
       
   790 		TInt tmp3 = srcPtr[1 * KJpgDCTBlockWidth];
       
   791 		
       
   792 		if (tmp3 == 0)
       
   793 			{
       
   794 			TInt dcval = srcPtr[0] << PASS1_BITS;
       
   795 
       
   796 			tempPtr[0 * KJpgDCTBlockWidth] = dcval;
       
   797 			tempPtr[1 * KJpgDCTBlockWidth] = dcval;
       
   798 			tempPtr[2 * KJpgDCTBlockWidth] = dcval;
       
   799 			tempPtr[3 * KJpgDCTBlockWidth] = dcval;
       
   800 			tempPtr[4 * KJpgDCTBlockWidth] = dcval;
       
   801 			tempPtr[5 * KJpgDCTBlockWidth] = dcval;
       
   802 			tempPtr[6 * KJpgDCTBlockWidth] = dcval;
       
   803 			tempPtr[7 * KJpgDCTBlockWidth] = dcval;
       
   804 
       
   805 			srcPtr++;
       
   806 			tempPtr++;
       
   807 			continue;
       
   808 			}
       
   809 
       
   810 		TInt z2 = srcPtr[0 * KJpgDCTBlockWidth];
       
   811 
       
   812 		TInt tmp0 = z2 << CONST_BITS;
       
   813 
       
   814 		TInt tmp10 = tmp0;
       
   815 
       
   816 		TInt z1 = tmp3;
       
   817 		TInt z4 = tmp3;
       
   818 		TInt z5 = z4 * FIX_1_175875602;
       
   819 
       
   820 		tmp3 = tmp3 * FIX_1_501321110;
       
   821 		z1 = z1 * - FIX_0_899976223;
       
   822 		z4 = z4 * - FIX_0_390180644;
       
   823 
       
   824 		const TInt z3 = z5;
       
   825 		z4 += z5;
       
   826 
       
   827 		tmp0 = z1 + z3;
       
   828 		const TInt tmp1 = z4;
       
   829 		const TInt tmp2 = z3;
       
   830 		tmp3 += z1 + z4;
       
   831 
       
   832 		tempPtr[0 * KJpgDCTBlockWidth] = DESCALE(tmp10 + tmp3, CONST_BITS - PASS1_BITS);
       
   833 		tempPtr[7 * KJpgDCTBlockWidth] = DESCALE(tmp10 - tmp3, CONST_BITS - PASS1_BITS);
       
   834 		tempPtr[1 * KJpgDCTBlockWidth] = DESCALE(tmp10 + tmp2, CONST_BITS - PASS1_BITS);
       
   835 		tempPtr[6 * KJpgDCTBlockWidth] = DESCALE(tmp10 - tmp2, CONST_BITS - PASS1_BITS);
       
   836 		tempPtr[2 * KJpgDCTBlockWidth] = DESCALE(tmp10 + tmp1, CONST_BITS - PASS1_BITS);
       
   837 		tempPtr[5 * KJpgDCTBlockWidth] = DESCALE(tmp10 - tmp1, CONST_BITS - PASS1_BITS);
       
   838 		tempPtr[3 * KJpgDCTBlockWidth] = DESCALE(tmp10 + tmp0, CONST_BITS - PASS1_BITS);
       
   839 		tempPtr[4 * KJpgDCTBlockWidth] = DESCALE(tmp10 - tmp0, CONST_BITS - PASS1_BITS);
       
   840 
       
   841 		srcPtr++;
       
   842 		tempPtr++;
       
   843 		} while (tempPtr < tempPtrLimit);
       
   844 
       
   845 	tempPtr = temp;
       
   846 	tempPtrLimit = temp + KJpgDCTBlockSize;
       
   847 
       
   848 	do
       
   849 		{
       
   850 		TInt tmp3 = tempPtr[1];
       
   851 		
       
   852 		if (tmp3 == 0)
       
   853 			{
       
   854 			TUint16 dcval = TUint16( TInt16(DESCALE(tempPtr[0], PASS1_BITS+3) + iLevelShift) );
       
   855 
       
   856 			TUint64 w=MAKE_TUINT64( ((dcval << 16) | (dcval)), ((dcval << 16) | dcval) );
       
   857 
       
   858 			*(0 + reinterpret_cast<TUint64*>(dstPtr) ) = w;
       
   859 			*(1 + reinterpret_cast<TUint64*>(dstPtr) ) = w;
       
   860 
       
   861 			tempPtr += KJpgDCTBlockWidth;
       
   862 			dstPtr += KJpgDCTBlockWidth;
       
   863 			continue;
       
   864 			}
       
   865 
       
   866 		TInt tmp10 = tempPtr[0] << CONST_BITS;
       
   867 
       
   868 		
       
   869 		TInt z1 = tmp3;
       
   870 		TInt z4 = tmp3;
       
   871 		TInt z5 = z4 * FIX_1_175875602;
       
   872 
       
   873 		tmp3 = tmp3 * FIX_1_501321110;
       
   874 
       
   875 		z1 = z1 * - FIX_0_899976223;
       
   876 		z4 = z4 * - FIX_0_390180644;
       
   877 
       
   878 		z4 += z5;
       
   879 
       
   880 		const TInt tmp0 = z1 + z5;
       
   881 		const TInt tmp1 = z4;
       
   882 		const TInt tmp2 = z5;
       
   883 		tmp3 += z1 + z4;
       
   884 
       
   885 		const TInt KLevelShift = iLevelShift;
       
   886 		dstPtr[0] = TInt16(DESCALE(tmp10 + tmp3,CONST_BITS+PASS1_BITS+3) + KLevelShift);
       
   887 		dstPtr[7] = TInt16(DESCALE(tmp10 - tmp3,CONST_BITS+PASS1_BITS+3) + KLevelShift);
       
   888 		dstPtr[1] = TInt16(DESCALE(tmp10 + tmp2,CONST_BITS+PASS1_BITS+3) + KLevelShift);
       
   889 		dstPtr[6] = TInt16(DESCALE(tmp10 - tmp2,CONST_BITS+PASS1_BITS+3) + KLevelShift);
       
   890 		dstPtr[2] = TInt16(DESCALE(tmp10 + tmp1,CONST_BITS+PASS1_BITS+3) + KLevelShift);
       
   891 		dstPtr[5] = TInt16(DESCALE(tmp10 - tmp1,CONST_BITS+PASS1_BITS+3) + KLevelShift);
       
   892 		dstPtr[3] = TInt16(DESCALE(tmp10 + tmp0,CONST_BITS+PASS1_BITS+3) + KLevelShift);
       
   893 		dstPtr[4] = TInt16(DESCALE(tmp10 - tmp0,CONST_BITS+PASS1_BITS+3) + KLevelShift);
       
   894 
       
   895 		tempPtr += KJpgDCTBlockWidth;
       
   896 		dstPtr += KJpgDCTBlockWidth;
       
   897 		} while (tempPtr < tempPtrLimit);
       
   898 	}
       
   899 
       
   900 // TFastQuarterDCT
       
   901 void TFastQuarterDCT::InverseTransform(TDataUnit& aDestination,const TDataUnit& aSource) const
       
   902 	{
       
   903 	const TInt KScalingFactor=4;
       
   904 	const TInt16* srcPtr= aSource.iCoeff;
       
   905 	TInt16* dstPtr 		= aDestination.iCoeff;
       
   906 	
       
   907 	TInt temp[KJpgDCTBlockWidth];
       
   908 	
       
   909 	TInt* tempPtr = temp;
       
   910 	TInt* tempPtrLimit = temp + KJpgDCTBlockWidth / KScalingFactor; //scaling factor
       
   911 
       
   912 	do
       
   913 		{
       
   914 		TInt tmp3 = srcPtr[1 * KJpgDCTBlockWidth];
       
   915 		
       
   916 		if (tmp3 == 0)
       
   917 			{
       
   918 			TInt dcval = srcPtr[0] << PASS1_BITS;
       
   919 
       
   920 			tempPtr[0 ] = dcval;
       
   921 			tempPtr[4 ] = dcval;
       
   922 	
       
   923 			srcPtr	+=1;
       
   924 			tempPtr	+=1;
       
   925 			continue;
       
   926 			}
       
   927 
       
   928 		const TInt z2 = srcPtr[0 * KJpgDCTBlockWidth];
       
   929 
       
   930 		TInt tmp0 = z2 << CONST_BITS;
       
   931 
       
   932 		const TInt tmp10 = tmp0;
       
   933 
       
   934 		TInt z1 = tmp3;
       
   935 		TInt z4 = tmp3;
       
   936 		const TInt z5 = z4 * FIX_1_175875602;
       
   937 
       
   938 		tmp3 = tmp3 * FIX_1_501321110;
       
   939 		z1 = z1 * - FIX_0_899976223;
       
   940 		z4 = z4 * - FIX_0_390180644;
       
   941 
       
   942 		const TInt z3 = z5;
       
   943 		z4 += z5;
       
   944 
       
   945 		tmp0 = z1 + z3;
       
   946 
       
   947 		tmp3 += z1 + z4;
       
   948 
       
   949 		tempPtr[0 ] = DESCALE(tmp10 + tmp3, CONST_BITS - PASS1_BITS);
       
   950 		tempPtr[4 ] = DESCALE(tmp10 - tmp0, CONST_BITS - PASS1_BITS);
       
   951 
       
   952 		srcPtr	+=1;
       
   953 		tempPtr	+=1;
       
   954 		} while (tempPtr < tempPtrLimit);
       
   955 
       
   956 	tempPtr 	= temp;
       
   957 	tempPtrLimit= temp + KJpgDCTBlockWidth; 
       
   958 
       
   959 	do
       
   960 		{
       
   961 		TInt tmp3 = tempPtr[1];
       
   962 			
       
   963 		if (tmp3 == 0)
       
   964 			{
       
   965 			TInt16 dcval = TInt16(DESCALE(tempPtr[0], PASS1_BITS+3) + iLevelShift);
       
   966 
       
   967 			dstPtr[0] = dcval;
       
   968 			dstPtr[4] = dcval;
       
   969 			
       
   970 			tempPtr += KScalingFactor;
       
   971 			dstPtr 	+= KScalingFactor*KJpgDCTBlockWidth;
       
   972 			continue;
       
   973 			}
       
   974 
       
   975 		const TInt tmp10 = tempPtr[0] << CONST_BITS;
       
   976 
       
   977 		TInt z4 = tmp3;
       
   978 		const TInt z5 = z4 * FIX_1_175875602;
       
   979 
       
   980 		const TInt z1 = tmp3 * - FIX_0_899976223;
       
   981 		tmp3 = tmp3 * FIX_1_501321110;
       
   982 		
       
   983 		z4 = z4 * - FIX_0_390180644;
       
   984 
       
   985 		const TInt z3 = z5;
       
   986 		z4 += z5;
       
   987 
       
   988 		const TInt tmp0 = z1 + z3;
       
   989 
       
   990 		tmp3 += z1 + z4;
       
   991 
       
   992 		const TInt KLevelShift = iLevelShift;
       
   993 		dstPtr[0] = TInt16(DESCALE(tmp10 + tmp3,CONST_BITS+PASS1_BITS+3) + KLevelShift);
       
   994 		dstPtr[4] = TInt16(DESCALE(tmp10 - tmp0,CONST_BITS+PASS1_BITS+3) + KLevelShift);
       
   995 
       
   996 		tempPtr += KScalingFactor;
       
   997 		dstPtr 	+= KScalingFactor*KJpgDCTBlockWidth;
       
   998 		} while (tempPtr < tempPtrLimit);
       
   999 	}
       
  1000 
       
  1001 // TEighthDCT
       
  1002 void TEighthDCT::InverseTransform(TDataUnit& aDestination,const TDataUnit& aSource) const
       
  1003 	{
       
  1004 	Fast18InvTransform(aDestination, aSource.iCoeff[0]);
       
  1005 	}
       
  1006 
       
  1007 #ifdef __ARMCC__
       
  1008 #pragma pop
       
  1009 #endif
       
  1010