📄 high_api.c
字号:
g_558_WorkStatus=STATE558_Idle;
}
}
////////////////////////////////////////////////////////////////////////////
void JpegNote(UINT8 msg, PV558_JPEGBUF ptr)
{
V558_JPEGBUF Thumb_buf;
V558_SIZE Thumb_size;
if(msg==MSG_JBUF_FULL) // fifo full
{
if((VideoFrame.Video_Discard!=NoNeedDiscard)&&(g_558_WorkStatus==STATE558_Video))
{
g_pBUF=(gUSER_CallBack)(FIFO_FULL,VideoFrame.Video_ActLenth,0);
VideoFrame.Video_ActLenth=0;
}
else
g_pBUF=(gUSER_CallBack)(FIFO_FULL,ptr->ActLen,0);
}
else if(msg==MSG_JPEG_HEADER) //start read jbuf
{
return;
}
else if(msg==MSG_CAPTURE_DONE) //fifo_end
{
if(g_558_WorkStatus!=STATE558_Video&&g_558_WorkStatus!=STATE558_FrameVideo)
{
if(g_MutiShot_pTHUMB!=0)
{
Thumb_buf.ActLen = 0;
Thumb_buf.Len = 4096;
Thumb_buf.pData = g_MutiShot_pTHUMB;
V558_JbufReadThumb(&Thumb_buf, &Thumb_size);
g_Thumb_X=Thumb_size.cx;
g_Thumb_Y=Thumb_size.cy;
V558_IppSetDisplay(g_Preview_Para.Display_W);
V558_CtrlSetWorkMode(V558_MODE_VIEW);
}
g_pBUF=(gUSER_CallBack)(FIFO_END,ptr->ActLen,0);
}
else
{
if(g_VideoStop)
{
if((VideoFrame.Video_Discard!=NoNeedDiscard)&&(g_558_WorkStatus==STATE558_Video))
{
g_pBUF+=VideoFrame.Video_ActLenth;
while(1)
{
if(*g_pBUF==0xd8)
{
*g_pBUF=0;
g_pBUF--;
VideoFrame.Video_ActLenth--;
if(*g_pBUF==0xff)
{
break;
}
}
*g_pBUF=0;
g_pBUF--;
VideoFrame.Video_ActLenth--;
}
}
else
{
g_pBUF+=ptr->ActLen;
while(1)
{
if(*g_pBUF==0xd8)
{
*g_pBUF=0;
g_pBUF--;
ptr->ActLen--;
if(*g_pBUF==0xff)
{
break;
}
}
*g_pBUF=0;
g_pBUF--;
ptr->ActLen--;
}
}
g_VideoStop=0;
}
if((VideoFrame.Video_Discard!=NoNeedDiscard)&&(g_558_WorkStatus==STATE558_Video))
g_pBUF=(gUSER_CallBack)(VIDEO_END,VideoFrame.Video_ActLenth,0); //angela 1122
else
g_pBUF=(gUSER_CallBack)(VIDEO_END,ptr->ActLen,0);
}
}
ptr->pData=g_pBUF;
}
/********************************************************************************
Description:
Capture a still JPEG
Parameters:
pUCallBack: User's call back function for memory assigning and JPEG saving
Note:
Before capture a still, the V558 should be in preview mode
Remarks:
Please refer to USER558_SetCaptureParameter() for capture size
*********************************************************************************/
void USER558_CaptureStill(USER558_CallBack pUCallBack)
{
V558_JPEGBUF g_buf;
V558_CtrlIntEnable(V558_INT_AUTO_FUNC, 0); //disable AE
USER558_OneFrameEnd();
Delay(200);
gUSER_CallBack=pUCallBack;
g_Length=0;
g_pBUF=(gUSER_CallBack)(FIFO_INIT,0,0);
g_MutiShot_pTHUMB=0;
g_buf.ActLen = 0;
g_buf.Len = 0x8000;
g_buf.pData = g_pBUF;
V558_CaptureStill(&g_buf, JpegNote);
g_558_WorkStatus=STATE558_Capture;
}
/********************************************************************************
Description:
Capture a still JPEG from LCD display(include A&B layer)
Parameters:
pUCallBack: User's call back function for memory assigning and JPEG saving
Note:
Before capture a still, the V558 should be in preview mode
Remarks:
JPEG resolution is same as preview window.
*********************************************************************************/
void USER558_CaptureLCDStill(USER558_CallBack pUCallBack)
{
V558_JPEGBUF g_buf;
V558_CtrlIntEnable(V558_INT_AUTO_FUNC, 0); //disable AE
gUSER_CallBack=pUCallBack;
g_Length=0;
g_pBUF=(gUSER_CallBack)(FIFO_INIT,0,0);
g_MutiShot_pTHUMB=0;
g_buf.ActLen = 0;
g_buf.Len = 0x8000;
g_buf.pData = g_pBUF;
V558_CaptureFrame(&g_buf, JpegNote);
g_558_WorkStatus=STATE558_Capture;
}
/********************************************************************************
Description:
Get a JPEG Decod information.
Parameters:
pJPEG: the buffer for source jpeg frame saving.
dstwidth: decode target width.
*ptempwidth: reasonable decode target width
*ptempheight:reasonable decode target height
Return:
Status:
0: JPEG ERROR, can't decode;
1: JPEG is ok;
Note:
*********************************************************************************/
UINT8 USER558_GetDecodeInfo(UINT8 *pJPEG, UINT16 dstwidth, UINT16* ptempwidth,UINT16* ptempheight)
{
V558_JPEGBUF SourBuf;
V558_JPEG_INDEX pinfo;
UINT8 temp=0;
SourBuf.ActLen= 0x10000;
SourBuf.Len = 0x10000;
SourBuf.pData = pJPEG;
if(V558_JpegParse(&SourBuf, &pinfo)) return 0;
temp=pinfo.YUVType;
if(pinfo.YUVType==1)
{
*ptempwidth=pinfo.JpgSize.cx;
*ptempheight=pinfo.JpgSize.cy;
return 1;
}
V558_GetDecodeIppSize(pinfo.JpgSize.cx,pinfo.JpgSize.cy,dstwidth, ptempwidth,ptempheight);
return 1;
}
/********************************************************************************
Description:
Decod a jpeg file to yuv .
Parameters:
pJPEG: the buffer for source jpeg frame saving.
pDest: the buffer for destination yuv file.
Target_Width: destination yuv file's width
(if jpeg is type420, this parameter is negelect, the target YUV size is same as source JPEG size)
yuvmode: yuv formats of output
USER558_422_YYUV=4,
USER558_422_YUYV,
USER558_422_UYVY
pUCallBack: User's call back function .
Return:
0: JPEG ERROR, can't decode;
1: JPEG is ok;
Note:
Target_Width:the targt width must less than the width of source image.
the length width ratio should be as same as the source image
*********************************************************************************/
UINT8 USER558_JpegDecode(UINT8 *pJPEG, UINT8 *pDest,UINT16 Target_Width,UINT8 yuvmode)
{
V558_JPEGBUF decBuf;
V558_JPEGBUF SourBuf;
V558_JPEG_INDEX pinfo;
UINT8 temp=0;
SourBuf.ActLen= 0x10000;
SourBuf.Len = 0x10000;
SourBuf.pData = pJPEG;
decBuf.ActLen = 0;
decBuf.Len = 0x96000;
decBuf.pData = pDest;
if(V558_JpegParse(&SourBuf, &pinfo)) return temp;
temp=pinfo.YUVType;
if(yuvmode<V558_PYUV_422_YYUV)
yuvmode=V558_PYUV_422_YYUV;
if(yuvmode>USER558_422_UYVY)
yuvmode=USER558_422_UYVY;
if(temp==V558_YUV_420)
{
temp=V558_HostDecode(&SourBuf, &decBuf,yuvmode, &pinfo, JpegNote);
}
else
{
temp=V558_HostDecodeIpp(&SourBuf,&decBuf,yuvmode, &pinfo,JpegNote,Target_Width);
}
g_558_WorkStatus=STATE558_EnDecode;
if(temp)
return 0;
else
return 1;
}
/********************************************************************************
Description:
Decode a yuv file to jpeg .
Parameters:
pJPEG: the buffer for source yuv frame saving.
pDest: the buffer for destination jpeg file.
Source_Width: the width of source yuv file.
Source_height: the height of source yuv file.
yuvmode:
USER558_422_YYUV=4,
USER558_422_YUYV,
USER558_422_UYVY
pUCallBack: User's call back function .
Note:
*********************************************************************************/
void USER558_JpegEncode(UINT8 *pYUV, UINT8 *pDest,UINT16 Source_Width,UINT16 Source_height,UINT8 yuvmode,USER558_CallBack pUCallBack)
{
V558_JPEGBUF EncBuf;
V558_JPEGBUF SourBuf;
V558_SIZE size;
gUSER_CallBack=pUCallBack;
g_Length=0;
g_pBUF=(gUSER_CallBack)(FIFO_INIT,0,0);
SourBuf.ActLen= 0x10000;
SourBuf.Len = 0x10000;
SourBuf.pData = pYUV;
EncBuf.ActLen = 0;
EncBuf.Len = 0x80000;
EncBuf.pData = pDest;
size.cx=Source_Width;
size.cy=Source_height;
if(yuvmode<V558_PYUV_422_YYUV)
yuvmode=V558_PYUV_422_YYUV;
if(yuvmode>USER558_422_UYVY)
yuvmode=USER558_422_UYVY;
V558_HostEncode(&SourBuf,& EncBuf, JpegNote,size, yuvmode);
g_558_WorkStatus=STATE558_EnDecode;
}
/********************************************************************************
Description:
Display a still JPEG on LCD(A layer)
Parameters:
jpegBuf: the JPEG buffer point
Lcd_OffsetX: display offset X on LCD
Lcd_OffsetY: display offset Y on LCD
Display_W: display width on LCD
Display_H: display hight on LCD
*********************************************************************************/
void USER558_DisplayJpegFile(UINT8 *jpegBuf, UINT16 Lcd_OffsetX, UINT16 Lcd_OffsetY, UINT16 Display_W, UINT16 Display_H)
{
UINT8 Special;
UINT16 temp;
V558_LAYER_PROPERTY proty;
V558_JPEGBUF decBuf;
V558_JPEG_INDEX info;
Special=V558_LcdGetDispMode();
if(Special==0|Special==1) //90or 270
{
proty.Size.cx = Display_W;
proty.Size.cy = Display_H;
proty.DisRect.left = 0;
proty.DisRect.top =0;
proty.DisRect.width = Display_H;
proty.DisRect.height =Display_W;
proty.DisPoint.x = Lcd_OffsetX/4;
proty.DisPoint.y = Lcd_OffsetY;
}
else //normal
{
proty.Size.cx = Display_W;
proty.Size.cy = Display_H;
proty.DisRect.left = 0;
proty.DisRect.top = 0;
proty.DisRect.width = Display_W;
proty.DisRect.height =Display_H;
proty.DisPoint.x = Lcd_OffsetX;
proty.DisPoint.y = Lcd_OffsetY;
}
decBuf.ActLen = 0x10000;
decBuf.pData = (UINT8 *)jpegBuf;
decBuf.Len = 0x8000;
temp = 0x5000;
if(V558_JpegParse(&decBuf, &info) == 0)
{
V558_SetReg(V558_REG_LCD_IST, 0);
V558_LcdALEnable();
V558_DisplayStill(&decBuf, &info, &proty);
while( ((V558_LcdGetInterrupt() & 0x3) == 0) && (temp-- != 0) );
}
g_558_WorkStatus=STATE558_Display;
}
/********************************************************************************
Description:
Start capture video
Parameters:
pUCallBack: User's call back function for memory assigning and video saving
Frame: the number of every frame to discard.if 0 ,do not discard any frame
Note:
Before capture a video, the V558 should be in preview mode
Remarks:
Please refer to USER558_SetCaptureParameter() for video size
*********************************************************************************/
void USER558_CaptureVideo_Start(UINT8 Frame,USER558_CallBack pUCallBack)
{
V558_JPEGBUF g_buf;
if(Frame)
{
VideoFrame.Capture_Video_Done=CaputingVideoNow;
VideoFrame.Discard_Number=Frame;
VideoFrame.Frame_NowNumber=0;
VideoFrame.Video_Discard=PrapareDiscard;
VideoFrame.Video_Data=0;
VideoFrame.Video_ActLenth=0;
}
else
{
VideoFrame.Capture_Video_Done=CaputingVideoNow;
VideoFrame.Discard_Number=Frame;
VideoFrame.Frame_NowNumber=0;
VideoFrame.Video_Discard=NoNeedDiscard;
VideoFrame.Video_Data=0;
VideoFrame.Video_ActLenth=0;
}
gUSER_CallBack=pUCallBack;
g_Length=0;
g_pBUF=(gUSER_CallBack)(FIFO_INIT,0,0);
g_VideoStop=0;
g_MutiShot_pTHUMB=0;
g_buf.ActLen = 0;
g_buf.Len = 0x8000;
g_buf.pData = g_pBUF;
g_558_WorkStatus=STATE558_Video;
g_FrameEnd=0;
V558_StartCapVideo(&g_buf, JpegNote);
}
/********************************************************************************
Description:
Start capture video from LCD(include A&B layer),
Parameters:
pUCallBack: User's call back function for memory assigning and video saving
Note:
Before capture a video, the V558 should be in preview mode
Remarks:
Please refer to USER558_CaptureLCDStill() for video resolution
*********************************************************************************/
void USER558_CaptureLCDVideo_Start(USER558_CallBack pUCallBack)
{
V558_JPEGBUF g_buf;
UINT16 LcdGamma;
LcdGamma=V558_LcdGetIFControl();
if(LcdGamma&0x40)
g_Preview_Para.Lcd_Gamma=1;
else
g_Preview_Para.Lcd_Gamma=0;
V558_LcdDisableGamma();
gUSER_CallBack=pUCallBack;
g_Length=0;
g_pBUF=(gUSER_CallBack)(FIFO_INIT,0,0);
g_VideoStop=0;
g_MutiShot_pTHUMB=0;
g_buf.ActLen = 0;
g_buf.Len = 0x8000;
g_buf.pData = g_pBUF;
g_558_WorkStatus=STATE558_FrameVideo;
V558_CaptureFrameVideo(&g_buf, JpegNote);
}
/********************************************************************************
Description:
Stop video capture
Note:
This function only can be called after capture (LCD)video start
*********************************************************************************/
void USER558_CaptureVideo_Stop(void)
{
//g_558_WorkStatus=STATE558_Idle;
g_VideoStop=1;
V558_StopCapVideo();
}
/********************************************************************************
Description:
Capture a still attached thumbnail
Parameters:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -