Ejemplo n.º 1
0
void CFishEyeCorrect::FishImgIndex(const Mat& ormImg)
{
	ImgIndex1 = Mat::zeros(Size(w,h),CV_32SC2);
	ImgIndex2 = Mat::zeros(Size(w,h),CV_32SC2);
	ImgIndex3 = Mat::zeros(Size(w,h),CV_32SC2);
	for (int i =0; i < h; ++i)
	{
		int *data1 = ImgIndex1.ptr<int>(i);
		int *data2 = ImgIndex2.ptr<int>(i);
		int *data3 = ImgIndex3.ptr<int>(i);
		for (int j =0;j < w; ++j)
		{
			double x1 = 0 ;
			double y1 = 0;
			double x2 = 0 ;
			double y2 = 0;
			double x3 = 0 ;
			double y3 = 0;

			Fix(i,j, x1,y1,phi0,sita0,gama0);
			Fix(i,j, x2,y2,phi1,sita1,gama1);
			Fix(i,j, x3,y3,phi2,sita2,gama2);

			data1[j*2] = (int)x1;
			data1[j*2+1] = (int)y1;

			data2[j*2] = (int)x2;
			data2[j*2+1] = (int)y2;

			data3[j*2] = (int)x3;
			data3[j*2+1] = (int)y3;

		}
	}
}
void FisheyeImgCorrect::FishImgIndex(Mat& ormImg)
{
	//ImgIndex = Mat::zeros(Size(w,h),CV_32S);
	ImgIndex1 = Mat::zeros(Size(w,h),CV_32SC2);
	ImgIndex2 = Mat::zeros(Size(w,h),CV_32SC2);
	ImgIndex3 = Mat::zeros(Size(w,h),CV_32SC2);
	for (int i =0; i < h; ++i)
	{
		int *data1 = ImgIndex1.ptr<int>(i);
		int *data2 = ImgIndex2.ptr<int>(i);
		int *data3 = ImgIndex3.ptr<int>(i);
		for (int j =0;j < w; ++j)
		{
			double x1 = 0 ;
			double y1 = 0;
			double x2 = 0 ;
			double y2 = 0;
			double x3 = 0 ;
			double y3 = 0;

			Fix(i,j, x1,y1,phi0,sita0,gama0);
			Fix(i,j, x2,y2,phi1,sita1,gama1);
			Fix(i,j, x3,y3,phi2,sita2,gama2);

			//Point2f uv1;
			//uv1.x = int(x1);
			//uv1.y = int(y1); 

			//Point2f uv2;
			//uv2.x = int(x2);
			//uv2.y = int(y2);

			//Point2f uv3;
			//uv3.x = int(x3);
			//uv3.y = int(y3);

			data1[j*2] = (int)x1;
			data1[j*2+1] = (int)y1;

			data2[j*2] = (int)x2;
			data2[j*2+1] = (int)y2;

			data3[j*2] = (int)x3;
			data3[j*2+1] = (int)y3;

			//ImgIndex1.at<Point2f>(i,j) = uv1;
			//ImgIndex2.at<Point2f>(i,j) = uv2;
			//ImgIndex3.at<Point2f>(i,j) = uv3;
		}
	}
}
Ejemplo n.º 3
0
    void DeviceCreationParameterInt::SetValue(String val) throw (Exception) {
        if (Fix()) throw Exception("Device parameter is read only");
        int i = __parse_int(val);

        std::map<String,String> emptyMap;
        if (RangeMinAsInt(emptyMap) && i < *RangeMinAsInt(emptyMap)) {
            throw Exception("Invalid device parameter value: too small");
        }
        if (RangeMaxAsInt(emptyMap) && i > *RangeMaxAsInt(emptyMap)) {
            throw Exception("Invalid device parameter value: too big");
        }

        if (PossibilitiesAsInt(emptyMap).size()) {
            bool valid = false;
            std::vector<int> possibilities = PossibilitiesAsInt(emptyMap);
            std::vector<int>::iterator iter  = possibilities.begin();
            while (iter != possibilities.end()) {
                if (i == *iter) {
                    valid = true;
                    break;
                }
                iter++;
            }
            if (!valid) throw Exception("Invalid Device parameter value: not in set of possible values");
        }
        SetValue(i);
    }
Ejemplo n.º 4
0
fixmat operator*(const fixmat &a, const imat &b)
{
  it_assert_debug(a.cols() == b.rows(), "operator*: wrong sizes");
  fixmat r(a.rows(), b.cols());

  Fix tmp;
  int i, j, k;
  Fix *tr = r._data();
  const Fix *t1;
  const int *t2 = b._data();

  for (i = 0; i < r.cols(); i++) {
    for (j = 0; j < r.rows(); j++) {
      tmp = Fix(0);
      t1 = a._data() + j;
      for (k = a.cols(); k > 0; k--) {
        tmp += *(t1) * *(t2++);
        t1 += a.rows();
      }
      *(tr++) = tmp;
      t2 -= b.rows();
    }
    t2 += b.rows();
  }
  return r;
}
Ejemplo n.º 5
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CMapCheckDlg::OnFixall() 
{
	int iSel = m_Errors.GetCurSel();

	if(iSel == LB_ERR)
		return;

	MapError * pError = (MapError*) m_Errors.GetItemDataPtr(iSel);

	if(pError->Fix == CantFix)
	{
		// should never get here because this button is supposed 
		//  to be disabled if the error cannot be fixed
		return;
	}

	UpdateBox ub;
	CMapObjectList Objects;
	ub.Objects = &Objects;

	int nErrors = m_Errors.GetCount();
	for(int i = 0; i < nErrors; i++)
	{
		MapError * pError2 = (MapError*) m_Errors.GetItemDataPtr(i);
		if(pError2->Type != pError->Type)
			continue;

		Fix(i, ub);
	}

	OnSelchangeErrors();
	CMapDoc::GetActiveMapDoc()->UpdateAllViews(NULL, MAPVIEW_UPDATE_OBJECTS | MAPVIEW_UPDATE_DISPLAY, &ub);
}
Ejemplo n.º 6
0
bool nmrRegistrationRigid(vctDynamicConstVectorBase<_vectorOwnerType, vct3> &dataSet1,
                          vctDynamicConstVectorBase<_vectorOwnerType, vct3> &dataSet2,
                          vctFrm3 &transform, double *fre)
{
    size_t npoints = dataSet1.size();
    size_t i;
    if (npoints != dataSet2.size()) {
        CMN_LOG_RUN_WARNING << "nmrRegistrationPairedPoint: incompatible sizes: " << npoints << ", "
                            << dataSet2.size() << std::endl;
        return false;
    }
    else if (npoints <= 0) {
        CMN_LOG_RUN_WARNING << "nmrRegistrationPairedPoint called for " << npoints << " points." << std::endl;
        return false;
    }
    // Compute averages
    vct3 avg1 = dataSet1.SumOfElements();
	avg1.Divide(static_cast<double>(npoints));
    vct3 avg2 = dataSet2.SumOfElements();
	avg2.Divide(static_cast<double>(npoints));

    // Compute the sum of the outer products of (dataSet1-avg1) and (dataSet2-avg2)
    vctDouble3x3 H, sumH;
    sumH.SetAll(0.0);
    for (i = 0; i < npoints; i++) {
        H.OuterProductOf(dataSet1[i]-avg1, dataSet2[i]-avg2);
        sumH.Add(H);
    }
    // Now, compute SVD of sumH
    vctDouble3x3 U, Vt;
    vctDouble3 S;
    nmrSVD(sumH, U, S, Vt);
    // Compute X = V*U' = (U*V')'
    vctDouble3x3 X = (U*Vt).Transpose();
    double det = vctDeterminant<3>::Compute(X);
    // If determinant is not 1, apply correction from Umeyama(1991)
    if (fabs(det-1.0) > 1e-6) {
        vctDouble3x3 Fix(0.0);
        Fix.Diagonal() = vct3(1.0, 1.0, -1.0);
        X = (U*Fix*Vt).Transpose();
        det = vctDeterminant<3>::Compute(X);
        if (fabs(det-1.0) > 1e-6) {
            CMN_LOG_RUN_WARNING << "nmrRegistrationPairedPoint: registration failed!!" << std::endl;
            return false;
        }
    }
    vctMatRot3 R;
    R.Assign(X);
    transform = vctFrm3(R, avg2-R*avg1);

    // Now, compute residual error if fre is not null
    if (fre) {
        double err2 = 0.0;
        for (i = 0; i < npoints; i++)
            err2 += (dataSet2[i] - transform*dataSet1[i]).NormSquare();
        *fre = sqrt(err2/npoints);
    }

    return true;
}
Ejemplo n.º 7
0
 void DeviceRuntimeParameterString::SetValueAsString(String val) throw (Exception) {
     if (Fix()) throw Exception("Device parameter is read only");
     if (val.find("\'") != String::npos) throw Exception("Character -> \' <- not allowed");
     if (val.find("\"") != String::npos) throw Exception("Character -> \" <- not allowed");
     OnSetValue(val);
     sVal = val;
 }
Ejemplo n.º 8
0
bool FixMirror::FixSprite(const std::string& filepath, Json::Value& val) const
{
	sm::vec2 fixed;
	if (Fix(val, fixed)) {
 		val["x scale"] = fixed.x;
 		val["y scale"] = fixed.y;
		return true;
	} else {
		return false;
	}
}
Ejemplo n.º 9
0
TEST(DiagnosticsTest, FlagsMatter) {
  Annotations Test("[[void]] main() {}");
  EXPECT_THAT(buildDiags(Test.code()),
              ElementsAre(DiagWithEqualFix(Test.range(), "int",
                                           "'main' must return 'int'")));
  // Same code built as C gets different diagnostics.
  EXPECT_THAT(
      buildDiags(Test.code(), {"-x", "c"}),
      ElementsAre(AllOf(
          Diag(Test.range(), "return type of 'main' is not 'int'"),
          WithFix(Fix(Test.range(), "int", "change return type to 'int'")))));
}
Ejemplo n.º 10
0
			void ChatTab::GenerateColors ()
			{
				const qreal lower = 50. / 360.;
				const qreal higher = 180. / 360.;
				const qreal delta = 25. / 360.;

				const qreal alpha = BgColor_.alphaF ();

				qreal s = BgColor_.saturationF ();
				s += 15 * (1 - s) / 16;
				qreal v = BgColor_.valueF ();
				v = 0.95 - v / 2;

				qreal h = BgColor_.hueF ();

				QColor color;
				for (qreal d = lower; d <= higher; d += delta)
				{
					color.setHsvF (Fix (h + d), s, v, alpha);
					NickColors_ << color;
					color.setHsvF (Fix (h - d), s, v, alpha);
					NickColors_ << color;
				}
			}
Ejemplo n.º 11
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CMapCheckDlg::OnFix() 
{
	// fix error.. or try to
	int iSel = m_Errors.GetCurSel();

	if(iSel == LB_ERR)
		return;

	UpdateBox ub;
	CMapObjectList Objects;
	ub.Objects = &Objects;
	Fix(iSel, ub);

	OnSelchangeErrors();
	CMapDoc::GetActiveMapDoc()->UpdateAllViews(NULL, MAPVIEW_UPDATE_OBJECTS | MAPVIEW_UPDATE_DISPLAY, &ub);
}
Ejemplo n.º 12
0
 void DeviceCreationParameterFloat::SetValue(String val) throw (Exception) {
     if (Fix()) throw Exception("Device parameter is read only");
     float f = __parse_float(val);
     //if (RangeMinAsFloat() && i < *RangeMinAsFloat()) throw Exception("Invalid device parameter value: too small");
     //if (RangeMaxAsFloat() && i > *RangeMaxAsFloat()) throw Exception("Invalid device parameter value: too big");
     /*if (PossibilitiesAsFloat()) {
         bool valid = false;
         std::vector<float>* pPossibilities = PossibilitiesAsFloat();
         std::vector<float>::iterator iter  = pPossibilities->begin();
         while (iter != pPossibilities->end()) {
             if (f == *iter) {
                 valid = true;
                 break;
             }
             iter++;
         }
         if (!valid) throw Exception("Invalid Device parameter value: not in set of possible values");
     }*/
     SetValue(f);
 }
Ejemplo n.º 13
0
LRESULT APIENTRY NewWndProc( HWND hwnd,UINT uMsg,
							 WPARAM wParam,LPARAM lParam ) 
{ 
	switch(uMsg) {
		case WM_KEYDOWN:
			switch (wParam) {
				case 50: //2
				DoubleCarSpeed();
				return 0;
				break;
				case 51: //3
				InstantStop();
				return 0;
				break;
				case 53: //5
				InvertSpeed();
				return 0;
				break;
				case 54: //6
				Fix();
				return 0;
				break;
				case 55: //7
				VehicleJump();
				return 0;
				break;
			}
			break;
		case WM_KEYUP:
			if(HandleKeyPress((DWORD)wParam)) { // 'I' handled it.
				return 0;
			}
			break;
		case WM_CHAR:
			if(HandleCharacterInput((DWORD)wParam)) { // 'I' handled it.
				return 0;
			}
			break;
	}
	return CallWindowProc(hOldProc,hwnd,uMsg,wParam,lParam);
}
Ejemplo n.º 14
0
 void DeviceCreationParameterStrings::SetValue(std::vector<String> vS) throw (Exception) {
     if (Fix()) throw Exception("Device parameter is read only");
     OnSetValue(vS);
     sVals = vS;
 }
Ejemplo n.º 15
0
 void DeviceCreationParameterStrings::SetValue(String val) throw (Exception) {
     if (Fix()) throw Exception("Device parameter is read only");
     std::vector<String> vS = __parse_strings(val);
     SetValue(vS);
 }
Ejemplo n.º 16
0
 void DeviceCreationParameterString::SetValue(String val) throw (Exception) {
     if (Fix()) throw Exception("Device parameter is read only");
     SetValueAsString(__parse_string(val));
 }
Ejemplo n.º 17
0
 void DeviceCreationParameterFloat::SetValue(float f) throw (Exception) {
     if (Fix()) throw Exception("Device parameter is read only");
     OnSetValue(f);
     fVal = f;
 }
Ejemplo n.º 18
0
	GTime::GTime(_uint h, _uint m, _uint s) : hours{ h }, minutes{ m }, seconds{ s }
	{
		Fix();
	}
Ejemplo n.º 19
0
 void DeviceCreationParameterBool::SetValue(bool b) throw (Exception) {
     if (Fix()) throw Exception("Device parameter is read only");
     OnSetValue(b);
     bVal = b;
 }
Ejemplo n.º 20
0
Fix operator-(const Fix &x, const int y)
{
  return Fix(x.get_re() - y,
             assert_shifts(x, y),
             0, 0);
}
Ejemplo n.º 21
0
Fix operator/(const Fix &x, const int y)
{
  return Fix(x.get_re() / y,
             x.get_shift(),
             0, 0);
}
Ejemplo n.º 22
0
/* Implementation *************************************************************/
void CTimeSyncTrack::Process(CParameter& Parameter,
			     CComplexVector& veccChanEst, int iNewTiCorr,
			     FXP& rLenPDS_fxp, FXP& rOffsPDS_fxp)
{
  int			i, j;
  int			iIntShiftVal;
  int			iFirstPathDelay;
  CFReal		rPeakBound_fxp;	  
  CFReal		rPropGain_fxp;  
  long long		rCurEnergy_fxp;  
  long long		rWinEnergy_fxp;  
  long long		rMaxWinEnergy_fxp;
  
  _BOOLEAN	bDelayFound;        //ok
  _BOOLEAN	bPDSResultFound;    //ok
  
  /* Rotate the averaged PDP to follow the time shifts -------------------- */
  /* Update timing correction history (shift register) */
  vecTiCorrHist.AddEnd(iNewTiCorr);
  
  /* Calculate the actual shift of the timing correction. Since we do the
     timing correction at the sound card sample rate (48 kHz) and the
     estimated impulse response has a different sample rate (since the
     spectrum is only one little part of the sound card frequency range)
     we have to correct the timing correction by a certain bandwidth factor */
  
  const CFReal rActShiftTiCor_fxp = rFracPartTiCor_fxp -
    (_FREAL) vecTiCorrHist[0] * iNumCarrier / iDFTSize;
  
  /* Integer part of shift */
  const int iIntPartTiCorr = (int) Round(rActShiftTiCor_fxp);
  
  /* Extract the fractional part since we can only correct integer timing
     shifts */
  rFracPartTiCor_fxp = rActShiftTiCor_fxp - iIntPartTiCorr;
  
  /* Shift the values in the vector storing the averaged impulse response. We
     have to consider two cases for shifting (left and right shift) */
  if (rActShiftTiCor_fxp < 0)
    iIntShiftVal = iIntPartTiCorr + iNumIntpFreqPil;
  else
    iIntShiftVal = iIntPartTiCorr;
  
  /* If new correction is out of range, do not apply rotation */
  if ((iIntShiftVal > 0) && (iIntShiftVal < iNumIntpFreqPil))
    {
      /* Actual rotation of vector */
      vecrAvPoDeSp.Merge(vecrAvPoDeSp(iIntShiftVal + 1, iNumIntpFreqPil),
			 vecrAvPoDeSp(1, iIntShiftVal));
    }
  /* New estimate for impulse response ------------------------------------ */
  /* Apply hamming window, Eq (15) */
  veccPilots = veccChanEst * vecrHammingWindow;
  
  /* Transform in time-domain to get an estimate for the delay power profile,
     Eq (15) */
  veccPilots = Ifft(veccPilots, FftPlan);
  
  /* Average result, Eq (16) (Should be a moving average function, for
     simplicity we have chosen an IIR filter here) */
  IIR1(vecrAvPoDeSp, SqMag(veccPilots), rLamAvPDS);
  
  /* Rotate the averaged result vector to put the earlier peaks
     (which can also detected in a certain amount) at the beginning of
     the vector */
  vecrAvPoDeSpRot.Merge(vecrAvPoDeSp(iStPoRot, iNumIntpFreqPil),
			vecrAvPoDeSp(1, iStPoRot - 1));
  
  
  /* Different timing algorithms ------------------------------------------ */
  switch (TypeTiSyncTrac)
    {
    case TSFIRSTPEAK:
      /* Detect first peak algorithm proposed by Baoguo Yang */
      /* Lower and higher bound */
      rBoundHigher = Max(vecrAvPoDeSpRot) * rConst1;  //ok
      rBoundLower = Min(vecrAvPoDeSpRot) * rConst2;   //ok
      
      /* Calculate the peak bound, Eq (19) */
      rPeakBound_fxp = FXP (Max(rBoundHigher, rBoundLower));
      
      /* Get final estimate, Eq (18) */
      bDelayFound = FALSE; /* Init flag */
      for (i = 0; i < iNumIntpFreqPil - 1; i++)
	{
	  /* We are only interested in the first peak */
	  if (bDelayFound == FALSE)
	    {
	      if ((vecrAvPoDeSpRot[i] > vecrAvPoDeSpRot[i + 1]) &&
		  (FXP (vecrAvPoDeSpRot[i]) > rPeakBound_fxp))
		{
		  /* The first peak was found, store index */
		  iFirstPathDelay = i;
		  
		  /* Set the flag */
		  bDelayFound = TRUE;
		}
	    }
	}
      break;
      
    case TSENERGY:
      /* Determin position of window with maximum energy in guard-interval.
	 A window with the size of the guard-interval is moved over the entire
	 profile and the energy inside this window is calculated. The window
	 position which maximises this energy is taken as the new timing
	 position */
      rMaxWinEnergy_fxp = 0;
      iFirstPathDelay = 0;
      for (i = 0; i < iNumIntpFreqPil - 1 - rGuardSizeFFT; i++)
	{
	  rWinEnergy_fxp = 0;
	  
	  /* Energy IN the guard-interval */
	  for (j = 0; j < rGuardSizeFFT; j++)
	    rWinEnergy_fxp += (long long)(vecrAvPoDeSpRot[i + j]*(1<<FXP_TIME_SYNC_TRACK_SCALE));
	  
	  /* Get maximum */
	  if (rWinEnergy_fxp > rMaxWinEnergy_fxp)
	    {
	      rMaxWinEnergy_fxp = rWinEnergy_fxp;
	      iFirstPathDelay = i;
	    }
	}
      
      /* We always have a valid measurement, set flag */
      bDelayFound = TRUE;
      break;
    }
  
  
  /* Only apply timing correction if search was successful and tracking is
     activated */
  if ((bDelayFound == TRUE) && (bTiSyncTracking == TRUE))
    {
      /* Consider the rotation introduced for earlier peaks in path delay.
	 Since the "iStPoRot" is the position of the beginning of the block
	 at the end for cutting out, "iNumIntpFreqPil" must be substracted.
	 (Actually, a part of the following line should be look like this:
	 "iStPoRot - 1 - iNumIntpFreqPil + 1" but the "- 1 + 1" compensate
	 each other) */
      iFirstPathDelay += iStPoRot - iNumIntpFreqPil - iTargetTimingPos - 1;
      
      
      /* Correct timing offset -------------------------------------------- */
      /* Final offset is target position in comparision to the estimated first
	 path delay. Since we have a delay from the channel estimation, the
	 previous correction is subtracted "- vecrNewMeasHist[0]". If the
	 "real" correction arrives after the delay, this correction is
	 compensated. The length of the history buffer (vecrNewMeasHist) must
	 be equal to the delay of the channel estimation.
	 The corrections must be quantized to the upsampled output sample
	 rate ("* iDFTSize / iNumCarrier") */
      iDFTSize / iNumCarrier - veciNewMeasHist[0];
      const CFReal rTiOffset_fxp = (CFReal) -iFirstPathDelay *
	iDFTSize / iNumCarrier - veciNewMeasHist[0];
      
      /* Different controlling parameters for different types of tracking */
      switch (TypeTiSyncTrac)
	{
	case TSFIRSTPEAK:
	  /* Adapt the linear control parameter to the region, where the peak
	     was found. The region left of the desired timing position is
	     critical, because we immediately get ISI if a peak appers here.
	     Therefore we apply fast correction here. At the other positions,
	     we smooth the controlling to improve the immunity against false
	     peaks */
	  if (rTiOffset_fxp > 0)
	    rPropGain_fxp = CONT_PROP_BEFORE_GUARD_INT;
	  else
	    rPropGain_fxp = CONT_PROP_IN_GUARD_INT;
	  break;
	  
	case TSENERGY:
	  rPropGain_fxp = CONT_PROP_ENERGY_METHOD;
	  break;
	}
      
      /* In case of sample rate offset acquisition phase, use faster timing
	 corrections */
      if (bSamRaOffsAcqu == TRUE)
	rPropGain_fxp *= 2;
      
      /* Apply proportional control and fix result to sample grid */
      const CFReal rCurCorrValue_fxp = rTiOffset_fxp * rPropGain_fxp + rFracPartContr_fxp;
      
      const int iContrTiOffs = (int) Fix(rCurCorrValue_fxp);
      
      /* Calculate new fractional part of controlling */
      rFracPartContr_fxp = rCurCorrValue_fxp - iContrTiOffs;
      
      /* Manage correction history */
      veciNewMeasHist.AddEnd(0);
      for (i = 0; i < iSymDelay - 1; i++)
	veciNewMeasHist[i] += iContrTiOffs;
      
      /* Apply correction */
      Parameter.iTimingOffsTrack = -iContrTiOffs;
    }
  
  
  /* Sample rate offset estimation ---------------------------------------- */
  /* This sample rate offset estimation is based on the movement of the
     estimated PDS with time. The movement per symbol (or a number of symbols)
     is proportional to the sample rate offset. It has to be considered the
     PDS shiftings of the timing correction unit ("rActShiftTiCor" can be used
     for that). The procedere is to detect the maximum peak in the PDS and use
     this as a reference, assuming tha delay of this peak is not changing. The
     problem is when another peak get higher than this due to fading. In this
     case we must adjust the history to this new peak (the new reference) */
  int		iMaxInd;
  CReal	rMax;
  //int	rMax_fxp;
  
  /* Find index of maximum peak in PDS estimation. This is our reference
     for this estimation method */
  Max(rMax, iMaxInd, vecrAvPoDeSpRot);
  
  /* Integration of timing corrections
     FIXME: Check for overrun of "iIntegTiCorrections" variable! */
  iIntegTiCorrections += (long long) iIntPartTiCorr;
  
  /* We need to consider the timing corrections done by the timing unit. What
     we want to estimate is only the real movement of the detected maximum
     peak */
  const long long iCurRes = iIntegTiCorrections + iMaxInd;
  veciSRTiCorrHist.AddEnd(iCurRes);
  
  /* We assumed that the detected peak is always the same peak in the actual
     PDS. But due to fading the maximum can change to a different peak. In
     this case the estimation would be wrong. We try to detect the detection
     of a different peak by defining a maximum sample rate change. The sample
     rate offset is very likely to be very constant since usually crystal
     oscialltors are used. Thus, if a larger change of sample rate offset
     happens, we assume that the maximum peak has changed */
  const long long iNewDiff = veciSRTiCorrHist[iLenCorrectionHist - 2] - iCurRes;
  
  /* If change is larger than 2, it is most likely that a new peak was chosen
     by the maximum function. Also, if the sign has changed of the difference
     (and it is not zero), we also say that a new peak was selected */
  if ((llabs(iNewDiff) > 2) ||
      ((Sign(iOldNonZeroDiff) != Sign(iNewDiff)) && (iNewDiff != 0)))
    {
      /* Correct the complete history to the new reference peak. Reference
	 peak was already added, therefore do not use last element */
      for (i = 0; i < iLenCorrectionHist - 1; i++)
	veciSRTiCorrHist[i] -= iNewDiff;
    }
  
  /* Store old difference if it is not zero */
  if (iNewDiff != 0)
    iOldNonZeroDiff = iNewDiff;
  
  
  /* Check, if we are in acquisition phase */
  if (iResOffsetAcquCnt > 0)
    {
      /* Acquisition phase */
      iResOffsetAcquCnt--;
    }
  else
    {
      /* Apply the result from acquisition only once */
      if (bSamRaOffsAcqu == TRUE)
	{
	  /* End of acquisition phase */
	  bSamRaOffsAcqu = FALSE;
	  
	  /* Set sample rate offset to initial estimate. We consider the
	     initialization phase of channel estimation by "iSymDelay" */
	  /*rInitSamOffset = FXP GetSamOffHz(iCurRes - veciSRTiCorrHist[
	    iLenCorrectionHist - (iResOffAcqCntMax - iSymDelay)],
	    iResOffAcqCntMax - iSymDelay - 1); */
	  CFReal rInitSamOffset = FXP (GetSamOffHz(iCurRes - veciSRTiCorrHist[
									      iLenCorrectionHist - (iResOffAcqCntMax - iSymDelay)],
						   iResOffAcqCntMax - iSymDelay - 1)); 
	  
	  
#ifndef USE_SAMOFFS_TRACK_FRE_PIL
	  /* Apply initial sample rate offset estimation */
	  // (Parameter.rResampleOffset) -= rInitSamOffset;
	  FXP (Parameter.rResampleOffset) -= rInitSamOffset;
	  
#endif
	  
	  /* Reset estimation history (init with zeros) since the sample
	     rate offset was changed */
	  veciSRTiCorrHist.Init(iLenCorrectionHist, 0);
	  iIntegTiCorrections = 0;
	}
      else
	{
	  /* Tracking phase */
	  /* Get actual sample rate offset in Hertz */
	  /* const CReal rSamOffset = GetSamOffHz(iCurRes - veciSRTiCorrHist[0],
	     iLenCorrectionHist - 1); */
	  const CFReal rSamOffset = FXP (GetSamOffHz(iCurRes - veciSRTiCorrHist[0],
						     iLenCorrectionHist - 1));
	  
#ifndef USE_SAMOFFS_TRACK_FRE_PIL
	  /* Apply result from sample rate offset estimation */
	  //Parameter.rResampleOffset -= CONTR_SAMP_OFF_INT_FTI * rSamOffset;
	  FXP (Parameter.rResampleOffset) -= CONTR_SAMP_OFF_INT_FTI * rSamOffset;
#endif
	}
    }
  
  
  /* Delay spread length estimation --------------------------------------- */
  /* Estimate the noise energy using the minimum statistic. We assume that
     the noise variance is equal on all samples of the impulse response.
     Therefore we subtract the variance on each sample. The total estimated
     signal energy is the total energy minus the noise energy */
  /* Calculate total energy */
  const CFReal rTotEgy = Sum(vecrAvPoDeSpRot);
  
  /* Sort the values of the PDS to get the smallest values */
  CRealVector rSortAvPoDeSpRot(Sort(vecrAvPoDeSpRot));
  
  /* Average the result of smallest values and overestimate result */
  const long long rSigmaNoise_fxp =
    (long long)(Sum(rSortAvPoDeSpRot(1, NUM_SAM_IR_FOR_MIN_STAT - 1)) /
		NUM_SAM_IR_FOR_MIN_STAT * OVER_EST_FACT_MIN_STAT*(1<<FXP_TIME_SYNC_TRACK_SCALE));
  
  /* Calculate signal energy by subtracting the noise energy from total
     energy (energy cannot by negative -> bound at zero) */
  const long long rSigEnergyBound_fxp =
    (long long)((double)Max(rTotEgy - ((double)rSigmaNoise_fxp/(1<<FXP_TIME_SYNC_TRACK_SCALE)) * iNumIntpFreqPil,
			    (FXP)0)*(1<<FXP_TIME_SYNC_TRACK_SCALE));
  
  /* From left to the right -> search for end of PDS */
  rEstPDSEnd_fxp = (FXP) (iNumIntpFreqPil - 1);
  rCurEnergy_fxp = 0;
  bPDSResultFound = FALSE;
  for (i = 0; i < iNumIntpFreqPil; i++)
    {
      if (bPDSResultFound == FALSE)
	{
	  if (rCurEnergy_fxp > rSigEnergyBound_fxp)
	    {
	      /* Delay index */
	      rEstPDSEnd_fxp = (CReal) i;
	      
	      bPDSResultFound = TRUE;
	    }
	  
	  /* Accumulate signal energy, subtract noise on each sample */
	  rCurEnergy_fxp += (long long)(vecrAvPoDeSpRot[i]*(1<<FXP_TIME_SYNC_TRACK_SCALE)) - rSigmaNoise_fxp; //slu2 change
	}
    }
  
  /* From right to the left -> search for beginning of PDS */
  rEstPDSBegin_fxp = 0;
  rCurEnergy_fxp = 0;
  bPDSResultFound = FALSE;
  for (i = iNumIntpFreqPil - 1; i >= 0; i--)
    {
      if (bPDSResultFound == FALSE)
	{
	  if (rCurEnergy_fxp > rSigEnergyBound_fxp)
	    {
	      /* Delay index */
	      rEstPDSBegin_fxp = (CFReal) i;
	      
	      bPDSResultFound = TRUE;
	    }
	  
	  /* Accumulate signal energy, subtract noise on each sample */
	  rCurEnergy_fxp += (long long)(vecrAvPoDeSpRot[i]*(1<<FXP_TIME_SYNC_TRACK_SCALE)) - rSigmaNoise_fxp; //slu2 change
	}
    }
  
  /* If the signal energy is too low it can happen that the estimated
     beginning of the impulse response is before the end -> correct */
  if (rEstPDSBegin_fxp > rEstPDSEnd_fxp)
    {
      /* Set beginning and end to their maximum (minimum) value */
      //rEstPDSBegin = (CReal) 0.0;
      rEstPDSBegin_fxp = 0;
      rEstPDSEnd_fxp = (CFReal) (iNumIntpFreqPil - 1);
    }
  
  /* Correct estimates of begin and end of PDS by the rotation */
  const CReal rPDSLenCorrection = iNumIntpFreqPil - iStPoRot + 1; /* slu2: dont' have to change here */
  rEstPDSBegin_fxp -= FXP (rPDSLenCorrection);
  rEstPDSEnd_fxp -= FXP (rPDSLenCorrection);
  
  /* Set return parameters */
  rLenPDS_fxp = rEstPDSEnd_fxp - rEstPDSBegin_fxp;
  rOffsPDS_fxp= rEstPDSBegin_fxp;
}
Ejemplo n.º 23
0
		/// \brief Move the object.
		void Translate( const ei::Vec3& _vector )				{ m_position[0] += Fix(_vector[0]); m_position[1] += Fix(_vector[1]); m_position[2] += Fix(_vector[2]); }
Ejemplo n.º 24
0
		Transformation() : m_position(Fix(0.0)), m_rotation(ei::qidentity()), m_rotationMatrix(ei::identity3x3()), m_inverseRotationMatrix(ei::identity3x3()) {}
Ejemplo n.º 25
0
Fix operator*(const Fix &x, const Fix &y)
{
  return Fix(x.get_re() * y.get_re(),
             x.get_shift() + y.get_shift(),
             0, 0);
}
Ejemplo n.º 26
0
 void DeviceCreationParameterInt::SetValue(int i) throw (Exception) {
     if (Fix()) throw Exception("Device parameter is read only");
     OnSetValue(i);
     iVal = i;
 }
Ejemplo n.º 27
0
/* <130f04> ../cstrike/dlls/plats.cpp:1093 */
NOBODY void FixupAngles(Vector &v)
{
	v.x = Fix(v.x);
	v.y = Fix(v.y);
	v.z = Fix(v.z);
}
Ejemplo n.º 28
0
Fix operator+(const int x, const Fix &y)
{
  return Fix(x + y.get_re(),
             assert_shifts(y, x),
             0, 0);
}
Ejemplo n.º 29
0
void FixupAngles( QAngle &v )
{
	v.x = Fix( v.x );
	v.y = Fix( v.y );
	v.z = Fix( v.z );
}
Ejemplo n.º 30
0
 void DeviceCreationParameterBool::SetValue(String val) throw (Exception) {
     if (Fix()) throw Exception("Device parameter is read only");
     int b = __parse_bool(val);
     SetValue(b);
 }