第一件事,检查下你传入的参数是否合法;
第二件事,若malloc了一块内存,必须记得free;第三件事,你是否赋值了已经溢出的值或地址。
pOrg = pcPicYuvOrg->getLumaAddr(); for( y = 0; y < height-1; y++ ) { for( x = 0; x < width-1; x++ ) { Pel A[4]; //2x2 A[0]=pOrg[x]; A[1]=pOrg[x+1]; A[2]=(pOrg+stride)[x]; A[3]=(pOrg+stride)[x+1]; if( A[0]==255 && A[1]==255 && A[2]==255 && A[3]==255 ) { pOrg[x] = 255; pOrg[x+1] = 255; (pOrg+stride)[x] = 255; (pOrg+stride)[x+1] = 255; } else { pOrg[x] = 0; pOrg[x+1] = 0; (pOrg+stride)[x] = 0; (pOrg+stride)[x+1] = 0; } x += 1; } pOrg += 2*stride; }
pOrg = pcPicYuvOrg->getLumaAddr(); for( y = 0; y < height/2; y++ ) { for( x = 0; x < width-1; x++ ) { Pel A[4]; //2x2 A[0]=pOrg[x]; A[1]=pOrg[x+1]; A[2]=(pOrg+stride)[x]; A[3]=(pOrg+stride)[x+1]; if( A[0]==255 && A[1]==255 && A[2]==255 && A[3]==255 ) { pOrg[x] = 255; pOrg[x+1] = 255; (pOrg+stride)[x] = 255; (pOrg+stride)[x+1] = 255; } else { pOrg[x] = 0; pOrg[x+1] = 0; (pOrg+stride)[x] = 0; (pOrg+stride)[x+1] = 0; } x += 1; } pOrg += 2*stride; }
Unhandled exception at 0x........ in XXXX.exe: 0xC0000005:Access violation reading location 0x......
原文地址:http://blog.csdn.net/frd2009041510/article/details/45217385