void Buffer_preview_info_update()
{
// U32 Y_size;
int temp;
unsigned int buffer_rgb;
temp = (s2440CAM->CIPRSTATUS>>26)&3;
temp = (temp + 2) % 4;
RETAILMSG(MSG_EN_2,(_T("preview index = %d, size %d\r\n"), temp, image_size));
switch (temp)
{
case 0:
buffer_rgb = s2440CAM->CIPRCLRSA1;
break;
case 1:
buffer_rgb = s2440CAM->CIPRCLRSA2;
break;
case 2:
buffer_rgb = s2440CAM->CIPRCLRSA3;
break;
case 3:
buffer_rgb = s2440CAM->CIPRCLRSA4;
break;
default :
buffer_rgb = s2440CAM->CIPRCLRSA1;
break;
}
RETAILMSG(MSG_EN_1,(_T("buffer_rgb[PHY] = 0x%x\r\n"), buffer_rgb));
buffer_rgb += VIRTUAL_ADDR_OFFSET;
#if 1
RETAILMSG(MSG_EN_1,(_T("buffer_rgb = 0x%x\r\n"), buffer_rgb));
#endif
if( rgb_flag ) RETAILMSG(MSG_EN_1,(_T("Prev Buffer is not read\r\n")));
rgb_flag = 1;
rgb_address = buffer_rgb;
}
buffer_rgb = s2440CAM->CIPRCLRSA1中的s2440CAM->CIPRCLRSA1和
void CamInit(U32 CoDstWidth, U32 CoDstHeight, U32 PrDstWidth, U32 PrDstHeight,
U32 WinHorOffset, U32 WinVerOffset, U32 CoFrameBuffer, U32 PrFrameBuffer)
{
U32 WinOfsEn;
U32 divisor, multiplier;
U32 MainBurstSizeY, RemainedBurstSizeY, MainBurstSizeC, RemainedBurstSizeC, MainBurstSizeRGB, RemainedBurstSizeRGB;
U32 H_Shift, V_Shift, PreHorRatio, PreVerRatio, MainHorRatio, MainVerRatio;
U32 SrcWidth, SrcHeight;
U32 ScaleUp_H_Co, ScaleUp_V_Co, ScaleUp_H_Pr, ScaleUp_V_Pr;
//constant for calculating codec dma address
if(CAM_CODEC_OUTPUT) //=0
divisor=2; //CCIR-422
else
divisor=4; //CCIR-420
//constant for calculating preview dma address
if(CAM_PVIEW_OUTPUT) //=1
multiplier=4;
else
multiplier=2;
if(WinHorOffset==0 && WinVerOffset==0)
WinOfsEn=0;
else
WinOfsEn=1;
SrcWidth=CAM_SRC_HSIZE-WinHorOffset*2;
SrcHeight=CAM_SRC_VSIZE-WinVerOffset*2;
if(SrcWidth>=CoDstWidth) ScaleUp_H_Co=0; //down
else ScaleUp_H_Co=1; //up
if(SrcHeight>=CoDstHeight) ScaleUp_V_Co=0;
else ScaleUp_V_Co=1;
if(SrcWidth>=PrDstWidth) ScaleUp_H_Pr=0; //down
else ScaleUp_H_Pr=1; //up
if(SrcHeight>=PrDstHeight) ScaleUp_V_Pr=0;
else ScaleUp_V_Pr=1;
////////////////// common control setting
s2440CAM->CIGCTRL |= (1<<26)|(0<<27); // inverse PCLK, test pattern
s2440CAM->CIWDOFST = (1<<30)|(0xf<<12); // clear overflow
s2440CAM->CIWDOFST = 0;
s2440CAM->CIWDOFST=(WinOfsEn<<31)|(WinHorOffset<<16)|(WinVerOffset);
//#if(CIS_TYPE == CIS_S5X3A1)
s2440CAM->CISRCFMT=(CAM_ITU601<<31)|(0<<30)|(0<<29)|(CAM_SRC_HSIZE<<16)|(CAM_ORDER_YCBYCR<<14)|(CAM_SRC_VSIZE);
//#elif(CIS_TYPE == CIS_S5X3AA)
// s2440CAM->CISRCFMT=(CAM_ITU601<<31)|(0<<30)|(0<<29)|(CAM_SRC_HSIZE<<16)|(CAM_ORDER_CBYCRY<<14)|(CAM_SRC_VSIZE);
//#endif
////////////////// codec port setting
s2440CAM->CICOYSA1=CoFrameBuffer;
s2440CAM->CICOYSA2=s2440CAM->CICOYSA1+CoDstWidth*CoDstHeight+2*CoDstWidth*CoDstHeight/divisor;
if(CoDstWidth*CoDstHeight < 655360) // Codec Max. Size = 1280*1024 Above sXGA, use only 2 memory of the 4 pingpong memory
{
s2440CAM->CICOYSA3=s2440CAM->CICOYSA2+CoDstWidth*CoDstHeight+2*CoDstWidth*CoDstHeight/divisor;
s2440CAM->CICOYSA4=s2440CAM->CICOYSA3+CoDstWidth*CoDstHeight+2*CoDstWidth*CoDstHeight/divisor;
}
else
{
s2440CAM->CICOYSA3=s2440CAM->CICOYSA1;
s2440CAM->CICOYSA4=s2440CAM->CICOYSA2;
}
s2440CAM->CICOCBSA1=s2440CAM->CICOYSA1+CoDstWidth*CoDstHeight;
s2440CAM->CICOCBSA2=s2440CAM->CICOYSA2+CoDstWidth*CoDstHeight;
s2440CAM->CICOCBSA3=s2440CAM->CICOYSA3+CoDstWidth*CoDstHeight;
s2440CAM->CICOCBSA4=s2440CAM->CICOYSA4+CoDstWidth*CoDstHeight;
s2440CAM->CICOCRSA1=s2440CAM->CICOCBSA1+CoDstWidth*CoDstHeight/divisor;
s2440CAM->CICOCRSA2=s2440CAM->CICOCBSA2+CoDstWidth*CoDstHeight/divisor;
s2440CAM->CICOCRSA3=s2440CAM->CICOCBSA3+CoDstWidth*CoDstHeight/divisor;
s2440CAM->CICOCRSA4=s2440CAM->CICOCBSA4+CoDstWidth*CoDstHeight/divisor;
s2440CAM->CICOTRGFMT=(CAM_CODEC_IN_422<<31)|(CAM_CODEC_OUTPUT<<30)|(CoDstWidth<<16)|(CAM_FLIP_NORMAL<<14)|(CoDstHeight);
CalculateBurstSize(CoDstWidth, &MainBurstSizeY, &RemainedBurstSizeY);
CalculateBurstSize(CoDstWidth/2, &MainBurstSizeC, &RemainedBurstSizeC);
s2440CAM->CICOCTRL=(MainBurstSizeY<<19)|(RemainedBurstSizeY<<14)|(MainBurstSizeC<<9)|(RemainedBurstSizeC<<4);
。。。。。
s2440CAM->CICOSCPRERATIO=((10-H_Shift-V_Shift)<<28)|(PreHorRatio<<16)|(PreVerRatio);
s2440CAM->CICOSCPREDST=((SrcWidth/PreHorRatio)<<16)|(SrcHeight/PreVerRatio);
s2440CAM->CICOSCCTRL=(CAM_SCALER_BYPASS_OFF<<31)|(ScaleUp_H_Co<<30)|(ScaleUp_V_Co<<29)|(MainHorRatio<<16)|(MainVerRatio);
s2440CAM->CICOTAREA=CoDstWidth*CoDstHeight;
///////////////// preview port setting
s2440CAM->CIPRCLRSA1=PrFrameBuffer;
s2440CAM->CIPRCLRSA2=s2440CAM->CIPRCLRSA1+PrDstWidth*PrDstHeight*multiplier;
s2440CAM->CIPRCLRSA3=s2440CAM->CIPRCLRSA2+PrDstWidth*PrDstHeight*multiplier;
s2440CAM->CIPRCLRSA4=s2440CAM->CIPRCLRSA3+PrDstWidth*PrDstHeight*multiplier;
s2440CAM->CIPRTRGFMT=(PrDstWidth<<16)|(CAM_FLIP_XAXIS<<14)|(PrDstHeight);
if (CAM_PVIEW_OUTPUT==CAM_RGB24B)
CalculateBurstSize(PrDstWidth*4, &MainBurstSizeRGB, &RemainedBurstSizeRGB);
else // RGB16B
CalculateBurstSize(PrDstWidth*2, &MainBurstSizeRGB, &RemainedBurstSizeRGB);
s2440CAM->CIPRCTRL=(MainBurstSizeRGB<<19)|(RemainedBurstSizeRGB<<14);
CalculatePrescalerRatioShift(SrcWidth, PrDstWidth, &PreHorRatio, &H_Shift);
CalculatePrescalerRatioShift(SrcHeight, PrDstHeight, &PreVerRatio, &V_Shift);
MainHorRatio=(SrcWidth<<8)/(PrDstWidth<
MainVerRatio=(SrcHeight<<8)/(PrDstHeight<
s2440CAM->CIPRSCPRERATIO=((10-H_Shift-V_Shift)<<28)|(PreHorRatio<<16)|(PreVerRatio);
s2440CAM->CIPRSCPREDST=((SrcWidth/PreHorRatio)<<16)|(SrcHeight/PreVerRatio);
s2440CAM->CIPRSCCTRL=(1<<31)|(CAM_RGB16B<<30)|(ScaleUp_H_Pr<<29)|(ScaleUp_V_Pr<<28)|(MainHorRatio<<16)|(MainVerRatio);
s2440CAM->CIPRTAREA= PrDstWidth*PrDstHeight;
// initialization for buffer addresses
y_address = s2440CAM->CICOYSA1;
cb_address = s2440CAM->CICOCBSA1;
cr_address = s2440CAM->CICOCRSA1;
rgb_address = s2440CAM->CIPRCLRSA1;
}
上面两种codec和preview 方式是不是都可以得到相关的图片?数据转化为bmp格式的图片有没有相应的函数或者编写这类函数的步骤?看到gooogleman的帖子:
http://topic.eeworld.net/u/20091021/17/b03d7311-6f69-46b4-9b5f-7f563353c668.html
void CCameratestDlg::OnButton3()
{
// TODO: Add your control notification handler code here
PINGPONG_PR image;
WORD width=GetSystemMetrics(SM_CXSCREEN);
WORD height=GetSystemMetrics(SM_CYSCREEN);
BOOL ret;
BYTE* DDBdata=new BYTE[width*height*2];
BYTE* DIBdata;
if(width>640)
width=640;
if(height>480)
height=480;
ret=DeviceIoControl(m_hled,CAM_IOCTL_SAMSUNG_CAM_PR,NULL,NULL,(PBYTE)&image,NULL,NULL,NULL);
if(!ret)
AfxMessageBox(_T("读取图片失败!"));
else
{
SetKMode(TRUE);
memcpy(DDBdata,(void *)image.rgb_address,width*height*2);
SetKMode(FALSE);
CBitmap bitmap;
HBITMAP dstBmp;
bitmap.CreateBitmap(width,height,1,16,DDBdata);
HDC hdcSrc = CreateCompatibleDC(NULL);
HDC hdcDst = CreateCompatibleDC(NULL);
BITMAPINFOHEADER bih = {0};//位图信息头
bih.biBitCount = 16;//每个像素字节大小
bih.biCompression = BI_RGB;
bih.biHeight = height;//高度
bih.biPlanes = 1;
bih.biSize = sizeof(BITMAPINFOHEADER);
bih.biSizeImage = 0;// width*height*2;//图像数据大小
bih.biWidth = width;//宽度
BITMAPFILEHEADER bfh = {0};//位图文件头
bfh.bfOffBits = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER);//到位图数据的偏移量
bfh.bfSize = bfh.bfOffBits + width*height*2;//文件总的大小
bfh.bfType = (WORD)0x4d42;
BITMAPINFO bi={0};
bi.bmiHeader=bih;
dstBmp=CreateDIBSection(hdcDst, (BITMAPINFO*)&bi, DIB_RGB_COLORS, (void **)&DIBdata, NULL, 0);
SelectObject(hdcDst, dstBmp);
SelectObject(hdcSrc, bitmap);
BitBlt(hdcDst, 0, 0, width, height, hdcSrc, 0, 0, SRCCOPY);
CFile file(_T("image.bmp"),CFile::modeCreate|CFile::modeReadWrite);
file.Write(&bfh,sizeof(bfh));
file.Write(&bih,sizeof(bih));
file.Write(DIBdata,width*height*2);
file.Close();
}
delete []DDBdata;
}
如果保存的话,保存的地点在哪儿?