⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 buxx_sample.c

📁 bu1566dsp芯片用来处理ov7660或其他30万摄像模组的图像预览.图像拍照(jpeg压缩)
💻 C
📖 第 1 页 / 共 2 页
字号:
    cam.cst_y = u16CstY;
    cam.mst_x = 0;
    cam.mst_y = 0;

    aDSC_Decode(p_u16JpgCode, &u32JpgSize, &cam);
    wait(10);
    
    cam.rot_h_vflip = sROT_OFF | sHFLIP_OFF | sVFLIP_OFF;
    cam.srkx = CAM_HSIZE/10;
    cam.srky = CAM_VSIZE/10;
    cam.xsize = CAM_HSIZE/10;
    cam.ysize = CAM_VSIZE/10;

    cam.cst_x = 0;
    cam.cst_y = 0;
    cam.mst_x = 0;
    cam.mst_y = 0;
    
    aDSC_Decode(p_u16JpgCode, &u32JpgSize, &cam);

    aDSC_data_trans_st(0, 0, M_LCD_WSIZE, M_LCD_HSIZE);
}

void sJPEGCameraDecode2(UINT16 * start_add, UINT16 u16Srkx, UINT16 u16Srky)
{
    CAMSET cam;
    UINT16 *p_u16JpgCode=(UINT16 *)(start_add+2);
    UINT32 u32JpgSize=0;

    sFilterSet(sDISABLE);
    
    u32JpgSize=(*start_add)<<16;
    u32JpgSize=u32JpgSize|(*(start_add+1));
    
    if(*p_u16JpgCode!=0xd8ff)  //if dec before enc, return
    {
        data_write(OVL_CNT,0x0000);
        return;
    }

    cam.rot_h_vflip = sROT_OFF | sHFLIP_OFF | sVFLIP_OFF;
    cam.srkx = 128;
    cam.srky = 96;
    cam.xsize = M_LCD_WSIZE;
    cam.ysize = M_LCD_HSIZE;
    cam.cst_x = 0;
    cam.cst_y = 0;
    cam.mst_x = 0;
    cam.mst_y = 0;

    aDSC_fmemory_clear(0, 0, M_LCD_WSIZE, M_LCD_HSIZE, 0x000000);

    aDSC_Decode(p_u16JpgCode, &u32JpgSize, &cam);
    
    aDSC_data_trans_st(0, 0, M_LCD_WSIZE, M_LCD_HSIZE);
}

void sJPEGHostEnc(UINT16 * start_add, const UINT16 je_q)
{
    
}

void sJPEGHostDec(UINT16 * start_add, UINT16* p_u16Rgb_addr)
{
    CAMSET cam;
    UINT16 *p_u16JpgCode=(UINT16 *)(start_add+2);
    UINT32 u32JpgSize=0;

    sFilterSet(sDISABLE);
    
    u32JpgSize=(*start_add)<<16;
    u32JpgSize=u32JpgSize|(*(start_add+1));
    
    if(*p_u16JpgCode!=0xd8ff)  //if dec before enc, return
    {
        data_write(OVL_CNT,0x0000);
        return;
    }

    cam.rot_h_vflip = sROT_OFF | sHFLIP_OFF | sVFLIP_OFF;
    cam.srkx = 320;
    cam.srky = 240;
    cam.xsize = 320;
    cam.ysize = 240;
    cam.cst_x = 0;
    cam.cst_y = 0;
    cam.mst_x = 0;
    cam.mst_y = 0;

    aDSC_HostJpegDec(p_u16JpgCode, &u32JpgSize, p_u16Rgb_addr, &cam);
}

void sRgbRot(UINT16 * start_add, UINT32 rgb_size)
{
    
}

