⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 interpolation.cpp

📁 在vc上做的802.16d ofdm phy的仿真
💻 CPP
字号:
#include "globalMacro.h"
#include "global_var.h"
#include "interpolation.h"


void	interpolation (Int16 *pInterpIn, Uint16  interpInLength,
					   Uint8 interplRate, Int16  *pInterpOut)
{
	Int16 i;
	Int16 j;
	Int16 *temp;
	Uint16 tempSize;

	tempSize = interplRate * interpInLength;
	temp = new Int16[2*tempSize];

	for (i = 0; i < interpInLength; i++)
	{
		temp[2*i] = pInterpIn[2*i];
		temp[2*i+1] = pInterpIn[2*i+1];
	}
		
	for (j = 1; j <= interplRate/2; j++)
	{ 
		pInterpOut[0] = temp[0];
		pInterpOut[1] = temp[1];
		pInterpOut[2] = (g_interpolCoeff[1] * temp[0]
						+ g_interpolCoeff[2] * temp[2]
						+ g_interpolCoeff[3] * temp[4]) / (g_interplweight - g_interpolCoeff[0]);
		pInterpOut[3] = (g_interpolCoeff[1] * temp[1]
						+ g_interpolCoeff[2] * temp[3]
						+ g_interpolCoeff[3] * temp[5]) / (g_interplweight - g_interpolCoeff[0]);
		for (i = 1; i < interpInLength/2 - 2; i++)
		{
			pInterpOut[4 * i] = temp[2 * i];
			pInterpOut[4 * i + 1] = temp[2 * i + 1];
			pInterpOut[4 * i + 2] = (g_interpolCoeff[0] * temp[2 * i - 2]
									+ g_interpolCoeff[1] * temp[2 * i]
									+ g_interpolCoeff[2] * temp[2 * i + 2]
									+ g_interpolCoeff[3] * temp[2 * i + 4]) / g_interplweight;
			pInterpOut[4 * i + 3] = (g_interpolCoeff[0] * temp[2 * i - 1]
									+ g_interpolCoeff[1] * temp[2 * i + 1]
									+ g_interpolCoeff[2] * temp[2 * i + 3]
									+ g_interpolCoeff[3] * temp[2 * i + 5]) / g_interplweight;
		}

		pInterpOut[4 * i] = temp[2 * i];
		pInterpOut[4 * i + 1] = temp[2 * i + 1];
		pInterpOut[4 * i + 2] = (g_interpolCoeff[0] * temp[2 * i - 2]
									+ g_interpolCoeff[1] * temp[2 * i]
									+ g_interpolCoeff[2] * temp[2 * i + 2]) / (g_interplweight - g_interpolCoeff[3]);
		pInterpOut[4 * i + 3] = (g_interpolCoeff[0] * temp[2 * i - 1]
									+ g_interpolCoeff[1] * temp[2 * i + 1]
									+ g_interpolCoeff[2] * temp[2 * i + 3]) / (g_interplweight - g_interpolCoeff[3]);
		i++;

		pInterpOut[4 * i] = temp[2 * i];
		pInterpOut[4 * i + 1] = temp[2 * i + 1];
		pInterpOut[4 * i + 2] = (g_interpolCoeff[0] * temp[2 * i - 2]
									+ g_interpolCoeff[1] * temp[2 * i]
									+ g_interpolCoeff[3] * temp[2 * i + 4]) / (g_interplweight - g_interpolCoeff[2]);
		pInterpOut[4 * i + 3] = (g_interpolCoeff[0] * temp[2 * i - 1]
									+ g_interpolCoeff[1] * temp[2 * i + 1]
									+ g_interpolCoeff[3] * temp[2 * i + 5]) / (g_interplweight - g_interpolCoeff[2]);
		i++;

		pInterpOut[4 * i] = temp[2 * i];
		pInterpOut[4 * i + 1] = temp[2 * i + 1];
		pInterpOut[4 * i + 2] = (g_interpolCoeff[0] * temp[2 * i - 2]
									+ g_interpolCoeff[2] * temp[2 * i + 2]
									+ g_interpolCoeff[3] * temp[2 * i + 4]) / (g_interplweight - g_interpolCoeff[1]);
		pInterpOut[4 * i + 3] = (g_interpolCoeff[0] * temp[2 * i - 1]
									+ g_interpolCoeff[2] * temp[2 * i + 3]
									+ g_interpolCoeff[3] * temp[2 * i + 5]) / (g_interplweight - g_interpolCoeff[1]);
		i++;

		pInterpOut[4 * i] = temp[2 * i];
		pInterpOut[4 * i + 1] = temp[2 * i + 1];
		pInterpOut[4 * i + 2] = (g_interpolCoeff[1] * temp[2 * i]
									+ g_interpolCoeff[2] * temp[2 * i + 2]
									+ g_interpolCoeff[3] * temp[2 * i + 4]) / (g_interplweight - g_interpolCoeff[0]);
		pInterpOut[4 * i + 3] = (g_interpolCoeff[1] * temp[2 * i + 1]
									+ g_interpolCoeff[2] * temp[2 * i + 3]
									+ g_interpolCoeff[3] * temp[2 * i + 5]) / (g_interplweight - g_interpolCoeff[0]);
		i++;

		for (; i < interpInLength - 2; i++)
		{
			pInterpOut[4 * i] = temp[2 * i];
			pInterpOut[4 * i + 1] = temp[2 * i + 1];
			pInterpOut[4 * i + 2] = (g_interpolCoeff[0] * temp[2 * i - 2]
									+ g_interpolCoeff[1] * temp[2 * i]
									+ g_interpolCoeff[2] * temp[2 * i + 2]
									+ g_interpolCoeff[3] * temp[2 * i + 4]) / g_interplweight;
			pInterpOut[4 * i + 3] = (g_interpolCoeff[0] * temp[2 * i - 1]
									+ g_interpolCoeff[1] * temp[2 * i + 1]
									+ g_interpolCoeff[2] * temp[2 * i + 3]
									+ g_interpolCoeff[3] * temp[2 * i + 5]) / g_interplweight;
		}

		pInterpOut[4*(interpInLength-2)] = temp[2*(interpInLength-2)];
		pInterpOut[4*(interpInLength-2)+1] = temp[2*(interpInLength-2)+1];
		pInterpOut[4*(interpInLength-2)+2] = (g_interpolCoeff[0] * temp[2*(interpInLength-2)-2]
											+ g_interpolCoeff[1] * temp[2*(interpInLength-2)]
											+ g_interpolCoeff[2] * temp[2*(interpInLength-2)+2]) / (g_interplweight - g_interpolCoeff[3]);
		pInterpOut[4*(interpInLength-2)+3] = (g_interpolCoeff[0] * temp[2*(interpInLength-2)-1]
											+ g_interpolCoeff[1] * temp[2*(interpInLength-2)+1]
											+ g_interpolCoeff[2] * temp[2*(interpInLength-2)+3]) / (g_interplweight - g_interpolCoeff[3]);
										
		pInterpOut[4*(interpInLength-1)] = temp[2*(interpInLength-1)];
		pInterpOut[4*(interpInLength-1)+1] = temp[2*(interpInLength-1)+1];
		pInterpOut[4*(interpInLength-1)+2] = (g_interpolCoeff[0] * temp[2*(interpInLength-1)-2]
											+ g_interpolCoeff[1] * temp[2*(interpInLength-1)]) / (g_interpolCoeff[0] + g_interpolCoeff[1]);									
		pInterpOut[4*(interpInLength-1)+3] = (g_interpolCoeff[0] * temp[2*(interpInLength-1)-1]
											+ g_interpolCoeff[1] * temp[2*(interpInLength-1)+1]) / (g_interpolCoeff[0] + g_interpolCoeff[1]);
		interpInLength = interpInLength * 2;
		for (i = 0; i < interpInLength; i++)
		{
			temp[2*i] = pInterpOut[2*i];
			temp[2*i+1] = pInterpOut[2*i+1];
		}
	}
	delete[]temp;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -