源代码:函数外定义了全局变量
           unsigned char* Yuv;
           unsigned char* R;
           unsigned char* G;
           unsigned char* B;
           CString fileName;
void CDCTDlg::Transform(unsigned char *p, unsigned char *R, unsigned char *G, unsigned char *B)//把yuv转为RGB
{
int m_AllSize=AllSize>>2;
for (int i=0;i<HEIGHT;i++)  
for(int j=0;j<WIDTH;j++)
{   
int w=(i/2)*(WIDTH/2)+j/2;
R[i*WIDTH+j]=p[i*WIDTH+j]+1.4022*(p[AllSize+m_AllSize+w]-128);
G[i*WIDTH+j]=p[i*WIDTH+j]-0.3456*(p[AllSize+w]-128)-0.7145*(p[AllSize+m_AllSize+w]-128);
B[i*WIDTH+j]=p[i*WIDTH+j]+1.771*(p[AllSize+w]-128);

}
}void CDCTDlg::Show(unsigned char *R, unsigned char *G, unsigned char *B, HDC hdc, CRect rect)//显示图像
{
unsigned char* Bmp;
Bmp=new unsigned char[AllSize*3];

for(int h=HEIGHT-1,i=0;h>=0;h--,i++)
for(int j=0;j<WIDTH;j++)
{
Bmp[i*WIDTH*3+j*3]=B[WIDTH*h+j];
Bmp[i*WIDTH*3+j*3+1]=G[WIDTH*h+j];
Bmp[i*WIDTH*3+j*3+2]=R[WIDTH*h+j];
}

BITMAPINFO *bmpinfo;
bmpinfo=(BITMAPINFO*)malloc (sizeof(BITMAPINFO));  //创建位图文件包
BITMAPINFOHEADER *bmpinfoheader = &(bmpinfo->bmiHeader); 
bmpinfoheader->biSize=sizeof(BITMAPINFOHEADER);
bmpinfoheader->biWidth=WIDTH;
bmpinfoheader->biHeight=HEIGHT;
bmpinfoheader->biBitCount=24;
bmpinfoheader->biCompression=BI_RGB;
bmpinfoheader->biSizeImage=abs(3*AllSize);
bmpinfoheader->biClrImportant=0;
bmpinfoheader->biClrUsed=0;
bmpinfoheader->biXPelsPerMeter=0;
bmpinfoheader->biYPelsPerMeter=0;
bmpinfoheader->biPlanes=1;
//显示位图
::SetStretchBltMode(hdc,COLORONCOLOR); 
::StretchDIBits(hdc,rect.left,rect.top,rect.Width(),rect.Height(),0,0,WIDTH,HEIGHT,
Bmp,bmpinfo,DIB_RGB_COLORS,+SRCCOPY);
}
void CDCTDlg::OnBtnOpen() 
{
// TODO: Add your control notification handler code here
int m_AllSize=AllSize>>2;
Yuv=new unsigned char[AllSize+m_AllSize*2];
R=new unsigned char[AllSize];
G=new unsigned char[AllSize];
B=new unsigned char[AllSize]; CFileDialog fileDlg(TRUE);
fileDlg.m_ofn.lpstrTitle="选择文件";
fileDlg.m_ofn.lpstrFilter="Yuv Files(*.yuv)\0*.yuv\0All Files(*.*)\0*.*\0\0"; if(IDOK==fileDlg.DoModal())
fileName=fileDlg.GetFileName(); CString str1="已选择视频:"+fileName+"\n\n单击按钮播放第一帧";
CString str2="单击按钮播放DCT变换后图像";
GetDlgItem(IDC_CLIENTDC1)->SetWindowText(str1);
GetDlgItem(IDC_CLIENTDC2)->SetWindowText(str2); CFile file(fileName,CFile::modeRead);
file.Read(Yuv,AllSize+m_AllSize*2);
}
void CDCTDlg::OnBtnDct() //作DCT变换
{
// TODO: Add your control notification handler code here
unsigned char F[HEIGHT][WIDTH];
unsigned char f[HEIGHT][WIDTH];
unsigned char *T;
T=new unsigned char[AllSize]; for(int i=0;i<HEIGHT;i++)
for(int j=0;j<WIDTH;j++)
{
f[i][j]=Yuv[i+WIDTH*j]; } for(i=0;i<22;i++)
for(int j=0;j<18;j++)
{
for(int u=0;u<8;u++)
for(int v=0;v<8;v++)
{
double sum=0;
double cu,cv;
if(u==0&&v==0)
cu=cv=1/(sqrt(2));
else cu=cv=1;

for(int x=0;x<8;x++)
for(int y=0;y<8;y++)
sum+=f[x+8*i][y+8*j]*cos((2*x+1)*u*PI/16)*cos((2*y+1)*v*PI/16); ********** F[u+8*i][v+8*j]=1/4*cu*cv*sum;
}
} for(i=0;i<HEIGHT;i++)
for(int j=0;j<WIDTH;j++)
{
T[i*WIDTH+j]=F[i][j];
} CDCTDlg dlg;
HDC m_hdc;
CRect rect;
GetDlgItem(IDC_CLIENTDC2)->GetClientRect(&rect);
m_hdc=GetDlgItem(IDC_CLIENTDC2)->GetDC()->m_hDC;

dlg.Transform(T,R,G,B);
dlg.Show(R,G,B,m_hdc,rect);
Sleep(100);
}
问题应该就出在DCT变换那个函数里,调试到标注******那一行时,就弹出unhandled exception:0xC0000005Acess violation
请各位帮我看看,问题到底在哪,怎么解决?谢谢了