//-----------------------------------------------------------------------------
//                                                             
//-----------------------------------------------------------------------------
void sMultiShot(UINT16 * start_add, UINT32 * jpeg_size)
{
    int i;
    CAMSET cam;
    CAMSET d_cam;
    UINT32 framesize[4];

    framesize[0] = 0;
    for (i = 0; i < 3; i++)
    {
        framesize[i + 1] = framesize[i] + jpeg_size[i];
    }

 #if defined SENSOR_ROT90
    cam.rot_h_vflip = sROT_ON | sHFLIP_OFF | sVFLIP_OFF;
    cam.srkx = M_LCD_WSIZE ;
    cam.srky = M_LCD_WSIZE* 4 / 3;
#else
    cam.rot_h_vflip = sROT_OFF | sHFLIP_OFF | sVFLIP_OFF;
    cam.srkx = M_LCD_HSIZE * 4 / 3;
    cam.srky = M_LCD_HSIZE;
#endif
    cam.xsize = M_LCD_WSIZE;
    cam.ysize = M_LCD_HSIZE;

    if (cam.rot_h_vflip & sROT_ON)
    {
        cam.cst_x = (cam.srkx - cam.xsize) / 2;
        cam.cst_y = (cam.srky - cam.ysize) / 2 + 1;
        if(cam.cst_y%2)  cam.cst_y--;  
    }
    else
    {
        cam.cst_x = (cam.srkx - cam.xsize) / 2 + 1;
        cam.cst_y = (cam.srky - cam.ysize) / 2;
        if(cam.cst_x%2)  cam.cst_x--;  
    }

    cam.mst_x = 0;
    cam.mst_y = 0;


    d_cam.rot_h_vflip = sROT_OFF | sHFLIP_OFF | sVFLIP_OFF;
    d_cam.srkx = M_LCD_WSIZE / 2;
    d_cam.srky = M_LCD_HSIZE / 2;
    if (d_cam.rot_h_vflip & sROT_ON)
    {
        d_cam.xsize = M_LCD_WSIZE / 2;
        d_cam.ysize = M_LCD_HSIZE / 2;
        d_cam.cst_x = (cam.srkx - cam.xsize) / 2 + 1;
        d_cam.cst_y = (cam.srky - cam.ysize) / 2;
    }
    else
    {
        d_cam.xsize = M_LCD_WSIZE / 2;
        d_cam.ysize = M_LCD_HSIZE / 2;
        d_cam.cst_x = (cam.srkx - cam.xsize) / 2 + 1;
        d_cam.cst_y = (cam.srky - cam.ysize) / 2;
    }
    d_cam.cst_x = 0;
    d_cam.cst_y = 0;
    d_cam.mst_x = 0;
    d_cam.mst_y = 0;



    aDSC_overlayframe_off();

    for (i = 0; i < 4; i++)
    {
        aDSC_Start_Preview(0, 0, M_LCD_WSIZE, M_LCD_HSIZE, &cam);
        wait(500);
        aDSC_FrameEncode(start_add + framesize[i] / 2, &jpeg_size[i], 0, 0,
                         M_LCD_WSIZE, M_LCD_HSIZE, 0);
        aDSC_fmemory_clear(0, 0, M_LCD_WSIZE, M_LCD_HSIZE, 0x0000);
        aDSC_data_trans_st(0, 0, M_LCD_WSIZE, M_LCD_HSIZE);
    }

    for (i = 0; i < 4; i++)
    {
        d_cam.mst_x = (M_LCD_WSIZE / 2) * (i % 2);
        d_cam.mst_y = (M_LCD_HSIZE / 2) * (i / 2);
        if (aDSC_Decode
            ((start_add + framesize[i] / 2), &jpeg_size[i], &d_cam) != 0)
            break;              //err
        wait(10);
    }
    aDSC_data_trans_st(0, 0, M_LCD_WSIZE, M_LCD_HSIZE);

}

//-----------------------------------------------------------------------------
//                                                             
//-----------------------------------------------------------------------------
void sMotionJPEG_Preview(void)
{
    CAMSET cam;


    aDSC_fmemory_clear(0, 0, M_LCD_WSIZE, M_LCD_HSIZE, 0x0000);
    aDSC_data_trans_st(0, 0, M_LCD_WSIZE, M_LCD_HSIZE);

 #if defined SENSOR_ROT90
    cam.rot_h_vflip = sROT_ON | sHFLIP_OFF | sVFLIP_OFF;
    cam.srkx = 80;
    cam.srky = 80* 4 / 3;
#else
    cam.rot_h_vflip = sROT_OFF | sHFLIP_OFF | sVFLIP_OFF;
    cam.srkx = 80 * 4 / 3;
    cam.srky = 80;
#endif
    cam.xsize = 80;
    cam.ysize = 80;

    if (cam.rot_h_vflip & sROT_ON)
    {
        cam.cst_x = (cam.srkx - cam.xsize) / 2;
        cam.cst_y = (cam.srky - cam.ysize) / 2 + 1;
        if(cam.cst_y%2)  cam.cst_y--;  
    }
    else
    {
        cam.cst_x = (cam.srkx - cam.xsize) / 2 + 1;
        cam.cst_y = (cam.srky - cam.ysize) / 2;
        if(cam.cst_x%2)  cam.cst_x--;  
    }
    cam.mst_x = (M_LCD_WSIZE - 80) / 2;
    cam.mst_y = (M_LCD_HSIZE - 80) / 2;



    aDSC_Start_Preview((M_LCD_WSIZE - 80) / 2, (M_LCD_HSIZE - 80) / 2, 80,
                       80, &cam);

}



//-----------------------------------------------------------------------------
//                                                         Jpeg Decode dispose
//-----------------------------------------------------------------------------
void sMjEncode(UINT16 * start_add, UINT32 * jpeg_size)
{
    UINT32 mj_framesize;
    UINT32 motionjpeg_size = *jpeg_size;
    CAMSET cam;

 #if defined SENSOR_ROT90
    cam.rot_h_vflip = sROT_ON | sHFLIP_OFF | sVFLIP_OFF;
    cam.srkx = 80;
    cam.srky = 80* 4 / 3;
#else
    cam.rot_h_vflip = sROT_OFF | sHFLIP_OFF | sVFLIP_OFF;
    cam.srkx = 80 * 4 / 3;
    cam.srky = 80;
#endif
    cam.xsize = 80;
    cam.ysize = 80;

    if (cam.rot_h_vflip & sROT_ON)
    {
        cam.cst_x = (cam.srkx - cam.xsize) / 2;
        cam.cst_y = (cam.srky - cam.ysize) / 2 + 1;
        if(cam.cst_y%2)  cam.cst_y--;  
    }
    else
    {
        cam.cst_x = (cam.srkx - cam.xsize) / 2 + 1;
        cam.cst_y = (cam.srky - cam.ysize) / 2;
        if(cam.cst_x%2)  cam.cst_x--;  
    }
    cam.mst_x = (M_LCD_WSIZE - 80) / 2;
    cam.mst_y = (M_LCD_HSIZE - 80) / 2;

    aDSC_fmemory_clear(0, 0, M_LCD_WSIZE, M_LCD_HSIZE, 0xf800);
    aDSC_data_trans_st(0, 0, M_LCD_WSIZE, M_LCD_HSIZE);

    *jpeg_size = 0;
    do
    {
        mj_framesize = 176 * 232;
        aDSC_Start_Preview((M_LCD_WSIZE - 80) / 2, (M_LCD_HSIZE - 80) / 2,
                           80, 80, &cam);
        aDSC_FrameEncode(start_add + *jpeg_size / 2, &mj_framesize,
                         (M_LCD_WSIZE - 80) / 2, (M_LCD_HSIZE - 80) / 2,
                         80, 80, 0);
        *jpeg_size += mj_framesize;
    }
    while (*jpeg_size < motionjpeg_size - mj_framesize * 2);
}

//-----------------------------------------------------------------------------
//                                                         Jpeg Decode dispose
//-----------------------------------------------------------------------------
int sMjDecode(UINT16 * start_add, UINT32 * jpeg_size)
{
    UINT32 framesize;
    UINT32 decode_size = 0;
    int ret_code = 0;
    CAMSET cam;

    cam.rot_h_vflip = sROT_OFF | sHFLIP_OFF | sVFLIP_OFF;
    cam.srkx = 80;
    cam.srky = 80;
    cam.xsize = 80;
    cam.ysize = 80;
    cam.cst_x = 0;
    cam.cst_y = 0;
    cam.mst_x = (M_LCD_WSIZE - 80) / 2;
    cam.mst_y = (M_LCD_HSIZE - 80) / 2;

    aDSC_overlayframe_off();
    aDSC_fmemory_clear(0, 0, M_LCD_WSIZE, M_LCD_HSIZE, 0x44ff);
    aDSC_data_trans_st(0, 0, M_LCD_WSIZE, M_LCD_HSIZE);


    do
    {
        framesize = 307200;     //640*480
        ret_code =
            aDSC_Decode(start_add + decode_size / 2, &framesize, &cam);
        if (ret_code != 0)
            break;              //err
        aDSC_data_trans_st((M_LCD_WSIZE - 80) / 2, (M_LCD_HSIZE - 80) / 2,
                           80, 80);
        wait(132);
        decode_size += framesize;
    }
    while (*jpeg_size > (decode_size));

    return (ret_code);
}

void sZoomPreview(INT16 u8Zoom)
{
    CAMSET cam;
    
#if defined SENSOR_ROT90
    static UINT16 sHoriZoom=M_LCD_WSIZE;
    static UINT16 sVertZoom=M_LCD_WSIZE* 4 / 3;
    INT16 u16HoriZoomStep=3*u8Zoom;
    INT16 u16VertZoomStep=4*u8Zoom;
    UINT16 u16CamWidth=CAM_VSIZE;
    UINT16 u16CamHight=CAM_HSIZE;
    cam.rot_h_vflip = sROT_ON | sHFLIP_OFF | sVFLIP_OFF;
        
#else
    static UINT16 sHoriZoom=M_LCD_HSIZE * 4 / 3;
    static UINT16 sVertZoom=M_LCD_HSIZE;
    INT16 u16HoriZoomStep=4*u8Zoom;
    INT16 u16VertZoomStep=3*u8Zoom;
    UINT16 u16CamWidth=CAM_HSIZE;
    UINT16 u16CamHight=CAM_VSIZE;
    cam.rot_h_vflip = sROT_OFF | sHFLIP_OFF | sVFLIP_OFF;
#endif

    aDSC_overlayframe_off();

    cam.xsize = M_LCD_WSIZE;
    cam.ysize = M_LCD_HSIZE;

    if((((sHoriZoom+u16HoriZoomStep)<=u16CamWidth)&&((sHoriZoom+u16HoriZoomStep)>=cam.xsize))
        &&(((sVertZoom+u16VertZoomStep)<=u16CamHight)&&((sVertZoom+u16VertZoomStep)>=cam.ysize)))
    {
        sHoriZoom+=u16HoriZoomStep;
        sVertZoom+=u16VertZoomStep;
    }
    
    cam.srkx = sHoriZoom;
    cam.srky = sVertZoom;

    if (cam.rot_h_vflip & sROT_ON)
    {
        cam.cst_x = (cam.srkx - cam.xsize) / 2 ;
        cam.cst_y = (cam.srky - cam.ysize) / 2+ 1;
        if(cam.cst_y%2)  cam.cst_y--;  
    }
    else
    {
        cam.cst_x = (cam.srkx - cam.xsize) / 2 + 1;
        cam.cst_y = (cam.srky - cam.ysize) / 2;
        if(cam.cst_x%2)  cam.cst_x--;  
    }
    
    cam.mst_x = 0;
    cam.mst_y = 0;
    
#if 0
    gl_dsc_status=sLEDMODE;
    wait_int0(bCAMST_MSK);
    bit_write(HWMODE2, bFRM_PRT, HIGH); // Frame protect ON
    wait_int0(bLCDED_MSK);
    cam_capture_set(&cam);
    bit_write(HWMODE2, bFRM_PRT, LOW);  // Frame protect OFF
    gl_dsc_status=dummy_mode;
#endif

    cam_capture_set(&cam);

    wait(50);              // wait 50ms

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -