Exemplo n.º 1
0
/** Compares two files, excluding the REV property, as it doesn't remain the same always
@param	aExpectedFile The expected vcf file
@param	aFile This is the vcf file produced, and will be compared against aExpectedFile
*/
TBool CTestCompareCntFiles::CompareWholeFileL(const TDesC& aExpectedFile, const TDesC& aFile)
	{
	User::LeaveIfError(iFsSession.Connect());
	CleanupClosePushL(iFsSession);
	
	RFile fileExpected;
	RFile fileOutput;
	CleanupClosePushL(fileExpected);
	CleanupClosePushL(fileOutput);
	
	TInt err;
	err = fileExpected.Open(iFsSession, aExpectedFile, EFileRead);

	if (err != KErrNone)
		{
		User::Leave(err);
		}

	err = fileOutput.Open(iFsSession, aFile, EFileWrite);
	if (err != KErrNone)
		{
		User::Leave(err);
		}

	RFileReadStream stream1(fileExpected);
	RFileReadStream stream2(fileOutput);
	CleanupClosePushL(stream1);
	CleanupClosePushL(stream2);
	TBuf8<0x80> bufO,bufC;
	TBool flag = ETrue;
	TInt line = 1;
	do
		{
		TRAP(err, stream1.ReadL(bufO, KLinefeedChar));
		if (err == KErrNone || err == KErrEof)
			TRAP(err, stream2.ReadL(bufC, KLinefeedChar));
		if (err != KErrNone && err != KErrEof)
			User::Leave(err);
		if (CompareLine(bufO, bufC) == EFalse)
			{
			flag = EFalse;
			break;
			}
		++line;
		}
	while (err != KErrEof);

	CleanupStack::PopAndDestroy(4, &fileExpected);
	CleanupStack::PopAndDestroy(&iFsSession);
    iFsSession.Close();
	
	if(flag)
		{
		return ETrue;		
		}
	else
		{
		return EFalse;
		}		
	}
void ScrollDetectionCore (SPixMap* pSrcPixMap, SPixMap* pRefPixMap, int32_t iWidth, int32_t iHeight,
                          int32_t iOffsetX, int32_t iOffsetY, SScrollDetectionParam& sScrollDetectionParam) {
  bool bScrollDetected = 0;
  uint8_t* pYLine;
  uint8_t* pYTmp;
  int32_t iTestPos, iSearchPos = 0, iOffsetAbs, iMaxAbs;
  int32_t iPicHeight = pRefPixMap->sRect.iRectHeight;
  int32_t iMinHeight = WELS_MAX (iOffsetY, 0);
  int32_t iMaxHeight = WELS_MIN (iOffsetY + iHeight - 1, iPicHeight - 1) ; //offset_y + height - 1;//
  uint8_t* pYRef, *pYSrc;
  int32_t iYStride;

  pYRef = (uint8_t*)pRefPixMap->pPixel[0];
  pYSrc = (uint8_t*)pSrcPixMap->pPixel[0];
  iYStride = pRefPixMap->iStride[0];

  iTestPos = SelectTestLine (pYSrc, iWidth, iHeight, iPicHeight, iYStride, iOffsetX, iOffsetY);

  if (iTestPos == -1) {
    sScrollDetectionParam.bScrollDetectFlag = 0;
    return;
  }
  pYLine = pYSrc + iYStride * iTestPos + iOffsetX;
  iMaxAbs = WELS_MIN (WELS_MAX (iTestPos - iMinHeight - 1, iMaxHeight - iTestPos), MAX_SCROLL_MV_Y);
  iSearchPos = iTestPos;
  for (iOffsetAbs = 0; iOffsetAbs <= iMaxAbs; iOffsetAbs++) {
    iSearchPos = iTestPos + iOffsetAbs;
    if (iSearchPos <= iMaxHeight) {
      pYTmp = pYRef + iSearchPos * iYStride + iOffsetX;
      if (!CompareLine (pYLine, pYTmp, iWidth)) {
        uint8_t* pYUpper, *pYLineUpper;
        int32_t iCheckedLines;
        int32_t iLowOffset = WELS_MIN (iMaxHeight - iSearchPos, CHECK_OFFSET);
        int32_t i;

        iCheckedLines = WELS_MIN (iTestPos - iMinHeight + iLowOffset, 2 * CHECK_OFFSET);
        pYUpper = pYTmp - (iCheckedLines - iLowOffset) * iYStride;
        pYLineUpper = pYLine - (iCheckedLines - iLowOffset) * iYStride;

        for (i = 0; i < iCheckedLines; i ++) {
          if (CompareLine (pYLineUpper, pYUpper, iWidth)) {
            break;
          }
          pYUpper += iYStride;
          pYLineUpper += iYStride;
        }
        if (i == iCheckedLines) {
          bScrollDetected = 1;
          break;
        }
      }
    }

    iSearchPos = iTestPos - iOffsetAbs - 1;
    if (iSearchPos >= iMinHeight) {
      pYTmp = pYRef + iSearchPos * iYStride + iOffsetX;
      if (!CompareLine (pYLine, pYTmp, iWidth)) {
        uint8_t* pYUpper, *pYLineUpper;
        int32_t iCheckedLines;
        int32_t iUpOffset = WELS_MIN (iSearchPos - iMinHeight, CHECK_OFFSET);
        int32_t i;

        pYUpper = pYTmp - iUpOffset * iYStride;
        pYLineUpper = pYLine - iUpOffset * iYStride;
        iCheckedLines = WELS_MIN (iMaxHeight - iTestPos + iUpOffset, 2 * CHECK_OFFSET);

        for (i = 0; i < iCheckedLines; i ++) {
          if (CompareLine (pYLineUpper, pYUpper, iWidth)) {
            break;
          }
          pYUpper += iYStride;
          pYLineUpper += iYStride;
        }
        if (i == iCheckedLines) {
          bScrollDetected = 1;
          break;
        }
      }
    }
  }

  if (!bScrollDetected) {
    sScrollDetectionParam.bScrollDetectFlag = 0;
  } else {
    sScrollDetectionParam.bScrollDetectFlag = 1;
    sScrollDetectionParam.iScrollMvY = iSearchPos - iTestPos; // pre_pos - cur_pos, change to mv
    sScrollDetectionParam.iScrollMvX = 0;
  }
}