ICETEK-DM642-C.c
上传用户:dahaojd
上传日期:2008-01-29
资源大小:14357k
文件大小:2k
- #include <csl_cache.h>
- #include "ICETEK-DM642-C.h"
- //工作变量
- #pragma DATA_SECTION(nMemTemp, ".INTPROCBUFF");
- #pragma DATA_ALIGN(nMemTemp,128);
- unsigned char nMemTemp[720];
- #pragma DATA_SECTION(cLines, ".INTPROCBUFF");
- #pragma DATA_ALIGN(cLines,128);
- unsigned char cLines[MWIDTH*3];
- #pragma DATA_SECTION(nUV, ".INTPROCBUFF");
- unsigned char nUV[720];
- int mi,mj,m_nWork1;
- unsigned int m_nWork,*pWork,m_nOffset1,m_nOffset2,m_nOffset3;
- unsigned char *pImg1,*pImg2,*pImg3;
- unsigned char x1,x2,x3,x4,x5,x6,x7,x8,x9;
- #pragma DATA_SECTION(cBuffer, ".INTPROCBUFF");
- #pragma DATA_ALIGN(cBuffer,128);
- unsigned char cBuffer[9],cWork;
- void ICETEKDM642CInit()
- {
- m_nOffset1=0;
- m_nOffset2=MWIDTH;
- m_nOffset3=MWIDTH*2;
- for ( mi=0;mi<720;mi++ )
- nUV[mi]=0x80;
- for ( mi=0;mi<MWIDTH*2;mi++ )
- cLines[mi]=0;
- }
- #pragma CODE_SECTION(ICETEKDM642CMedianFilter,".text1")
- void ICETEKDM642CMedianFilter()
- {
- unsigned int m_nID;
-
- m_nID=DAT_copy(nMemTemp,cLines+m_nOffset3,MWIDTH);
- pImg1=cLines; pImg1+=m_nOffset1;
- pImg2=cLines; pImg2+=m_nOffset2;
- pImg3=cLines; pImg3+=m_nOffset3;
- x1=(*pImg1); pImg1++; x2=(*pImg1); pImg1++;
- x4=(*pImg2); pImg2++; x5=(*pImg2); pImg2++;
- x7=(*pImg3); pImg3++; x8=(*pImg3); pImg3++;
- for ( mi=2;mi<MWIDTH;mi++,pImg1++,pImg2++,pImg3++ )
- {
- x3=(*pImg1); x6=(*pImg2); x9=(*pImg3);
- nMemTemp[mi]=GetMiddleValue();
- x1=x2; x2=x3;
- x4=x5; x5=x6;
- x7=x8; x8=x9;
- }
- nMemTemp[mi]=0;
- m_nWork=m_nOffset1; m_nOffset1=m_nOffset2;
- m_nOffset2=m_nOffset3; m_nOffset3=m_nWork;
- CACHE_clean(CACHE_L2ALL, 0, 0);
- }
- #pragma CODE_SECTION(GetMiddleValue,".text1")
- unsigned char GetMiddleValue()
- {
- int i,j;
-
- cBuffer[0]=x1; cBuffer[1]=x2; cBuffer[2]=x3;
- cBuffer[3]=x4; cBuffer[4]=x5; cBuffer[5]=x6;
- cBuffer[6]=x7; cBuffer[7]=x8; cBuffer[8]=x9;
- for ( i=0;i<8;i++ )
- for ( j=i;j<9;j++ )
- if ( cBuffer[i]>cBuffer[j] )
- {
- cWork=cBuffer[i];
- cBuffer[i]=cBuffer[j];
- cBuffer[j]=cWork;
- }
-
- return cBuffer[5];
- }