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

📄 noisefilter.cpp

📁 这是G.723和G.729的音频编解码的源代码
💻 CPP
字号:


#include "stdafx.h"
#include "noisefilter.h"

void CNoiseFilter::YUVComponentFilter(BYTE* pbyInputPicture,BYTE* pbyOutputPicture,int nWidth,int nHeight)
{		
	int nOff,nCol,nLine,nSum=0,nTotal=0,nNum=3;
	static int coff[7]={0,3,0};//2^0, 2^3, 2^0
	int * pcoff=&coff[1];
	int i;
	nTotal=10;//2^0+2^3+2^0
	
//	for(int i=0;i<nNum;i++)	
	//	nTotal+=coff[i];
	

	static BYTE pbyTemp[352*288];
	
	//horizontal filter
	BYTE* pI=pbyInputPicture;
	BYTE* pO=pbyTemp;
	for(nLine=0;nLine<nHeight;nLine++)
	{
		for(nCol=1;nCol<nWidth-1;nCol++)
		{
			nSum=0;
			for(i=-1;i<=1;i++)
				nSum+=((*(pI+nCol+i))<<(*(pcoff+i)));
			*(pO+nCol)=nSum/nTotal;			
		}
		pI+=nWidth;
		pO+=nWidth;
	}

	//fill pbyTemp left 3 colum and right colum
	pO=pbyTemp;
	pI=pbyInputPicture;
	for(nLine=0;nLine<nHeight;nLine++)
	{
		*pO=*pI;
		pI+=nWidth;
		pO+=nWidth;
		*(pO-1)=*(pI-1);
	}

	//vertical filter
	pI=pbyTemp+1*nWidth;
	pO=pbyOutputPicture+1*nWidth;
	for(nLine=1;nLine<nHeight-1;nLine++)
	{
		for(nCol=0;nCol<nWidth;nCol++)
		{		
			nOff=-1*nWidth;
			nSum=0;
			for(i=-1;i<=1;i++)
			{
				nSum+=((*(pI+nOff+nCol))<<(*(pcoff+i)));
				nOff+=nWidth;
			}
			*(pO+nCol)=nSum/nTotal;
		}		
		pI+=nWidth;
		pO+=nWidth;		
	}

	//fill up 3 lines and dow 3 lines
	pI=pbyTemp;
	pO=pbyOutputPicture;
	for(nLine=0;nLine<1;nLine++)
	{
		memcpy(pO,pI,nWidth);
		pI+=nWidth;
		pO+=nWidth;
	}
	pI=pbyTemp+nWidth*(nHeight-1);
	pO=pbyOutputPicture+nWidth*(nHeight-1);
	for(nLine=nHeight-1;nLine<nHeight;nLine++)
	{
		memcpy(pO,pI,nWidth);
		pI+=nWidth;
		pO+=nWidth;
	}
}

void CNoiseFilter::PlaneYUV411Filter(BYTE* pbyInputPicture,BYTE* pbyOutputPicture,int nWidth,int nHeight)
{	
	//Y component
	YUVComponentFilter(pbyInputPicture,pbyOutputPicture,nWidth,nHeight);

	//U component
	YUVComponentFilter(pbyInputPicture+nWidth*nHeight,pbyOutputPicture+nWidth*nHeight,nWidth/2,nHeight/2);

	//V component
	YUVComponentFilter(pbyInputPicture+nWidth*nHeight+nWidth*nHeight/4,pbyOutputPicture+nWidth*nHeight+nWidth*nHeight/4,nWidth/2,nHeight/2);
}

⌨️ 快捷键说明

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