📄 cellmappingtable.cpp
字号:
ip * ip * (1 + iFrameSym) * ScatPilots.iQ, 1024);
/* Gain calculation and applying of complex value ----------- */
/* Test, if current carrier-index is one of the "boosted pilots"
position */
_BOOLEAN bIsBoostedPilot = FALSE;
for (i = 0; i < NUM_BOOSTED_SCAT_PILOTS; i++)
{
/* In case of match set flag */
if (ScatPilots.piGainTable[i] == iCar)
bIsBoostedPilot = TRUE;
}
/* Boosted pilot: Gain = 2, Regular pilot: Gain = sqrt(2) */
if (bIsBoostedPilot)
{
matcPilotCells[iSym][iCarArrInd] =
Polar2Cart(sqrt(AV_BOOSTED_PIL_POWER), iScatPilPhase);
/* Add flag for boosted pilot */
matiMapTab[iSym][iCarArrInd] |= CM_BOOSTED_PI;
}
else
{
matcPilotCells[iSym][iCarArrInd] =
Polar2Cart(sqrt(AV_PILOT_POWER), iScatPilPhase);
}
}
/* Time-reference pilots ---------------------------------------- */
/* Time refs at the beginning of each frame, we use a table */
if (iFrameSym == 0)
{
/* Use only the first column in piTableTimePilots */
if (piTableTimePilots[iTimePilotsCounter * 2] == iCar)
{
/* Set flag in mapping table, consider case of both,
scattered pilot and time pilot at same position */
if (_IsScatPil(matiMapTab[iSym][iCarArrInd]))
matiMapTab[iSym][iCarArrInd] |= CM_TI_PI;
else
matiMapTab[iSym][iCarArrInd] = CM_TI_PI;
/* Set complex value for this pilot */
matcPilotCells[iSym][iCarArrInd] =
Polar2Cart(sqrt(AV_PILOT_POWER),
piTableTimePilots[iTimePilotsCounter * 2 + 1]);
if (iTimePilotsCounter == iNumTimePilots - 1)
iTimePilotsCounter = 0;
else
iTimePilotsCounter++;
}
}
/* Frequency-reference pilots ----------------------------------- */
/* These pilots are in all symbols, the positions are stored in
a table */
/* piTableFreqPilots[x * 2]: first column;
piTableFreqPilots[x * 2 + 1]: second column */
if (piTableFreqPilots[iFreqPilotsCounter * 2] == iCar)
{
/* Set flag in mapping table, consider case of multiple
definitions of pilot-mapping */
if (_IsTiPil(matiMapTab[iSym][iCarArrInd]) ||
_IsScatPil(matiMapTab[iSym][iCarArrInd]))
{
matiMapTab[iSym][iCarArrInd] |= CM_FRE_PI;
}
else
matiMapTab[iSym][iCarArrInd] = CM_FRE_PI;
/* Set complex value for this pilot */
/* Test for "special case" defined in drm-standard */
_BOOLEAN bIsFreqPilSpeciCase = FALSE;
if (eNewRobustnessMode == RM_ROBUSTNESS_MODE_D)
{
/* For robustness mode D, carriers 7 and 21 (Means: first
and second pilot, not No. 28 (NUM_FREQ_PILOTS - 1) */
if (iFreqPilotsCounter != NUM_FREQ_PILOTS - 1)
{
/* Test for odd values of "s" (iSym) */
if ((iFrameSym % 2) == 1)
bIsFreqPilSpeciCase = TRUE;
}
}
/* Apply complex value */
if (bIsFreqPilSpeciCase)
{
matcPilotCells[iSym][iCarArrInd] =
Polar2Cart(sqrt(AV_PILOT_POWER), mod(
piTableFreqPilots[iFreqPilotsCounter * 2 + 1] +
512, 1024));
}
else
{
matcPilotCells[iSym][iCarArrInd] =
Polar2Cart(sqrt(AV_PILOT_POWER),
piTableFreqPilots[iFreqPilotsCounter * 2 + 1]);
}
/* Increase counter and wrap if needed */
if (iFreqPilotsCounter == NUM_FREQ_PILOTS - 1)
iFreqPilotsCounter = 0;
else
iFreqPilotsCounter++;
}
/* DC-carrier (not used by DRM) --------------------------------- */
/* Mark DC-carrier. Must be marked after scattered pilots, because
in one case (Robustness Mode D) some pilots must be overwritten!
*/
if (iCar == 0)
matiMapTab[iSym][iCarArrInd] = CM_DC;
/* In Robustness Mode A there are three "not used carriers" */
if (eNewRobustnessMode == RM_ROBUSTNESS_MODE_A)
{
if ((iCar == -1) || (iCar == 1))
matiMapTab[iSym][iCarArrInd] = CM_DC;
}
}
}
/* Count individual cells *************************************************/
/* We need to count the cells in a symbol for defining how many values from
each source is needed to generate one symbol in carrier-mapping */
/* Init all counters */
iMaxNumMSCSym = 0;
iNumSDCCellsPerSFrame = 0;
int iMSCCounter = 0;
int iScatPilotCellCnt = 0;
rAvPowPerSymbol = (_REAL) 0.0;
rAvScatPilPow = (_REAL) 0.0;
for (iSym = 0; iSym < iNumSymbolsPerSuperframe; iSym++)
{
/* Init all counters */
veciNumMSCSym[iSym] = 0;
veciNumFACSym[iSym] = 0;
veciNumSDCSym[iSym] = 0;
for (iCar = 0; iCar < iNumCarrier; iCar++)
{
/* MSC */
if (_IsMSC(matiMapTab[iSym][iCar]))
{
veciNumMSCSym[iSym]++;
/* Count ALL MSC cells per super-frame */
iMSCCounter++;
}
/* FAC */
if (_IsFAC(matiMapTab[iSym][iCar]))
veciNumFACSym[iSym]++;
/* SDC */
if (_IsSDC(matiMapTab[iSym][iCar]))
{
veciNumSDCSym[iSym]++;
/* Count ALL SDC cells per super-frame */
iNumSDCCellsPerSFrame++;
}
/* Calculations for average power per symbol (needed for SNR
estimation and simulation). DC carrier is zero (contributes not
to the average power) */
if (!_IsDC(matiMapTab[iSym][iCar]))
{
if (_IsData(matiMapTab[iSym][iCar]))
{
/* Data cells have average power of 1 */
rAvPowPerSymbol += AV_DATA_CELLS_POWER;
}
else
{
/* All pilots have power of 2 except of the boosted pilots
at the edges of the spectrum (they have power of 4) */
if (_IsBoosPil(matiMapTab[iSym][iCar]))
{
rAvPowPerSymbol += AV_BOOSTED_PIL_POWER;
if (_IsScatPil(matiMapTab[iSym][iCar]))
{
/* Boosted scattered pilots power */
rAvScatPilPow += AV_BOOSTED_PIL_POWER;
iScatPilotCellCnt++;
}
}
else
{
/* Regular pilot has power of 2 */
rAvPowPerSymbol += AV_PILOT_POWER;
if (_IsScatPil(matiMapTab[iSym][iCar]))
{
/* Scattered pilots power */
rAvScatPilPow += AV_PILOT_POWER;
iScatPilotCellCnt++;
}
}
}
}
}
/* Set maximum for symbol */
/* MSC */
if (iMaxNumMSCSym < veciNumMSCSym[iSym])
iMaxNumMSCSym = veciNumMSCSym[iSym];
}
/* Set number of useful MSC cells */
iNumUsefMSCCellsPerFrame =
(int) (iMSCCounter / NUM_FRAMES_IN_SUPERFRAME);
/* Calculate dummy cells for MSC */
iNoMSCDummyCells = iMSCCounter - iNumUsefMSCCellsPerFrame *
NUM_FRAMES_IN_SUPERFRAME;
/* Correct last MSC count (because of dummy cells) */
veciNumMSCSym[iNumSymbolsPerSuperframe - 1] -= iNoMSCDummyCells;
/* Normalize the average powers */
rAvPowPerSymbol /= iNumSymbolsPerSuperframe;
rAvScatPilPow /= iScatPilotCellCnt;
/* ########################################################################## */
#ifdef _DEBUG_
/* Save table in file */
FILE* pFile = fopen("test/CarMapTable.dat", "w");
/* Title */
fprintf(pFile, "Robustness mode ");
switch (eNewRobustnessMode)
{
case RM_ROBUSTNESS_MODE_A:
fprintf(pFile, "A");
break;
case RM_ROBUSTNESS_MODE_B:
fprintf(pFile, "B");
break;
case RM_ROBUSTNESS_MODE_C:
fprintf(pFile, "C");
break;
case RM_ROBUSTNESS_MODE_D:
fprintf(pFile, "D");
break;
}
fprintf(pFile, " / Spectrum occupancy %d\n\n", iSpecOccArrayIndex);
/* Actual table */
for (int i = 0; i < iNumSymbolsPerSuperframe; i++)
{
for (int j = 0; j < iNumCarrier; j++)
{
if (_IsDC(matiMapTab[i][j]))
{
fprintf(pFile, ":");
continue;
}
if (_IsMSC(matiMapTab[i][j]))
{
fprintf(pFile, ".");
continue;
}
if (_IsSDC(matiMapTab[i][j]))
{
fprintf(pFile, "S");
continue;
}
if (_IsFAC(matiMapTab[i][j]))
{
fprintf(pFile, "X");
continue;
}
if (_IsTiPil(matiMapTab[i][j]))
{
fprintf(pFile, "T");
continue;
}
if (_IsFreqPil(matiMapTab[i][j]))
{
fprintf(pFile, "f");
continue;
}
if (_IsScatPil(matiMapTab[i][j]))
{
/* Special mark for boosted pilots */
if (_IsBoosPil(matiMapTab[i][j]))
fprintf(pFile, "*");
else
fprintf(pFile, "0");
continue;
}
}
fprintf(pFile, "\n");
}
/* Legend */
fprintf(pFile, "\n\nLegend:\n\t: DC-carrier\n\t. MCS cells\n\tS SDC cells");
fprintf(pFile, "\n\tX FAC cells\n\tT time pilots\n\tf frequency pilots");
fprintf(pFile, "\n\t0 scattered pilots\n\t* boosted scattered pilots\n");
fclose(pFile);
/* Save pilot values in file */
/* Use following command to plot pilot complex values in Matlab:
clear all;close all;load PilotCells.dat;subplot(211),mesh(abs(complex(PilotCells(:,1:2:end), PilotCells(:,2:2:end))));subplot(212),mesh(angle(complex(PilotCells(:,1:2:end), PilotCells(:,2:2:end))))
(It plots the absolute of the pilots in the upper plot and angle in
the lower plot.)
*/
pFile = fopen("test/PilotCells.dat", "w");
for (int z = 0; z < iNumSymbolsPerSuperframe; z++)
{
for (int v = 0; v < iNumCarrier; v++)
fprintf(pFile, "%e %e ", matcPilotCells[z][v].real(),
matcPilotCells[z][v].imag());
fprintf(pFile, "\n");
}
fclose(pFile);
#endif
/* ########################################################################## */
}
_COMPLEX CCellMappingTable::Polar2Cart(const _REAL rAbsolute,
const int iPhase) const
{
/*
This function takes phases normalized to 1024 as defined in the drm-
standard.
*/
return _COMPLEX(rAbsolute * cos((_REAL) 2 * crPi * iPhase / 1024),
rAbsolute * sin((_REAL) 2 * crPi * iPhase / 1024));
}
int CCellMappingTable::mod(const int ix, const int iy) const
{
/* Modulus definition for integer numbers */
if (ix < 0)
return ix % iy + iy;
else
return ix % iy;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -