12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874 |
- #include "../../includes/includes.h"
- extern flt32 gg_afOneFrameLocationData[PUB_SLOT_FRAME_LEN];
- extern LCT_FIRSTPATH_PARAM_T gg_stFirstPathParam;
- extern flt32 g_afSincFilterDataList[24001];
- extern PUB_SYS_STATUS_T gg_stSysStatus;
- extern uint32 gg_dwFrameNo;
- extern LCT_FIRSTPATH_PREDICTION_DIRECTION_DATA_T gLct_astPredictionDirectionDataList[PUB_SYS_CARRIER_NUM];
- void lct_firstpath_init(LCT_FIRSTPATH_PARAM_T stFirstPathParam)
- {
-
- gg_stFirstPathParam.byMinValueFactor = stFirstPathParam.byMinValueFactor;
-
- gg_stFirstPathParam.byAnchorFactor = stFirstPathParam.byAnchorFactor;
- gg_stFirstPathParam.byAnchorThreshold = stFirstPathParam.byAnchorThreshold;
-
- gg_stFirstPathParam.byPeakPeakDistance = stFirstPathParam.byPeakPeakDistance;
-
- gg_stFirstPathParam.byNoiseSignalFactor = stFirstPathParam.byNoiseSignalFactor;
-
- gg_stFirstPathParam.byNoiseHightScale = stFirstPathParam.byNoiseHightScale;
- gg_stFirstPathParam.byNoiseLowScale = stFirstPathParam.byNoiseLowScale;
-
- gg_stFirstPathParam.byCfarLeftFactor = stFirstPathParam.byCfarLeftFactor;
-
- gg_stFirstPathParam.bySincFactor = stFirstPathParam.bySincFactor;
-
- gg_stFirstPathParam.byFirstPathContactFactor = stFirstPathParam.byFirstPathContactFactor;
-
- gg_stFirstPathParam.wFirstPathContactDistance = stFirstPathParam.wFirstPathContactDistance;
-
-
- gg_stFirstPathParam.wFirstPathTrackWindowWidth = stFirstPathParam.wFirstPathTrackWindowWidth;
-
- gg_stFirstPathParam.wFirstPathTrackPeakGuardWidth = stFirstPathParam.wFirstPathTrackPeakGuardWidth;
-
- gg_stFirstPathParam.wFirstPathTrackNoiseFindWidth = stFirstPathParam.wFirstPathTrackNoiseFindWidth;
-
- gg_stFirstPathParam.byFirstPathTrackPeakGainFactor = stFirstPathParam.byFirstPathTrackPeakGainFactor;
- return;
- }
- void lct_firstpath_main(PUB_LCT_BTS_LIST_T *pstLctBtsList, PUB_LOCATION_DATA_T *pstLctDataList, LCT_FIRSTPATH_LIST_T *pstFirstPathList)
- {
- uint32 dwFrameNo = 0;
- uint8 byRemainder = 0;
- int32 dwSyncOffset = 0;
- uint8 byLctBtsNum = pstLctBtsList->byBtsNum;
- PUB_LCT_BTS_T *pstLctBts = NULL;
- PUB_LOCATION_DATA_T *pstLctData = NULL;
- uint8 byFreqIndex = 0;
- uint16 wAheadFrameFirstIndex = 0;
- uint16 wMaxValueIndex = 0;
- flt32 fMaxValue;
- uint16 wAnchorIndex = 0;
- flt32 fNoise = 0;
- flt32 fPeakThreshold = 0;
- FIRST_PATH_T stFirstPath = {0};
- uint8 byCounter = 0;
- uint16 wFrameTraceIndex = 0;
- LCT_FIRSTPATH_T *pstFirstPath = NULL;
-
- lct_firstpath_reset_direction_valid_flag(gLct_astPredictionDirectionDataList);
-
- for (uint8 i = 0; i < byLctBtsNum; i++)
- {
- pstLctBts = &pstLctBtsList->astLocationBts[i];
- byFreqIndex = pstLctBts->dwFreqIndex;
- pstLctData = &pstLctDataList[byFreqIndex];
-
- lct_firstpath_get_lct_data(pstLctData, gg_afOneFrameLocationData);
-
- if (PUB_DEBUG_ENABLE)
- {
- if (pstLctData->byFreqIndex < 8 && pstLctData->dwFrameNo > 232)
- {
- char *pfileName = "E:\\work\\ips8000\\aplm8000sdk\\output\\lctdata\\firstpath.bin";
- util_write_flt32_to_bin_file(pfileName, PUB_SLOT_FRAME_LEN, gg_afOneFrameLocationData, 1);
- uint8 byTmp = 0;
- }
- }
-
- if (pstLctData->byLctBtsFlag && pstLctData->byBtsValidFlag && pstLctData->byCurrentAmplValidFlag)
- {
-
- wFrameTraceIndex = pstLctData->wAheadFrameTrackPathIndex;
-
- pstFirstPath = &pstFirstPathList->astFirstPath[byCounter];
- memset(pstFirstPath, 0, sizeof(LCT_FIRSTPATH_T));
-
- pstFirstPath->byMainFlag = (uint8)pstLctBts->dwMainBtsFlag;
- pstFirstPath->dwBuildId = pstLctBts->dwBuildId;
- pstFirstPath->dwLayerId = pstLctBts->dwLayerId;
- pstFirstPath->dwBtsId = pstLctBts->dwBtsId;
- pstFirstPath->byFreqIndex = (uint8)pstLctBts->dwFreqIndex;
- pstFirstPath->bySlot = (uint8)pstLctBts->dwSlot;
- pstFirstPath->dwLctType = pstLctBts->dwLctType;
- pstFirstPath->dwTwoBtsNum = pstLctBts->dwTwoBtsNum;
- memcpy(pstFirstPath->adwTwoBtsList, pstLctBts->adwTwoBtsList, sizeof(uint32) * pstLctBts->dwTwoBtsNum);
- pstFirstPath->dwCoordX = pstLctBts->dwCoordX;
- pstFirstPath->dwCoordY = pstLctBts->dwCoordY;
- pstFirstPath->dwCoordZ = pstLctBts->dwCoordZ;
-
- lct_firstpath_cal_calpath(gg_afOneFrameLocationData, wFrameTraceIndex, &wMaxValueIndex, &wAnchorIndex, &fNoise, &fPeakThreshold, &stFirstPath);
- if (stFirstPath.wFirstPathIndex > 3000)
- {
-
-
- pstFirstPath->dwCalPathIndex = PUB_SLOT_FRAME_LEN + pstLctData->dwSignalSlotSyncOffset + pstLctData->dwSignalSyncIndex + stFirstPath.wFirstPathIndex;
- pstFirstPath->wFrameCalIndex = stFirstPath.wFirstPathIndex;
- pstFirstPath->fFrameCalPathValue = gg_afOneFrameLocationData[stFirstPath.wFirstPathIndex];
- pstFirstPath->fCalPathIndexSnr = stFirstPath.fSnr;
- fMaxValue = gg_afOneFrameLocationData[wMaxValueIndex];
- pstFirstPath->fMaxAmplValue = fMaxValue;
-
- if (PUB_DEBUG_ENABLE)
- {
- if (pstLctData->byFreqIndex < 8 && pstLctData->dwFrameNo > 220)
- {
- printf("frame no:%d, freq index:%d, sync index:%d, cal frame index:%d, cal index:%d\n", pstLctData->dwFrameNo - 1, pstFirstPath->byFreqIndex, pstLctData->dwSignalSyncIndex, pstFirstPath->wFrameCalIndex, pstFirstPath->dwCalPathIndex);
- uint8 byTmp = 0;
- }
- }
- }
- else
- {
- pstFirstPath->wFrameCalIndex = 0;
- }
-
- if (wFrameTraceIndex && wFrameTraceIndex < 12000)
- {
- lct_firstpath_cal_trackpath(gg_afOneFrameLocationData, wFrameTraceIndex, fNoise, fPeakThreshold, wAnchorIndex, wMaxValueIndex, &stFirstPath);
-
- if (stFirstPath.byTrackSuccessFlag && stFirstPath.wFirstPathIndex > 3000)
- {
-
-
- pstFirstPath->dwTrackPathIndex = PUB_SLOT_FRAME_LEN + pstLctData->dwSignalSlotSyncOffset + pstLctData->dwSignalSyncIndex + stFirstPath.wFirstPathIndex;
- pstFirstPath->wFrameTrackIndex = stFirstPath.wFirstPathIndex;
- pstFirstPath->fFrameTrackPathValue = gg_afOneFrameLocationData[stFirstPath.wFirstPathIndex];
- pstFirstPath->fTrackPathIndexSnr = stFirstPath.fSnr;
- }
-
- else
- {
- pstFirstPath->dwTrackPathIndex = pstFirstPath->dwCalPathIndex;
- pstFirstPath->fFrameTrackPathValue = pstFirstPath->fFrameCalPathValue;
- pstFirstPath->wFrameTrackIndex = pstFirstPath->wFrameCalIndex;
- pstFirstPath->fTrackPathIndexSnr = pstFirstPath->fCalPathIndexSnr;
- }
- }
- else
- {
- pstFirstPath->dwTrackPathIndex = pstFirstPath->dwCalPathIndex;
- pstFirstPath->fFrameTrackPathValue = pstFirstPath->fFrameCalPathValue;
- pstFirstPath->wFrameTrackIndex = pstFirstPath->wFrameCalIndex;
- pstFirstPath->fTrackPathIndexSnr = pstFirstPath->fCalPathIndexSnr;
- }
-
- if (PUB_DEBUG_ENABLE)
- {
- if (pstFirstPath->wFrameTrackIndex > 0 && pstLctData->byFreqIndex < 8 && pstLctData->dwFrameNo > 220)
- {
- printf("frame no:%d, freq index:%d, sync index:%d, track frame index:%d, track index:%d\n", pstLctData->dwFrameNo - 1, pstFirstPath->byFreqIndex, pstLctData->dwSignalSyncIndex, pstFirstPath->wFrameTrackIndex, pstFirstPath->dwTrackPathIndex);
- uint8 byTmp = 0;
- }
- }
-
- if (pstFirstPath->wFrameCalIndex > 3000 || pstFirstPath->wFrameTrackIndex > 3000)
- {
- byCounter++;
-
- lct_firstpath_save_first_path_data(pstLctData, pstFirstPath, gLct_astPredictionDirectionDataList);
- }
- }
- }
-
- pstFirstPathList->byBtsNum = byCounter;
-
- lct_firstpath_prediction_move_direction(gLct_astPredictionDirectionDataList);
- return;
- }
- void lct_firstpath_get_lct_data(PUB_LOCATION_DATA_T *pstLctData, flt32 *pfOutData)
- {
- int32 dwStartIndex = 0;
- uint32 dwTmpIndex = 0;
-
-
- dwStartIndex = pstLctData->dwLocationIndex + pstLctData->dwSignalSyncIndex;
- if (dwStartIndex < 0)
- {
- dwStartIndex += PUB_LCT_DATA_LIST_LEN;
- }
- else if (dwStartIndex >= PUB_LCT_DATA_LIST_LEN)
- {
- dwStartIndex -= PUB_LCT_DATA_LIST_LEN;
- }
-
- util_looplist_get_flt32(pstLctData->afData, PUB_LCT_DATA_LIST_LEN, dwStartIndex, pfOutData, PUB_SLOT_FRAME_LEN, &dwTmpIndex);
- return;
- }
- void lct_firstpath_cal_calpath(flt32 *pfLocationData, uint16 wAheadFrameFirstPath, uint16 *pwMaxValueIndex, uint16 *pwAnchorIndex, flt32 *pfNoise, flt32 *pfPeakThreshold, FIRST_PATH_T *pstFirstPath)
- {
- uint16 wMaxValueIndex = 0;
- uint16 wMinValueIndex = 0;
- flt32 fNoise = 0;
- flt32 fSnr = 0;
- flt32 fSelPeakThreshold = 0;
- flt32 fMiniValueFactor = (flt32)gg_stFirstPathParam.byMinValueFactor / 100;
- uint16 awPeakList[PUBLIC_LCT_PEAK_LIST_LEN];
- uint16 wPeakListLen = 0;
- uint16 wAnchorIndex = 0;
- flt32 fThresholdWithAnchor = 0;
- uint16 wFirstPathLen = 0;
- uint16 awOriginalList[PUBLIC_LCT_PEAK_LIST_LEN];
- uint16 wOriginalListLen = 0;
- uint16 wFirstPathIndex = 0;
- memset(awOriginalList, 0, sizeof(uint16) * PUBLIC_LCT_PEAK_LIST_LEN);
- memset(awPeakList, 0, sizeof(uint16) * PUBLIC_LCT_PEAK_LIST_LEN);
-
- lct_firstpath_cal_frame_max_min_value_index_noise_snr(pfLocationData, wAheadFrameFirstPath, &wMaxValueIndex, &wMinValueIndex, &fNoise, &fSnr);
- *pwMaxValueIndex = wMaxValueIndex;
- *pfNoise = fNoise;
-
- lct_firstpath_cal_peak_threshold(fNoise, fSnr, &fSelPeakThreshold);
- if (fSelPeakThreshold < fMiniValueFactor * pfLocationData[wMaxValueIndex])
- {
- fSelPeakThreshold = fMiniValueFactor * pfLocationData[wMaxValueIndex];
- }
- *pfPeakThreshold = fSelPeakThreshold;
-
- lct_firstpath_select_left_peak(pfLocationData, fSelPeakThreshold, wMinValueIndex, wMaxValueIndex, awPeakList, &wPeakListLen);
-
- lct_firstpath_cal_anchor_index(awPeakList, wPeakListLen, pfLocationData, fSnr, &wAnchorIndex);
- *pwAnchorIndex = wAnchorIndex;
-
- fSelPeakThreshold = lct_firstpath_recal_peak_value_threshold(pfLocationData, wMaxValueIndex, wAnchorIndex, fSelPeakThreshold);
- *pfPeakThreshold = fSelPeakThreshold;
-
- lct_firstpath_select_peak_by_anchor(awPeakList, wPeakListLen, wAnchorIndex, pfLocationData, fSelPeakThreshold, &wPeakListLen);
-
- wFirstPathLen = 0;
- lct_firstpath_cal_first_path_by_peak_value_threshold(pfLocationData, wMaxValueIndex, fSelPeakThreshold, awPeakList, wPeakListLen, 0, &wFirstPathLen);
- wPeakListLen = wFirstPathLen;
-
- wFirstPathLen = 0;
- lct_firstpath_cal_first_path_by_cfar(pfLocationData, wMaxValueIndex, awPeakList, wPeakListLen, 0, &wFirstPathLen);
- wPeakListLen = wFirstPathLen;
-
- wFirstPathLen = 0;
- lct_firstpath_cal_first_path_by_sinc(pfLocationData, wMaxValueIndex, fNoise, awPeakList, wPeakListLen, 0, &wFirstPathLen);
- wPeakListLen = wFirstPathLen;
-
- lct_firstpath_check_anchor_index(awPeakList, wPeakListLen, wAnchorIndex, wMaxValueIndex, &wAnchorIndex, &wPeakListLen);
-
- memcpy(awOriginalList, awPeakList, sizeof(uint16) * wPeakListLen);
- wOriginalListLen = wPeakListLen;
- lct_firstpath_check_first_path_contact(pfLocationData, awPeakList, wPeakListLen, awOriginalList, wOriginalListLen, wAnchorIndex, wMaxValueIndex, &wFirstPathIndex);
-
- pstFirstPath->wFirstPathIndex = wFirstPathIndex;
- pstFirstPath->fSnr = pfLocationData[wFirstPathIndex] / fNoise;
- return;
- }
- void lct_firstpath_cal_frame_max_min_value_index_noise_snr(flt32 *pfData, uint16 wAheadFrameFirstPath, uint16 *pwMaxValueIndex, uint16 *pwMinValueIndex, flt32 *pfNose, flt32 *pfSnr)
- {
- flt32 fMaxValue = 0;
- uint16 wMaxValueIndex = 0;
- flt32 *pfDataHead = NULL;
- flt32 fTmpValue = 0;
- flt32 fMinValue = FLT_MAX;
- uint16 wMinValueIndex = 0;
- flt32 afDataNoiseList[PUB_SLOT_FRAME_LEN] = {0};
- flt32 fMiddleValue = 0;
- flt32 fNoiseHightScale = (flt32)gg_stFirstPathParam.byNoiseHightScale / 10;
- flt32 fLeftAverageValue = 0;
- flt32 fNoise = 0;
- uint16 wStartIndex = 0;
-
- if (wAheadFrameFirstPath > 1500)
- {
- wStartIndex = wAheadFrameFirstPath - 1500;
- for (uint16 k = wStartIndex; k < PUB_SLOT_FRAME_LEN; k++)
- {
- if (pfData[k] > fMaxValue)
- {
- fMaxValue = pfData[k];
- wMaxValueIndex = k;
- }
- }
- }
- else
- {
- wMaxValueIndex = util_looplist_find_max_value_index_flt32(pfData, PUB_SLOT_FRAME_LEN);
- fMaxValue = pfData[wMaxValueIndex];
- }
-
- wStartIndex = wMaxValueIndex > 1000 ? 1000 : 0;
- pfDataHead = pfData;
- for (uint16 i = wStartIndex; i < wMaxValueIndex; i++)
- {
- fTmpValue = *pfDataHead;
- if (fTmpValue < fMinValue)
- {
- fMinValue = fTmpValue;
- wMinValueIndex = i;
- }
- pfDataHead++;
- }
- *pwMinValueIndex = wMinValueIndex;
- fMinValue *= fNoiseHightScale;
-
- wMinValueIndex += 501;
- for (uint16 k = 0; k < wMinValueIndex; k++)
- {
- fLeftAverageValue += pfData[k] / wMinValueIndex;
- afDataNoiseList[k] = pfData[k];
- }
-
- util_sort_flt32_asc(afDataNoiseList, wMinValueIndex);
- fMiddleValue = afDataNoiseList[wMinValueIndex * 65 / 100];
-
- fNoise = fLeftAverageValue > fMinValue ? fLeftAverageValue : fMinValue;
- fNoise = fMiddleValue > fNoise ? fMiddleValue : fNoise;
-
- *pwMaxValueIndex = wMaxValueIndex;
- *pfNose = fNoise;
- *pfSnr = fMaxValue / fNoise;
- return;
- }
- void lct_firstpath_cal_peak_threshold(flt32 fNoise, flt32 fSnr, flt32 *pfPeakThreshold)
- {
- uint8 byNoiseSignalFactor = gg_stFirstPathParam.byNoiseSignalFactor;
- flt32 fNoiseLowScale = (flt32)gg_stFirstPathParam.byNoiseLowScale / 10;
- flt32 fNoiseShapeSinrRatio = 1;
- flt32 fThresholdSnr = 0;
- flt32 fPeakThreshold = 0;
-
- if (fSnr < 10)
- {
- fThresholdSnr = fSnr > fNoiseLowScale ? fSnr : fNoiseLowScale;
- fNoiseShapeSinrRatio += (10 - fThresholdSnr) / (flt32)byNoiseSignalFactor;
- }
- fPeakThreshold = ((flt32)fNoiseLowScale / fNoiseShapeSinrRatio) * fNoise;
- *pfPeakThreshold = (uint32)fPeakThreshold;
- return;
- }
- void lct_firstpath_select_left_peak(flt32 *pfData, flt32 fPeakThreshold, uint16 wMinValueIndex, uint16 wMaxValueIndex, uint16 *pwPeakList, uint16 *pwPeakListLen)
- {
- flt32 fLeftData1 = 0;
- flt32 fLeftData2 = 0;
- flt32 fLeftData3 = 0;
- flt32 fCenterData = 0;
- flt32 fRightData1 = 0;
- flt32 fRightData2 = 0;
- flt32 fRightData3 = 0;
- uint16 wAheadPeakIndex = 0;
- flt32 fAheadPeakValue = 0;
- uint16 wPeakPeakDistance = 0;
- uint8 byDistanceGap = gg_stFirstPathParam.byPeakPeakDistance;
- uint16 wCounter = 0;
- uint16 wTmpIndex = 0;
-
- fAheadPeakValue = pfData[wMaxValueIndex];
- wAheadPeakIndex = wMaxValueIndex;
- for (int16 i = (wMaxValueIndex - byDistanceGap); i > wMinValueIndex; i--)
- {
- if ((i - 3) >= 0)
- {
- fLeftData3 = pfData[i - 3];
- fLeftData2 = pfData[i - 2];
- fLeftData1 = pfData[i - 1];
- fCenterData = pfData[i];
- fRightData1 = pfData[i + 1];
- fRightData2 = pfData[i + 2];
- fRightData3 = pfData[i + 3];
- wPeakPeakDistance = wAheadPeakIndex - i;
- if (fCenterData > fPeakThreshold && fCenterData > fLeftData1 && fCenterData > fLeftData2 && fCenterData > fLeftData3 && fCenterData > fRightData1 && fCenterData > fRightData2 && fCenterData > fRightData3 && fCenterData > 0.15 * fAheadPeakValue && wPeakPeakDistance < 1000)
- {
- fAheadPeakValue = fCenterData;
- wAheadPeakIndex = i;
- pwPeakList[wCounter] = i;
- i -= (byDistanceGap + 1);
- wCounter++;
- }
- }
- }
-
- pwPeakList[wCounter] = wMaxValueIndex;
- wCounter++;
-
- for (uint16 k = 0; k < wCounter; k++)
- {
- for (uint16 m = k + 1; m < wCounter; m++)
- {
- if (pwPeakList[m] < pwPeakList[k])
- {
- wTmpIndex = pwPeakList[k];
- pwPeakList[k] = pwPeakList[m];
- pwPeakList[m] = wTmpIndex;
- }
- }
- }
-
- *pwPeakListLen = wCounter;
- return;
- }
- void lct_firstpath_sel_track_peak(flt32 *pfData, uint16 wMaxValueIndex, uint16 wTrackIndex, uint16 *pwPeakList, uint16 *pwPeakListLen)
- {
- uint16 wStartIndex = 0;
- uint16 wStopIndex = 0;
- uint16 wGuardWidth = gg_stFirstPathParam.wFirstPathTrackPeakGuardWidth;
- uint16 wTrackWindowWidth = gg_stFirstPathParam.wFirstPathTrackWindowWidth;
- flt32 fLeftData1 = 0;
- flt32 fLeftData2 = 0;
- flt32 fLeftData3 = 0;
- flt32 fCenterData = 0;
- flt32 fRightData1 = 0;
- flt32 fRightData2 = 0;
- flt32 fRightData3 = 0;
- uint8 byDistance = gg_stFirstPathParam.byPeakPeakDistance;
- uint16 wCounter = 0;
- uint16 wTmpIndex = 0;
-
- if ((wTrackIndex - wGuardWidth - wTrackWindowWidth) > 0)
- {
- wStartIndex = wTrackIndex - wGuardWidth - wTrackWindowWidth;
- }
- else
- {
- wStartIndex = 0;
- }
-
- for (int16 i = wTrackIndex; i > wStartIndex; i--)
- {
- if ((i - 3) >= 0 && (i + 3) < PUB_SLOT_FRAME_LEN)
- {
- fLeftData3 = pfData[i - 3];
- fLeftData2 = pfData[i - 2];
- fLeftData1 = pfData[i - 1];
- fCenterData = pfData[i];
- fRightData1 = pfData[i + 1];
- fRightData2 = pfData[i + 2];
- fRightData3 = pfData[i + 3];
- if (fCenterData > fLeftData1 && fCenterData > fLeftData2 && fCenterData > fLeftData3 && fCenterData > fRightData1 && fCenterData > fRightData2 && fCenterData > fRightData3)
- {
- pwPeakList[wCounter] = i;
- i -= (byDistance + 1);
- wCounter++;
- }
- }
- }
-
- if ((wTrackIndex + wGuardWidth + wTrackWindowWidth + 1) < PUB_SLOT_FRAME_LEN)
- {
- wStopIndex = wTrackIndex + wGuardWidth + wTrackWindowWidth + 1;
- }
- else
- {
- wStopIndex = PUB_SLOT_FRAME_LEN;
- }
-
- for (int16 j = (wTrackIndex + byDistance); j < wStopIndex; j++)
- {
- if ((j + 3) < PUB_SLOT_FRAME_LEN)
- {
- fLeftData3 = pfData[j - 3];
- fLeftData2 = pfData[j - 2];
- fLeftData1 = pfData[j - 1];
- fCenterData = pfData[j];
- fRightData1 = pfData[j + 1];
- fRightData2 = pfData[j + 2];
- fRightData3 = pfData[j + 3];
- if (fCenterData > fLeftData1 && fCenterData > fLeftData2 && fCenterData > fLeftData3 && fCenterData > fRightData1 && fCenterData > fRightData2 && fCenterData > fRightData3)
- {
- pwPeakList[wCounter] = j;
- j += (byDistance - 1);
- wCounter++;
- }
- }
- }
-
- for (uint16 k = 0; k < wCounter; k++)
- {
- for (uint16 m = k + 1; m < wCounter; m++)
- {
- if (pwPeakList[m] < pwPeakList[k])
- {
- wTmpIndex = pwPeakList[k];
- pwPeakList[k] = pwPeakList[m];
- pwPeakList[m] = wTmpIndex;
- }
- }
- }
-
- for (uint16 p = 0; p < wCounter; p++)
- {
- wTmpIndex = pwPeakList[p];
- if (wTmpIndex >= wMaxValueIndex)
- {
- wCounter = p;
- break;
- }
- }
-
- *pwPeakListLen = wCounter;
- return;
- }
- void lct_firstpath_cal_anchor_index(uint16 *pwPeakList, uint16 wPeakListLen, flt32 *pfData, flt32 fSnr, uint16 *pwAnchorIndex)
- {
- flt32 fMaxValue = 0;
- uint16 wMaxValueIndex = 0;
- uint8 byAnchorFactor = gg_stFirstPathParam.byAnchorFactor;
- flt32 fAnchorThreshold = ((flt32)gg_stFirstPathParam.byAnchorThreshold) / 100;
- uint16 wAnchorIndex = 0;
- uint16 wTempIndex = 0;
- uint32 fTempValue = 0;
- uint8 byExistFlag = 0;
-
- wMaxValueIndex = pwPeakList[wPeakListLen - 1];
- fMaxValue = pfData[wMaxValueIndex];
-
- if (fSnr < 10)
- {
- fSnr = fSnr > 1.5 ? fSnr : 1.5;
- fAnchorThreshold += (10 - fSnr) / byAnchorFactor;
- }
-
- if (fMaxValue < 5000)
- {
- fAnchorThreshold = 0.45 * fMaxValue;
- }
- else
- {
- fAnchorThreshold = fMaxValue * fAnchorThreshold;
- }
-
- if (wPeakListLen <= 1)
- {
- *pwAnchorIndex = pwPeakList[0];
- }
- else
- {
- for (int16 i = 0; i < wPeakListLen; i++)
- {
- wTempIndex = pwPeakList[i];
- fTempValue = pfData[wTempIndex];
- if (fTempValue > fAnchorThreshold)
- {
- wAnchorIndex = wTempIndex;
- byExistFlag = 1;
- break;
- }
- }
- if (byExistFlag)
- {
- *pwAnchorIndex = wAnchorIndex;
- }
- else
- {
- *pwAnchorIndex = pwPeakList[wPeakListLen - 1];
- }
- }
- return;
- }
- flt32 lct_firstpath_recal_peak_value_threshold(flt32 *pfLocationData, uint16 wMaxValueIndex, uint16 wAnchorIndex, flt32 fThreshold)
- {
- int16 wIndexGap = 0;
- flt32 fAnchorValue = 0;
- flt32 fOutThreshold = fThreshold;
- fAnchorValue = pfLocationData[wAnchorIndex];
-
- if (wAnchorIndex != wMaxValueIndex)
- {
- wIndexGap = wMaxValueIndex - wAnchorIndex;
-
- if (wIndexGap > 2000)
- {
- if (0.35 * fAnchorValue > fThreshold)
- {
- fOutThreshold = 0.35 * fAnchorValue;
- }
- }
- else if (wIndexGap > 1500)
- {
- if (0.30 * fAnchorValue > fThreshold)
- {
- fOutThreshold = 0.30 * fAnchorValue;
- }
- }
- else if (wIndexGap > 1000)
- {
- if (0.25 * fAnchorValue > fThreshold)
- {
- fOutThreshold = 0.25 * fAnchorValue;
- }
- }
- else
- {
- if (0.15 * fAnchorValue > fThreshold)
- {
- fOutThreshold = 0.15 * fAnchorValue;
- }
- }
- }
-
- if (fAnchorValue < 3000)
- {
- fOutThreshold = 0.35 * fAnchorValue;
- }
- return fOutThreshold;
- }
- void lct_firstpath_select_peak_by_anchor(uint16 *pwPeakList, uint16 wPeakListLen, uint16 wAnchorIndex, flt32 *pfData, flt32 fThresholdWithAnchor, uint16 *pwPeakListLen)
- {
- uint16 wCounter = 0;
- uint16 wTempIndex = 0;
- flt32 fPeakValue = 0;
-
- for (uint16 i = 0; i < wPeakListLen; i++)
- {
- wTempIndex = pwPeakList[i];
- fPeakValue = pfData[wTempIndex];
- if (fPeakValue > fThresholdWithAnchor && wTempIndex <= wAnchorIndex)
- {
- pwPeakList[wCounter] = wTempIndex;
- wCounter++;
- }
- }
-
- if (wAnchorIndex < pwPeakList[wPeakListLen - 1])
- {
- pwPeakList[wCounter] = pwPeakList[wPeakListLen - 1];
- wCounter++;
- }
-
- *pwPeakListLen = wCounter;
- return;
- }
- void lct_firstpath_cal_first_path_by_peak_value_threshold(flt32 *pfData, uint16 wMaxValueIndex, flt32 fPeakValueThreshold, uint16 *pwPeakList, uint16 wPeakListLen, uint8 byTrackFlag, uint16 *pwFirstPathLen)
- {
- uint16 awList[PUB_SLOT_FRAME_LEN];
- uint16 wPeakIndex = 0;
- flt32 fTmpValue = 0;
- uint16 wCounter = 0;
- memset(awList, 0, sizeof(uint16) * PUB_SLOT_FRAME_LEN);
-
- for (uint16 i = 0; i < wPeakListLen; i++)
- {
- wPeakIndex = pwPeakList[i];
- fTmpValue = pfData[wPeakIndex];
- if (fTmpValue > fPeakValueThreshold)
- {
- pwPeakList[wCounter] = wPeakIndex;
- wCounter++;
- }
- }
-
- if (wCounter > 0)
- {
- *pwFirstPathLen = wCounter;
- }
-
- else
- {
-
- if (byTrackFlag <= 0)
- {
- pwPeakList[0] = wMaxValueIndex;
- *pwFirstPathLen = 1;
- }
-
- else
- {
- pwPeakList[0] = PUB_SLOT_FRAME_LEN;
- *pwFirstPathLen = 0;
- }
- }
- return;
- }
- void lct_firstpath_cal_first_path_by_cfar(flt32 *pfData, uint16 wMaxValueIndex, uint16 *pwPeakList, uint16 wPeakListLen, uint8 byTrackFlag, uint16 *pwFirstPathLen)
- {
-
- flt32 fCfarLeftFactor = ((flt32)gg_stFirstPathParam.byCfarLeftFactor) / 100;
- flt32 fLeftValueThres = 0;
- flt32 fLeftMax = 0;
- flt32 fLeftTemp = 0;
- flt32 fSignalValue = 0;
- uint16 wSignalIndex = 0;
- uint8 byErrorFlag = 0;
- uint16 wCounter = 0;
-
- for (uint16 k = 0; k < wPeakListLen; k++)
- {
- byErrorFlag = 0;
- wSignalIndex = pwPeakList[k];
-
- if ((wSignalIndex - 2 * PUBLIC_LCT_CFAR_LEN) < 0)
- {
- byErrorFlag = 1;
- }
-
- if (!byErrorFlag)
- {
- fSignalValue = pfData[wSignalIndex];
-
- fLeftMax = 0;
- for (uint16 i = (wSignalIndex - 2 * PUBLIC_LCT_CFAR_LEN); i < (wSignalIndex - PUBLIC_LCT_CFAR_LEN); i++)
- {
- fLeftTemp = pfData[i];
- if (fLeftTemp > fLeftMax)
- {
- fLeftMax = fLeftTemp;
- }
- }
- fLeftValueThres = fLeftMax * fCfarLeftFactor;
- if (fSignalValue > fLeftValueThres)
- {
- pwPeakList[wCounter] = wSignalIndex;
- wCounter++;
- }
- }
- }
-
- if (wCounter > 0)
- {
-
- if (pwPeakList[wCounter - 1] != wMaxValueIndex)
- {
- pwPeakList[wCounter] = wMaxValueIndex;
- wCounter++;
- }
- *pwFirstPathLen = wCounter;
- }
-
- else
- {
-
- if (byTrackFlag <= 0)
- {
- pwPeakList[0] = wMaxValueIndex;
- *pwFirstPathLen = 1;
- }
-
- else
- {
- pwPeakList[0] = PUB_SLOT_FRAME_LEN;
- *pwFirstPathLen = 0;
- }
- }
- return;
- }
- void lct_firstpath_cal_first_path_by_sinc(flt32 *pfData, uint16 wMaxValueIndex, flt32 fNoise, uint16 *pwPeakList, uint16 wPeakListLen, uint8 byTrackFlag, uint16 *pwFirstPathLen)
- {
- flt32 *pfSincDataModel = g_afSincFilterDataList;
- uint8 bySincFactor = gg_stFirstPathParam.bySincFactor;
- flt32 fSnr = 0;
- flt32 fSincFactor = 0;
- flt32 fSincThreshold = 0;
- uint16 wSincValueIndex = 0;
- int16 wPeakPeakGap = 0;
- flt32 fPeakValue = 0;
- uint16 wPeakValuelIndex = 0;
- uint16 wTempIndex = 0;
- flt32 fTempValue = 0;
- uint16 awInvalidPeakValueList[PUB_SLOT_FRAME_LEN];
- uint16 wInvalidPeakCounter = 0;
- uint16 wInvalidPeakValuelIndex = 0;
- uint8 byExistFlag = 0;
- uint16 wCounter = 0;
-
- flt32 afSincDataTestList[2 * PUB_SLOT_FRAME_LEN + 1];
- memset(afSincDataTestList, 0, sizeof(flt32) * (2 * PUB_SLOT_FRAME_LEN + 1));
- memset(awInvalidPeakValueList, 0, sizeof(uint16) * PUB_SLOT_FRAME_LEN);
-
-
-
-
-
-
-
- for (uint16 i = 0; i < wPeakListLen; i++)
- {
-
- wPeakValuelIndex = pwPeakList[i];
- fPeakValue = pfData[wPeakValuelIndex];
- fSincFactor = fPeakValue * bySincFactor / 100;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- for (uint16 j = 0; j < wPeakListLen; j++)
- {
- wTempIndex = pwPeakList[j];
- fTempValue = pfData[wTempIndex];
- if (wTempIndex != wPeakValuelIndex)
- {
-
-
- wSincValueIndex = 0;
- if (wPeakValuelIndex > wTempIndex)
- {
- wPeakPeakGap = wPeakValuelIndex - wTempIndex;
- wSincValueIndex = PUB_SLOT_FRAME_LEN - wPeakPeakGap;
-
-
-
-
-
-
- }
-
- else
- {
- wPeakPeakGap = wTempIndex - wPeakValuelIndex;
- wSincValueIndex = PUB_SLOT_FRAME_LEN + wPeakPeakGap;
- }
-
- if (wPeakPeakGap > 1500)
- {
- fSincThreshold = pfSincDataModel[wSincValueIndex] * fSincFactor * 0.90;
- }
- else
- {
- fSincThreshold = pfSincDataModel[wSincValueIndex] * fSincFactor;
- }
-
- if (fTempValue <= fSincThreshold)
- {
- awInvalidPeakValueList[wInvalidPeakCounter] = wTempIndex;
- wInvalidPeakCounter++;
- }
- }
- }
- }
-
- if (wInvalidPeakCounter > 0)
- {
- wCounter = 0;
-
- for (uint16 k = 0; k < wPeakListLen; k++)
- {
- byExistFlag = 0;
- wPeakValuelIndex = pwPeakList[k];
-
- for (uint16 m = 0; m < wInvalidPeakCounter; m++)
- {
- wInvalidPeakValuelIndex = awInvalidPeakValueList[m];
- if (wPeakValuelIndex == wInvalidPeakValuelIndex)
- {
- byExistFlag = 1;
- break;
- }
- }
- if (!byExistFlag)
- {
- pwPeakList[wCounter] = wPeakValuelIndex;
- wCounter++;
- }
- }
-
- if (wCounter > 0)
- {
- *pwFirstPathLen = wCounter;
- }
- else
- {
- *pwFirstPathLen = 1;
- if (byTrackFlag == 0)
- {
- pwPeakList[0] = wMaxValueIndex;
- }
- else if (byTrackFlag == 1)
- {
- pwPeakList[0] = 0;
- }
- }
- }
-
- else
- {
- *pwFirstPathLen = wPeakListLen;
- }
- return;
- }
- void lct_firstpath_check_anchor_index(uint16 *pwPeakList, uint16 wPeakListLen, uint16 wAnchorIndex, uint16 wMaxValueIndex, uint16 *pwAnchorIndex, uint16 *pwPeakListLen)
- {
- uint16 wTempIndex = 0;
- uint8 byExistFlag = 0;
-
- uint16 wCounter = wPeakListLen;
- uint16 wTemp = 0;
-
- for (uint16 i = 0; i < wPeakListLen; i++)
- {
- wTempIndex = pwPeakList[i];
- if (wTempIndex == wAnchorIndex)
- {
- byExistFlag = 1;
- break;
- }
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- if (!byExistFlag)
- {
-
- pwPeakList[wPeakListLen] = wAnchorIndex;
- wCounter++;
-
- for (uint16 k = 0; k < wCounter; k++)
- {
- for (uint16 m = k + 1; m < wCounter; m++)
- {
- if (pwPeakList[m] < pwPeakList[k])
- {
- wTemp = pwPeakList[k];
- pwPeakList[k] = pwPeakList[m];
- pwPeakList[m] = wTemp;
- }
- }
- }
- }
- *pwAnchorIndex = wAnchorIndex;
- *pwPeakListLen = wCounter;
- return;
- }
- void lct_firstpath_check_first_path_contact(flt32 *pfData, uint16 *pwPeakList, uint16 wPeakListLen, uint16 *pwOriginalList, uint16 wOriginalListLen, uint16 wAnchorIndex, uint16 wMaxValueIndex, uint16 *pwFirstPathIndex)
- {
- uint8 byContactFactor = gg_stFirstPathParam.byFirstPathContactFactor;
- uint16 wContactDistance = gg_stFirstPathParam.wFirstPathContactDistance;
- uint16 wPeakValueIndex = 0;
-
- flt32 fFirstpeakValue = 0;
- uint16 wFirstPeakIndex = 0;
-
- flt32 fSecondPeakValue = 0;
- uint16 wSecondPeakIndex = 0;
- flt32 fSecondpeakThreshold = 0;
- uint8 bySelectFlag = 0;
-
- if (wPeakListLen > 1)
- {
- for (uint16 i = 0; i < wPeakListLen - 1; i++)
- {
- wPeakValueIndex = pwPeakList[i];
- wFirstPeakIndex = pwPeakList[i];
- fFirstpeakValue = pfData[wFirstPeakIndex];
- fSecondpeakThreshold = (fFirstpeakValue / 100) * byContactFactor;
- for (uint16 k = 0; k < wOriginalListLen; k++)
- {
- wSecondPeakIndex = pwOriginalList[k];
- if (wSecondPeakIndex > wFirstPeakIndex)
- {
- fSecondPeakValue = pfData[wSecondPeakIndex];
-
- if (fSecondPeakValue > fSecondpeakThreshold)
- {
-
- if ((wSecondPeakIndex - wFirstPeakIndex) <= wContactDistance)
- {
-
- if ((wSecondPeakIndex == wAnchorIndex) || (wSecondPeakIndex == wMaxValueIndex))
- {
- *pwFirstPathIndex = wPeakValueIndex;
- bySelectFlag = 1;
- break;
- }
- else
- {
- wFirstPeakIndex = wSecondPeakIndex;
- fFirstpeakValue = fSecondPeakValue;
- fSecondpeakThreshold = (fFirstpeakValue / 100) * byContactFactor;
- }
- }
- else
- {
- bySelectFlag = 0;
- break;
- }
- }
- }
- }
- if (bySelectFlag)
- {
- break;
- }
- }
- if (!bySelectFlag)
- {
- *pwFirstPathIndex = wAnchorIndex;
- }
- }
- else
- {
- *pwFirstPathIndex = pwPeakList[wPeakListLen - 1];
- }
- return;
- }
- void lct_firstpath_cal_trackpath(flt32 *pfData, uint16 wTrackIndex, flt32 fNoise, flt32 fSelPeakThreshold, uint16 wAnchorIndex, uint16 wMaxValueIndex, FIRST_PATH_T *pstTrackPath)
- {
- uint16 awPeakList[2 * PUBLIC_LCT_TRACK_WINDOW_WIDTH + 1];
- uint16 wPeakListLen = 0;
- memset(awPeakList, 0, sizeof(uint16) * (2 * PUBLIC_LCT_TRACK_WINDOW_WIDTH + 1));
-
- lct_firstpath_sel_track_peak(pfData, wMaxValueIndex, wTrackIndex, awPeakList, &wPeakListLen);
-
- lct_firstpath_compensate_peak_gain(pfData, awPeakList, wPeakListLen);
-
- awPeakList[wPeakListLen] = wMaxValueIndex;
- wPeakListLen++;
-
- lct_firstpath_cal_first_path_by_peak_value_threshold(pfData, wMaxValueIndex, fSelPeakThreshold, awPeakList, wPeakListLen, 1, &wPeakListLen);
-
- lct_firstpath_cal_first_path_by_cfar(pfData, wMaxValueIndex, awPeakList, wPeakListLen, 1, &wPeakListLen);
-
- lct_firstpath_cal_first_path_by_sinc(pfData, wMaxValueIndex, fNoise, awPeakList, wPeakListLen, 1, &wPeakListLen);
-
- if (wPeakListLen <= 1)
- {
- pstTrackPath->byTrackSuccessFlag = 0;
- }
-
- else
- {
- pstTrackPath->byTrackSuccessFlag = 1;
- pstTrackPath->wFirstPathIndex = awPeakList[0];
- pstTrackPath->fSnr = pfData[awPeakList[0]] / fNoise;
- }
- return;
- }
- void lct_firstpath_compensate_peak_gain(flt32 *pfData, uint16 *pwPeakList, uint16 wPeakListLen)
- {
- uint16 wGuardWidth = gg_stFirstPathParam.wFirstPathTrackPeakGuardWidth;
- uint16 wFindWidth = gg_stFirstPathParam.wFirstPathTrackNoiseFindWidth;
- uint8 byPeakGainFactor = gg_stFirstPathParam.byFirstPathTrackPeakGainFactor;
- flt32 fPeakRatio = 0;
- uint16 wPeakValueIndex = 0;
- flt32 fPeakValue = 0;
- uint16 wStartIndex = 0;
- uint16 wStopIndex = 0;
- flt32 fNoiseValue = 0;
- flt32 fTmpValue = 0;
-
- for (uint16 i = 0; i < wPeakListLen; i++)
- {
- wPeakValueIndex = pwPeakList[i];
- fPeakValue = pfData[wPeakValueIndex];
- fNoiseValue = 0;
-
- if ((wPeakValueIndex - wGuardWidth - wFindWidth) >= 0)
- {
- wStartIndex = wPeakValueIndex - wGuardWidth - wFindWidth;
- }
- else
- {
- wStartIndex = 0;
- }
-
- if ((wStartIndex + wFindWidth) <= (wPeakValueIndex - wGuardWidth))
- {
- wStopIndex = wStartIndex + wFindWidth;
- }
- else
- {
- wStopIndex = wPeakValueIndex - wGuardWidth;
- }
-
- for (uint16 i = wStartIndex; i < wStopIndex; i++)
- {
- fTmpValue = pfData[i];
- if (fTmpValue > fNoiseValue)
- {
- fNoiseValue = fTmpValue;
- }
- }
-
- fPeakRatio = (fPeakValue / fNoiseValue * byPeakGainFactor) / 100;
- if (fPeakRatio > 1.2)
- {
- fPeakRatio = 1.2;
- }
- else if (fPeakRatio < 0.5)
- {
- fPeakRatio = 0.5;
- }
-
- pfData[wPeakValueIndex] = fPeakValue * fPeakRatio;
- }
- return;
- }
- void lct_firstpath_mirror_first_path_data(LCT_FIRSTPATH_LIST_T *pstFirstPathList, LCT_FIRSTPATH_LIST_T *pstAheadFirstPathList)
- {
- uint8 byCounter = pstFirstPathList->byBtsNum;
-
- for (uint8 i = 0; i < byCounter; i++)
- {
- memcpy(&pstAheadFirstPathList->astFirstPath[i], &pstFirstPathList->astFirstPath[i], sizeof(LCT_FIRSTPATH_T));
- }
- pstAheadFirstPathList->byBtsNum = byCounter;
- return;
- }
- void lct_firstpath_demirror_first_path_data(LCT_FIRSTPATH_LIST_T *pstFirstPathList, LCT_FIRSTPATH_LIST_T *pstAheadFirstPathList)
- {
- uint8 byCounter = 0;
- byCounter = pstAheadFirstPathList->byBtsNum;
-
- for (uint8 i = 0; i < byCounter; i++)
- {
- memcpy(&pstFirstPathList->astFirstPath[i], &pstAheadFirstPathList->astFirstPath[i], sizeof(LCT_FIRSTPATH_T));
- pstFirstPathList->astFirstPath[i].dwCalPathIndex += PUB_SIGNAL_SAMPLE_RATIO;
- pstFirstPathList->astFirstPath[i].dwTrackPathIndex += PUB_SIGNAL_SAMPLE_RATIO;
- }
- pstFirstPathList->byBtsNum = byCounter;
- return;
- }
- uint16 lct_firstpath_get_trackpath(LCT_FIRSTPATH_LIST_T *pstAheadFirstPathList, uint32 dwBuildId, uint32 dwLayerId, uint32 dwBtsId, uint8 byFreqIndex, uint8 bySlot)
- {
- uint8 byCounter = 0;
- uint32 dwTmpBuildId = 0;
- uint32 dwTmpLayerId = 0;
- uint32 dwTmpBtsId = 0;
- uint8 byTmpFreqIndex = 0;
- uint8 byTmpSlot = 0;
- uint16 wTrackIndex = 0;
- byCounter = pstAheadFirstPathList->byBtsNum;
- for (uint8 i = 0; i < byCounter; i++)
- {
- dwTmpBuildId = pstAheadFirstPathList->astFirstPath[i].dwBuildId;
- dwTmpLayerId = pstAheadFirstPathList->astFirstPath[i].dwLayerId;
- dwTmpBtsId = pstAheadFirstPathList->astFirstPath[i].dwBtsId;
- byTmpFreqIndex = pstAheadFirstPathList->astFirstPath[i].byFreqIndex;
- byTmpSlot = pstAheadFirstPathList->astFirstPath[i].bySlot;
-
- if ((dwTmpBuildId == dwBuildId) && (dwTmpLayerId == dwLayerId) && (dwTmpBtsId == dwBtsId) && (byTmpFreqIndex == byFreqIndex) && (byTmpSlot == bySlot))
- {
- if (pstAheadFirstPathList->astFirstPath[i].wFrameTrackIndex)
- {
- wTrackIndex = pstAheadFirstPathList->astFirstPath[i].wFrameTrackIndex;
- }
- else
- {
- wTrackIndex = pstAheadFirstPathList->astFirstPath[i].wFrameCalIndex;
- }
- break;
- }
- }
- return wTrackIndex;
- }
- void lct_firstpath_copy_ahead_first_path(LCT_FIRSTPATH_T *pstFirstPath, uint32 dwLocationIndex, uint8 byCalSlot, LCT_FIRSTPATH_LIST_T *pstAheadFirstPathList)
- {
- uint8 byBtsNum = 0;
- LCT_FIRSTPATH_T stAheadFirstPath = {0};
- byBtsNum = pstAheadFirstPathList->byBtsNum;
- for (uint8 i = 0; i < byBtsNum; i++)
- {
- stAheadFirstPath = pstAheadFirstPathList->astFirstPath[i];
- if (pstFirstPath->dwBuildId == stAheadFirstPath.dwBuildId && pstFirstPath->dwLayerId == stAheadFirstPath.dwLayerId && pstFirstPath->dwBtsId == stAheadFirstPath.dwBtsId && pstFirstPath->byFreqIndex == stAheadFirstPath.byFreqIndex && pstFirstPath->bySlot == stAheadFirstPath.bySlot)
- {
-
- if (stAheadFirstPath.wFrameTrackIndex > 0)
- {
- pstFirstPath->wFrameCalIndex = stAheadFirstPath.wFrameTrackIndex;
- pstFirstPath->wFrameTrackIndex = stAheadFirstPath.wFrameTrackIndex;
- pstFirstPath->dwCalPathIndex = dwLocationIndex + byCalSlot * PUB_SLOT_FRAME_LEN + stAheadFirstPath.wFrameTrackIndex;
- pstFirstPath->dwTrackPathIndex = dwLocationIndex + byCalSlot * PUB_SLOT_FRAME_LEN + stAheadFirstPath.wFrameTrackIndex;
- if (stAheadFirstPath.fTrackPathIndexSnr <= 0)
- {
- pstFirstPath->fCalPathIndexSnr = 3.5;
- pstFirstPath->fTrackPathIndexSnr = 3.5;
- }
- else
- {
- pstFirstPath->fCalPathIndexSnr = stAheadFirstPath.fTrackPathIndexSnr;
- pstFirstPath->fTrackPathIndexSnr = stAheadFirstPath.fTrackPathIndexSnr;
- }
- }
-
- else
- {
- pstFirstPath->wFrameCalIndex = stAheadFirstPath.wFrameCalIndex;
- pstFirstPath->wFrameTrackIndex = stAheadFirstPath.wFrameCalIndex;
- pstFirstPath->dwCalPathIndex = dwLocationIndex + byCalSlot * PUB_SLOT_FRAME_LEN + stAheadFirstPath.wFrameCalIndex;
- pstFirstPath->dwTrackPathIndex = dwLocationIndex + byCalSlot * PUB_SLOT_FRAME_LEN + stAheadFirstPath.wFrameCalIndex;
- if (stAheadFirstPath.fCalPathIndexSnr <= 0)
- {
- pstFirstPath->fCalPathIndexSnr = 3.5;
- pstFirstPath->fTrackPathIndexSnr = 3.5;
- }
- else
- {
- pstFirstPath->fCalPathIndexSnr = stAheadFirstPath.fCalPathIndexSnr;
- pstFirstPath->fTrackPathIndexSnr = stAheadFirstPath.fCalPathIndexSnr;
- }
- }
- break;
- }
- }
- }
- void lct_firstpath_copy_ahead_first_path_for_all_bts(PUB_LOCATION_DATA_T *pstLocationDataList, LCT_FIRSTPATH_LIST_T *pstAheadFirstPathList, LCT_FIRSTPATH_LIST_T *pstFirstPathList)
- {
- uint8 byBtsNum = 0;
- LCT_FIRSTPATH_T *pstAheadFirstPath = NULL;
- LCT_FIRSTPATH_T *pstFirstPath = NULL;
- PUB_LOCATION_DATA_T *pstLctData = NULL;
- uint8 byIndex = 0;
- byBtsNum = pstAheadFirstPathList->byBtsNum;
- for (uint8 i = 0; i < byBtsNum; i++)
- {
- pstAheadFirstPath = &pstAheadFirstPathList->astFirstPath[i];
- byIndex = pstAheadFirstPath->byFreqIndex;
- pstLctData = &pstLocationDataList[byIndex];
- pstFirstPath = &pstFirstPathList->astFirstPath[i];
- memcpy(pstFirstPath, pstAheadFirstPath, sizeof(LCT_FIRSTPATH_T));
-
- if (pstAheadFirstPath->wFrameTrackIndex > 0)
- {
- pstFirstPath->wFrameCalIndex = pstAheadFirstPath->wFrameTrackIndex;
- pstFirstPath->wFrameTrackIndex = pstAheadFirstPath->wFrameTrackIndex;
- pstFirstPath->dwCalPathIndex = pstLctData->dwLocationIndex + pstLctData->byCalSlot * PUB_SLOT_FRAME_LEN + pstAheadFirstPath->wFrameTrackIndex;
- pstFirstPath->dwTrackPathIndex = pstLctData->dwLocationIndex + pstLctData->byCalSlot * PUB_SLOT_FRAME_LEN + pstAheadFirstPath->wFrameTrackIndex;
- if (pstAheadFirstPath->fTrackPathIndexSnr <= 0)
- {
- pstFirstPath->fCalPathIndexSnr = 3.5;
- pstFirstPath->fTrackPathIndexSnr = 3.5;
- }
- else
- {
- pstFirstPath->fCalPathIndexSnr = pstAheadFirstPath->fTrackPathIndexSnr;
- pstFirstPath->fTrackPathIndexSnr = pstAheadFirstPath->fTrackPathIndexSnr;
- }
- }
-
- else
- {
- pstFirstPath->wFrameCalIndex = pstAheadFirstPath->wFrameCalIndex;
- pstFirstPath->wFrameTrackIndex = pstAheadFirstPath->wFrameCalIndex;
- pstFirstPath->dwCalPathIndex = pstLctData->dwLocationIndex + pstLctData->byCalSlot * PUB_SLOT_FRAME_LEN + pstAheadFirstPath->wFrameCalIndex;
- pstFirstPath->dwTrackPathIndex = pstLctData->dwLocationIndex + pstLctData->byCalSlot * PUB_SLOT_FRAME_LEN + pstAheadFirstPath->wFrameCalIndex;
- if (pstAheadFirstPath->fCalPathIndexSnr <= 0)
- {
- pstFirstPath->fCalPathIndexSnr = 3.5;
- pstFirstPath->fTrackPathIndexSnr = 3.5;
- }
- else
- {
- pstFirstPath->fCalPathIndexSnr = pstAheadFirstPath->fCalPathIndexSnr;
- pstFirstPath->fTrackPathIndexSnr = pstAheadFirstPath->fCalPathIndexSnr;
- }
- }
- }
- pstFirstPathList->byBtsNum = byBtsNum;
- return;
- }
- uint32 lct_firstpath_recal_absolute_index(uint32 dwOldIndex)
- {
- uint32 dwNewIndex = 0;
- if (dwOldIndex >= 0 && dwOldIndex < PUB_SLOT_FRAME_LEN)
- {
- dwNewIndex = dwOldIndex;
- }
- else if (dwOldIndex >= PUB_SLOT_FRAME_LEN && dwOldIndex < 2 * PUB_SLOT_FRAME_LEN)
- {
- dwNewIndex = dwOldIndex - PUB_SLOT_FRAME_LEN;
- }
- else if (dwOldIndex >= 2 * PUB_SLOT_FRAME_LEN && dwOldIndex < 3 * PUB_SLOT_FRAME_LEN)
- {
- dwNewIndex = dwOldIndex - 2 * PUB_SLOT_FRAME_LEN;
- }
- else if (dwOldIndex >= 3 * PUB_SLOT_FRAME_LEN && dwOldIndex < 4 * PUB_SLOT_FRAME_LEN)
- {
- dwNewIndex = dwOldIndex - 3 * PUB_SLOT_FRAME_LEN;
- }
- else
- {
- dwNewIndex = 0;
- }
- return dwNewIndex;
- }
- void lct_firstpath_reset_direction_valid_flag(LCT_FIRSTPATH_PREDICTION_DIRECTION_DATA_T *pstPredictionDirectionDataList)
- {
- LCT_FIRSTPATH_PREDICTION_DIRECTION_DATA_T *pstData = NULL;
- for (uint8 i = 0; i < PUB_SYS_CARRIER_NUM; i++)
- {
- pstData = &pstPredictionDirectionDataList[i];
- pstData->byValidFlag = 0;
- }
- return;
- }
- void lct_firstpath_save_first_path_data(PUB_LOCATION_DATA_T *pstLctData, LCT_FIRSTPATH_T *pstFirstPathData, LCT_FIRSTPATH_PREDICTION_DIRECTION_DATA_T *pstPredictionDirectionDataList)
- {
- uint8 byFreqIndex = 0;
- LCT_FIRSTPATH_PREDICTION_DIRECTION_DATA_T *pstResultData = NULL;
- uint32 dwBackupIndex = 0;
- byFreqIndex = pstLctData->byFreqIndex;
- pstResultData = &pstPredictionDirectionDataList[byFreqIndex];
- dwBackupIndex = pstResultData->dwFirstPathBackupIndex;
- flt32 fAmpl = 0;
- if (dwBackupIndex < LCT_FIRST_PATH_BACKUP_NUM)
- {
- pstResultData->dwFirstPathBackupIndex++;
- pstResultData->astFirstPathBackupList[dwBackupIndex].dwFrameNo = pstLctData->dwFrameNo - 1;
- pstResultData->astFirstPathBackupList[dwBackupIndex].fMaxAmplValue = pstFirstPathData->fMaxAmplValue;
- pstResultData->astFirstPathBackupList[dwBackupIndex].dwCalPathIndex = pstFirstPathData->dwCalPathIndex;
- pstResultData->astFirstPathBackupList[dwBackupIndex].dwTrackPathIndex = pstFirstPathData->dwTrackPathIndex;
- }
- else
- {
-
- memmove(pstResultData->astFirstPathBackupList, &pstResultData->astFirstPathBackupList[1], sizeof(LCT_FIRSTPATH_BACKUP_T) * (LCT_FIRST_PATH_BACKUP_NUM - 1));
-
- dwBackupIndex = LCT_FIRST_PATH_BACKUP_NUM - 1;
- pstResultData->astFirstPathBackupList[dwBackupIndex].dwFrameNo = pstLctData->dwFrameNo - 1;
- pstResultData->astFirstPathBackupList[dwBackupIndex].fMaxAmplValue = pstFirstPathData->fMaxAmplValue;
- pstResultData->astFirstPathBackupList[dwBackupIndex].dwCalPathIndex = pstFirstPathData->dwCalPathIndex;
- pstResultData->astFirstPathBackupList[dwBackupIndex].dwTrackPathIndex = pstFirstPathData->dwTrackPathIndex;
- }
- pstResultData->dwCoordX = pstFirstPathData->dwCoordX;
- pstResultData->dwCoordY = pstFirstPathData->dwCoordY;
- pstResultData->dwCoordZ = pstFirstPathData->dwCoordZ;
-
- pstResultData->dwCalPathIndex = pstFirstPathData->dwCalPathIndex;
-
- pstResultData->byValidFlag = 1;
- }
- void lct_firstpath_prediction_move_direction(LCT_FIRSTPATH_PREDICTION_DIRECTION_DATA_T *pstPredictionDirectionDataList)
- {
- LCT_FIRSTPATH_PREDICTION_DIRECTION_DATA_T *pstPredictionData = NULL;
- uint8 byLen = 0;
- LCT_FIRSTPATH_BACKUP_T *pstCurrentData = NULL;
- LCT_FIRSTPATH_BACKUP_T *pstAheadData = NULL;
- uint32 dwFrameGap = 0;
- uint8 byAheadTendency = 0;
- uint8 byCurrentTendency = 0;
- for (uint8 i = 0; i < PUB_SYS_CARRIER_NUM; i++)
- {
- pstPredictionData = &pstPredictionDirectionDataList[i];
- byAheadTendency = pstPredictionData->byDirectionTendency;
- pstPredictionData->byDirectionTendency = 0;
-
- byLen = pstPredictionData->dwFirstPathBackupIndex;
- if (byLen >= LCT_FIRST_PATH_BACKUP_NUM)
- {
- pstCurrentData = &pstPredictionData->astFirstPathBackupList[byLen - 1];
- pstAheadData = pstPredictionData->astFirstPathBackupList;
- dwFrameGap = pstCurrentData->dwFrameNo - pstAheadData->dwFrameNo;
- if (dwFrameGap == 8)
- {
-
- if ((pstCurrentData->dwCalPathIndex <= pstAheadData->dwCalPathIndex) || (pstCurrentData->dwTrackPathIndex <= pstAheadData->dwTrackPathIndex))
- {
- pstPredictionData->byDirectionTendency = 1;
-
- if (byAheadTendency == 1)
- {
- pstPredictionData->byDirectionTendency = 1;
- }
-
- else if (byAheadTendency == 2)
- {
-
- if (pstCurrentData->fMaxAmplValue >= (0.85 * pstAheadData->fMaxAmplValue))
- {
- pstPredictionData->byDirectionTendency = 1;
- }
- else
- {
- pstPredictionData->byDirectionTendency = 2;
- }
- }
- }
-
- else
- {
- pstPredictionData->byDirectionTendency = 2;
-
- if (byAheadTendency == 1)
- {
-
- if (pstCurrentData->fMaxAmplValue >= (0.9 * pstAheadData->fMaxAmplValue))
- {
- pstPredictionData->byDirectionTendency = 1;
- }
- else
- {
- pstPredictionData->byDirectionTendency = 2;
- }
- }
-
- else if (byAheadTendency == 2)
- {
- pstPredictionData->byDirectionTendency = 2;
- }
- }
- }
- }
- }
- }
|