//////////////////////////////////////////////////////////////////////////////// #include "SysCommon.h" //#include "AppCommon.h" //////////////////////////////////////////////////////////////////////////////// #include "vendor_isp.h" #include "PhotoFast.h" #include "MovieFast.h" #include "SysSensor.h" #include #include "ImageApp/ImageApp_Photo.h" #include "GxSound.h" #include "sys_mempool.h" #include "comm/hwclock.h" #include "NamingRule/NameRule_Custom.h" #include "FileDB.h" #include "SizeConvert.h" #include "UIApp/ExifVendor.h" #include "sys_fastboot.h" #include "flow_preview.h" #include #include #include #include #include #include "GxTime.h" #include "DxHunting.h" #include "PrjInc.h" #include "sys_fwload.h" #include "plat/gpio.h" #include "SizeConvert.h" #include "exif/Exif.h" #include "SizeConvert.h" #include "vendor_videoenc.h" #include "vendor_isp.h" #include "GxImageFile.h" #include "PhotoFastCapDateImprint.h" #include "DCF.h" #include "flow_boot_linux.h" #include "UIAppPhoto_Param.h" #if HUNTING_CAMERA_MCU == ENABLE #include #include "sf_led.h" #endif #include "sf_sd_common.h" #if POWERON_FAST_SLICE_ENC == ENABLE #include "PhotoFastSliceEncode.h" #endif #define THIS_DBGLVL 2 // 0=FATAL, 1=ERR, 2=WRN, 3=UNIT, 4=FUNC, 5=IND, 6=MSG, 7=VALUE, 8=USER #if 1//_TODO #define __MODULE__ PhotoFast #define __DBGLVL__ 2 // 0=FATAL, 1=ERR, 2=WRN, 3=UNIT, 4=FUNC, 5=IND, 6=MSG, 7=VALUE, 8=USER #define __DBGFLT__ "*" //*=All, [mark]=CustomClass #include #include "kwrap/cmdsys.h" #endif #define VDO_YUV_BUFSIZE(w, h, pxlfmt) ALIGN_CEIL_4(((w) * (h) * HD_VIDEO_PXLFMT_BPP(pxlfmt)) / 8) #define FILE_SN_MAX 99999 #define FILEDB_MAX_NUM 5000 #define _PHOTO_FDB_ROOT_MAX NMC_ROOT_MAX_LEN #define PHY2VIRT_MAIN(pa_pos, pa_start, va) (va + (pa_pos - pa_start)) #define PRI_PHOTOFAST_CMDTSK 11 #define STKSIZE_PHOTOFAST_CMDTSK 4096 #define FASTCAPTURE_AE_DEBUG 1 #define VD_TICK_BUF_SIZE (PHOTOFAST_START_CAP_FRAME_CNT * 3) //global variable static _FDB_SN_FASTBOOT g_fdb_sn_fastboot={ FALSE, "_", 1, 6 }; //local variable static ID PHOTOFAST_FLG_ID = 0; static THREAD_HANDLE g_photofast_tsk_id = 0; static UINT32 g_photofast_tsk_run = 1; static CHAR g_photo_fast_fdb_root_folder[_PHOTO_FDB_ROOT_MAX] = {0}; static BOOL g_photo_fast_is_fdb_root_folder = FALSE; static MEM_RANGE g_photo_fast_fdb_pool = {0}; static CHAR g_photo_fast_write_file_Path[NMC_TOTALFILEPATH_MAX_LEN] = {0}; static INT32 g_photo_fast_id_mapping[PHOTO_CAP_ID_MAX] = {-1,-1}; static PHOTO_FILENAME_CB *g_fpPhotoFastFileNameCB = NULL; /*************************************************** * Get from MovieFast **************************************************/ extern DCF_HANDLE g_dcf_hdl; #if (FS_MULTI_STRG_FUNC) extern DCF_HANDLE g_dcf_hdl2; #endif static HD_PATH_ID g_video_enc_path[PHOTO_ENC_JPG_TYPE_MAX_ID] = {0}; static UINT32 g_bVideoEncPathStart[PHOTO_ENC_JPG_TYPE_MAX_ID] = {0}; static HD_VIDEOENC_BUFINFO g_enc_buf_info[PHOTO_ENC_JPG_TYPE_MAX_ID] = {0}; static PHOTOFAST_HD_COM_BUF g_exif_data_buf = {0}; static PHOTOFAST_HD_COM_BUF g_enc_yuv_buf[PHOTO_ENC_JPG_TYPE_MAX_ID] = {0}; HD_VIDEOENC_BS g_bs_data_pull[PHOTO_ENC_JPG_TYPE_MAX_ID] = {0}; static UINT32 g_enc_jpg_va[PHOTO_ENC_JPG_TYPE_MAX_ID] = {0}, g_enc_jpg_size[PHOTO_ENC_JPG_TYPE_MAX_ID] = {0}; static UINT32 g_enc_vir_addr[PHOTO_ENC_JPG_TYPE_MAX_ID] = {0}; static BOOL g_bPreViewPullFlag = TRUE; static UINT32 g_vcap_frm_cnt = 1; /* start from 1 */ static UINT32 g_vprc_frm_cnt_ae_preset = 9999; static UINT32 g_vprc_frm_cnt = 1; /* start from 1 */ static BOOL g_ae_preset_flag = FALSE; static UINT32 g_exif_buf_pa = 0, g_exif_buf_va = 0; static UINT32 g_u32PrvCapCnt = 0; static VOS_TICK g_tickBuf[VD_TICK_BUF_SIZE] = {0}; static UINT32 g_vcap_trigger_frm_count = 0XFFFFFFFF; /* start from 0 */ AET_STATUS_INFO ae_status = {0}; /* size of AET_STATUS_INFO is quite large, don't put it in the stack */ //extern extern const unsigned char gDemoKit_Font[]; extern const unsigned char gDemoKit_Image[]; extern UINT32 Movie2_nextFolderID; extern UINT32 Movie2_nextFileID; //function INT32 PhotoFast_FileNaming_MakePath(UINT32 filetype, CHAR *pPath, UINT32 uiPathId); INT32 PhotoFast_Phy2LogID(UINT32 id); THREAD_RETTYPE PhotoFast_EncodeBsPullThread(void *ptr); UINT32 PhotoFast_GetExpectSize_RhoBRCrtl(UINT32 ImgIdx, BOOL bPrimaryOnly); INT32 PhotoFast_WriteFile(UINT32 Addr, UINT32 Size, UINT32 Fmt, UINT32 uiPathId, char* Path); static void PhotoFast_ShutDown(void); void Set_NIGHTMODE(UINT32 id, UINT8 isSnapVideo); void Set_AEMODE(UINT32 id); void PhotoFast_TriggerFrm_Dump(void); static HD_RESULT init_enc_module(void) { HD_RESULT hd_ret; HD_PATH_ID video_enc_path = 0; //init videoenc module if ((hd_ret = hd_videoenc_init()) != HD_OK){ DBG_ERR("hd_videoenc_init failed (%d)\r\n", hd_ret); return hd_ret; } if ((hd_ret = hd_videoenc_open(HD_VIDEOENC_0_IN_0, HD_VIDEOENC_0_OUT_0, &video_enc_path)) != HD_OK){ DBG_ERR("hd_videoenc_open HD_VIDEOENC_0_IN_0 failed (%d)\r\n", hd_ret); return hd_ret; } g_video_enc_path[PHOTO_ENC_JPG_PRIMARY] = video_enc_path; if ((hd_ret = hd_videoenc_open(HD_VIDEOENC_0_IN_1, HD_VIDEOENC_0_OUT_1, &video_enc_path)) != HD_OK){ DBG_ERR("hd_videoenc_open HD_VIDEOENC_0_IN_1 failed (%d)\r\n", hd_ret); return hd_ret; } g_video_enc_path[PHOTO_ENC_JPG_SCREENNAIL] = video_enc_path; if ((hd_ret = hd_videoenc_open(HD_VIDEOENC_0_IN_2, HD_VIDEOENC_0_OUT_2, &video_enc_path)) != HD_OK){ DBG_ERR("hd_videoenc_open HD_VIDEOENC_0_IN_2 failed (%d)\r\n", hd_ret); return hd_ret; } g_video_enc_path[PHOTO_ENC_JPG_THUMBNAIL] = video_enc_path; return HD_OK; } static HD_RESULT uninit_enc_module(void) { HD_RESULT hd_ret; UINT32 i; for (i=0; i < PHOTO_ENC_JPG_TYPE_MAX_ID; i++) { if (g_bVideoEncPathStart[i]) { hd_ret = hd_videoenc_stop(g_video_enc_path[i]); if (hd_ret != HD_OK) { DBG_ERR("vdoenc stop failed, hd_ret = %d\r\n", hd_ret); return hd_ret; } } hd_ret = hd_videoenc_close(g_video_enc_path[i]); if (hd_ret != HD_OK) { DBG_ERR("vdoencp close failed, hd_ret = %d\r\n", hd_ret); return hd_ret; } if (g_enc_vir_addr[i]) { hd_common_mem_munmap((void *)g_enc_vir_addr[i], g_enc_buf_info[i].buf_info.buf_size); g_enc_vir_addr[i] = 0; } } hd_ret = hd_videoenc_uninit(); if (hd_ret != HD_OK) { DBG_ERR("vdoencp close failed, hd_ret = %d\r\n", hd_ret); return hd_ret; } return HD_OK; } static HD_RESULT set_enc_cfg(void) { HD_VIDEOENC_PATH_CONFIG video_enc_path_config = {0}; HD_RESULT hd_ret; UINT32 u32W, u32H; UINT32 ThumbTargetBytes = THUMBNAIL_TARGETBYTERATE; #if HUNTING_CAMERA_MCU == ENABLE UIMenuStoreInfo *puiPara = sf_ui_para_get(); UINT32 ScrTargetBytes = ((sf_get_screen_nail_width(puiPara->SendPicSize)) * (sf_get_screen_nail_height(puiPara->SendPicSize))*3/(2*JPG_COMERESSED_RATIO_8)); #else UINT32 ScrTargetBytes = SCREENNAIL_TARGETBYTERATE; #endif UINT32 PriTargetBytes = PhotoFast_GetExpectSize_RhoBRCrtl(UI_GetData(FL_PHOTO_SIZE), TRUE); UINT32 PriTargetUBoundBytes = PRIMARY_TARGETBYTERATE_UBOUND(PriTargetBytes); //primary image u32W = GetPhotoSizeWidth(SysGetFlag(FL_PHOTO_SIZE)); u32H = GetPhotoSizeHeight(SysGetFlag(FL_PHOTO_SIZE)); video_enc_path_config.max_mem.codec_type = HD_CODEC_TYPE_JPEG; video_enc_path_config.max_mem.max_dim.w = u32W; video_enc_path_config.max_mem.max_dim.h = u32H; video_enc_path_config.max_mem.bitrate = JPG_FILE_BUFFER_SIZE(PriTargetUBoundBytes, ScrTargetBytes, ThumbTargetBytes, CFG_JPG_HEADER_SIZE)*8; video_enc_path_config.max_mem.enc_buf_ms = 1500; video_enc_path_config.max_mem.svc_layer = HD_SVC_DISABLE; video_enc_path_config.max_mem.ltr = FALSE; video_enc_path_config.max_mem.rotate = FALSE; video_enc_path_config.max_mem.source_output = FALSE; video_enc_path_config.isp_id = 0; hd_ret = hd_videoenc_set(g_video_enc_path[PHOTO_ENC_JPG_PRIMARY], HD_VIDEOENC_PARAM_PATH_CONFIG, &video_enc_path_config); if (hd_ret != HD_OK) { DBG_ERR("set the primary enc_path_config = %d\r\n", hd_ret); } //screennail image #if HUNTING_CAMERA_MCU == ENABLE u32W = sf_get_screen_nail_width(puiPara->SendPicSize); u32H = sf_get_screen_nail_height(puiPara->SendPicSize); video_enc_path_config.max_mem.bitrate = ScrTargetBytes*8; #else u32W = CFG_SCREENNAIL_W; u32H = CFG_SCREENNAIL_H; video_enc_path_config.max_mem.bitrate = SCREENNAIL_TARGETBYTERATE*8; #endif video_enc_path_config.max_mem.codec_type = HD_CODEC_TYPE_JPEG; video_enc_path_config.max_mem.max_dim.w = u32W; video_enc_path_config.max_mem.max_dim.h = u32H; video_enc_path_config.max_mem.enc_buf_ms = 1500; video_enc_path_config.max_mem.svc_layer = HD_SVC_DISABLE; video_enc_path_config.max_mem.ltr = FALSE; video_enc_path_config.max_mem.rotate = FALSE; video_enc_path_config.max_mem.source_output = FALSE; video_enc_path_config.isp_id = 0; hd_ret = hd_videoenc_set(g_video_enc_path[PHOTO_ENC_JPG_SCREENNAIL], HD_VIDEOENC_PARAM_PATH_CONFIG, &video_enc_path_config); if (hd_ret != HD_OK) { DBG_ERR("set the primary enc_path_config = %d\r\n", hd_ret); } //thumbnail image u32W = CFG_THUMBNAIL_W; u32H = CFG_THUMBNAIL_H; video_enc_path_config.max_mem.codec_type = HD_CODEC_TYPE_JPEG; video_enc_path_config.max_mem.max_dim.w = u32W; video_enc_path_config.max_mem.max_dim.h = u32H; video_enc_path_config.max_mem.bitrate = THUMBNAIL_TARGETBYTERATE*8; video_enc_path_config.max_mem.enc_buf_ms = 1500; video_enc_path_config.max_mem.svc_layer = HD_SVC_DISABLE; video_enc_path_config.max_mem.ltr = FALSE; video_enc_path_config.max_mem.rotate = FALSE; video_enc_path_config.max_mem.source_output = FALSE; video_enc_path_config.isp_id = 0; hd_ret = hd_videoenc_set(g_video_enc_path[PHOTO_ENC_JPG_THUMBNAIL], HD_VIDEOENC_PARAM_PATH_CONFIG, &video_enc_path_config); if (hd_ret != HD_OK) { DBG_ERR("set the primary enc_path_config = %d\r\n", hd_ret); } return hd_ret; } static HD_RESULT set_enc_param(void *pParam, UINT32 ParamType, PHOTOFAST_ENC_INFO *pEncInfo) { HD_RESULT hd_ret = HD_OK; HD_VIDEOENC_IN video_enc_in_param = {0}; HD_VIDEO_FRAME *p_video_frame = NULL; if ((!pParam) || (!pEncInfo)) { DBG_ERR("pParam or pEncInfo is NULL"); return HD_ERR_SYS; } switch (ParamType) { case HD_VIDEOENC_PARAM_IN: p_video_frame = (HD_VIDEO_FRAME *)pParam;; video_enc_in_param.dir = HD_VIDEO_DIR_NONE; video_enc_in_param.pxl_fmt = HD_VIDEO_PXLFMT_YUV420; video_enc_in_param.dim.w = p_video_frame->dim.w; video_enc_in_param.dim.h = p_video_frame->dim.h; video_enc_in_param.frc = HD_VIDEO_FRC_RATIO(1,1); hd_ret = hd_videoenc_set(g_video_enc_path[pEncInfo->EncJpgType], HD_VIDEOENC_PARAM_IN, &video_enc_in_param); break; case HD_VIDEOENC_PARAM_OUT_ENC_PARAM: hd_ret = hd_videoenc_set(g_video_enc_path[pEncInfo->EncJpgType], HD_VIDEOENC_PARAM_OUT_ENC_PARAM, pParam); break; default: DBG_ERR("No paramter type\r\n"); hd_ret = HD_ERR_SYS; break; } return hd_ret; } static HD_RESULT set_enc_vendor(void *pParam, UINT32 ParamType, PHOTOFAST_ENC_INFO *pEncInfo) { HD_RESULT hd_ret = HD_OK; if ((!pParam) || (!pEncInfo)) { DBG_ERR("pParam or pEncInfo is NULL"); return HD_ERR_SYS; } switch (ParamType) { case VENDOR_VIDEOENC_PARAM_OUT_BS_RESERVED_SIZE: hd_ret = vendor_videoenc_set(g_video_enc_path[pEncInfo->EncJpgType], VENDOR_VIDEOENC_PARAM_OUT_BS_RESERVED_SIZE, pParam); break; case VENDOR_VIDEOENC_PARAM_OUT_JPG_BRC: hd_ret = vendor_videoenc_set(g_video_enc_path[pEncInfo->EncJpgType], VENDOR_VIDEOENC_PARAM_OUT_JPG_BRC, pParam); break; default: DBG_ERR("No paramter type\r\n"); hd_ret = HD_ERR_SYS; break; } return hd_ret; } void PhotoFast_Cal_Jpg_Size(USIZE *psrc, USIZE *pdest , URECT *pdestwin) { SIZECONVERT_INFO scale_info = {0}; scale_info.uiSrcWidth = psrc->w; scale_info.uiSrcHeight = psrc->h; scale_info.uiDstWidth = pdest->w; scale_info.uiDstHeight = pdest->h; scale_info.uiDstWRatio = pdest->w; scale_info.uiDstHRatio = pdest->h; scale_info.alignType = SIZECONVERT_ALIGN_FLOOR_32; DisplaySizeConvert(&scale_info); pdestwin->x = scale_info.uiOutX; pdestwin->y = scale_info.uiOutY; pdestwin->w = scale_info.uiOutWidth; pdestwin->h = scale_info.uiOutHeight; //DBG_DUMP("Dst: x %d, y %d, w %d, h %d\r\n", pdestwin->x, pdestwin->y, pdestwin->w, pdestwin->h); } ER PhotoFast_Scale_YUV(VF_GFX_SCALE *pscale, HD_VIDEO_FRAME *psrc, PHOTOFAST_HD_COM_BUF *pComBufInfo, USIZE *pdest_sz, URECT *pdestwin, HD_VIDEO_PXLFMT pxl_fmt) { UINT32 blk_size; UINT32 addr[HD_VIDEO_MAX_PLANE] = {0}; UINT32 loff[HD_VIDEO_MAX_PLANE] = {0}; VF_GFX_DRAW_RECT fill_rect = {0}; HD_RESULT hd_ret; if (!pComBufInfo) { DBG_ERR("pComBufInfo is NULL\r\n"); return E_SYS; } blk_size = VDO_YUV_BUFSIZE(pdest_sz->w, pdest_sz->h, pxl_fmt); if (blk_size > pComBufInfo->blk_size) { DBG_ERR("Request blk_size(%d) > pComBufInfo->blk_size(%d)\r\n", blk_size, pComBufInfo->blk_size); return E_SYS; } // set src #if 0 addr[0] = psrc->phy_addr[HD_VIDEO_PINDEX_Y]; loff[0] = psrc->loff[HD_VIDEO_PINDEX_Y]; if(pxl_fmt == HD_VIDEO_PXLFMT_YUV420 ){ addr[1] = psrc->phy_addr[HD_VIDEO_PINDEX_UV]; loff[1] = psrc->loff[HD_VIDEO_PINDEX_UV]; }else{ addr[1] = psrc->phy_addr[HD_VIDEO_PINDEX_U]; loff[1] = psrc->loff[HD_VIDEO_PINDEX_U]; addr[2] = psrc->phy_addr[HD_VIDEO_PINDEX_V]; loff[2] = psrc->loff[HD_VIDEO_PINDEX_V]; } if ((hd_ret = vf_init_ex(&(pscale->src_img), psrc->dim.w, psrc->dim.h, psrc->pxlfmt, loff, addr)) != HD_OK) { DBG_ERR("vf_init_ex src failed(%d)\r\n", hd_ret); } #else memcpy(&pscale->src_img, psrc, sizeof(HD_VIDEO_FRAME)); #endif // set dest addr[0] = pComBufInfo->pa; loff[0] = ALIGN_CEIL_4(pdest_sz->w); if(pxl_fmt == HD_VIDEO_PXLFMT_YUV420 ){ addr[1] = addr[0] + loff[0] * pdest_sz->h; loff[1] = ALIGN_CEIL_4(pdest_sz->w); }else{ addr[1] = addr[0] + loff[0] * pdest_sz->h; loff[1] = ALIGN_CEIL_4(pdest_sz->w); addr[2] = addr[0] + loff[0] * pdest_sz->h + (loff[1] * pdest_sz->h)/2; loff[2] = ALIGN_CEIL_4(pdest_sz->w); } if ((hd_ret = vf_init_ex(&(pscale->dst_img), pdest_sz->w, pdest_sz->h, pxl_fmt, loff, addr)) != HD_OK) { DBG_ERR("vf_init_ex dst failed(%d)\r\n", hd_ret); } if ((pdest_sz->w != pdestwin->w ) || (pdest_sz->h != pdestwin->h)) { // clear buffer by black //gximg_fill_data((VDO_FRAME *)&(pscale->dst_img), GXIMG_REGION_MATCH_IMG, COLOR_YUV_BLACK); memcpy((void *)&(fill_rect.dst_img), (void *)&(pscale->dst_img), sizeof(HD_VIDEO_FRAME)); fill_rect.color = COLOR_RGB_BLACK; fill_rect.rect.x = 0; fill_rect.rect.y = 0; fill_rect.rect.w = pdest_sz->w; fill_rect.rect.h = pdest_sz->h; fill_rect.type = HD_GFX_RECT_SOLID; fill_rect.thickness = 0; fill_rect.engine = 0; if ((hd_ret = vf_gfx_draw_rect(&fill_rect)) != HD_OK) { DBG_ERR("vf_gfx_draw_rect failed(%d)\r\n", hd_ret); } } // set config pscale->engine = 0; pscale->src_region.x = 0; pscale->src_region.y = 0; pscale->src_region.w = psrc->dim.w; pscale->src_region.h = psrc->dim.h; pscale->dst_region.x = pdestwin->x; pscale->dst_region.y = pdestwin->y; pscale->dst_region.w = pdestwin->w; pscale->dst_region.h = pdestwin->h; pscale->dst_img.blk = pComBufInfo->blk; pscale->quality = HD_GFX_SCALE_QUALITY_BILINEAR; vf_gfx_scale(pscale, 1); pscale->dst_img.count = 0; pscale->dst_img.timestamp = hd_gettime_us(); return E_OK; } static ER PhotoFast_InitExif(void) { ER ret = E_SYS; HD_RESULT hd_ret; UINT32 pa, blk_size; void *va; HD_COMMON_MEM_DDR_ID ddr_id = DDR_ID0; MEM_RANGE buf; EXIF_InstallID(); blk_size = 64 * 1024; if(g_exif_buf_va == 0) { if ((hd_ret = hd_common_mem_alloc("exifbuf", &pa, (void **)&va, blk_size, ddr_id)) != HD_OK) { DBG_ERR("hd_common_mem_alloc failed(%d)\r\n", hd_ret); return E_NOMEM; } g_exif_buf_va = (UINT32)va; g_exif_buf_pa = (UINT32)pa; buf.addr = g_exif_buf_va; buf.size = 0x10000; EXIF_Init(EXIF_HDL_ID_1, &buf, ExifCB); ret = E_OK; } return ret; } static ER PhotoFast_UninitExif(void) { ER ret = E_OK; HD_RESULT hd_ret; if(g_exif_buf_pa == 0){ ret = E_OK; return ret; } if ((hd_ret = hd_common_mem_free(g_exif_buf_pa, (void *)g_exif_buf_va)) != HD_OK) { DBG_ERR("hd_common_mem_free failed(%d)\r\n", hd_ret); ret = E_SYS; } g_exif_buf_pa = 0; g_exif_buf_va = 0; if (g_exif_data_buf.blk != HD_COMMON_MEM_VB_INVALID_BLK && g_exif_data_buf.blk != 0) { if (g_exif_data_buf.va) { hd_common_mem_munmap((void *)g_exif_data_buf.va, g_exif_data_buf.blk_size); g_exif_data_buf.va = 0; } hd_common_mem_release_block(g_exif_data_buf.blk); g_exif_data_buf.blk = HD_COMMON_MEM_VB_INVALID_BLK; } EXIF_UninstallID(); return ret; } #if defined(_UI_STYLE_LVGL_) #include "lvgl/lvgl.h" #include "UIApp/lv_user_font_conv/lv_user_font_conv.h" #include "flow_lvgl.h" #else static void PhotoFast_InitGxGfx(void) { UINT32 uiPoolAddr =0; //Initial all states, all buffers DBG_FUNC_BEGIN("\r\n"); uiPoolAddr = mempool_gxgfx_temp; //////////////////////////////////////////////////////////////// GxGfx_Config(CFG_STRING_BUF_SIZE, 256); //Init Gfx GxGfx_Init((UINT32 *)uiPoolAddr, POOL_SIZE_GFX_TEMP); //initial Graphics //set default shape, text, image state for GxGfx GxGfx_SetAllDefault(); //set custom image state for GxGfx GxGfx_SetImageStroke(ROP_KEY, IMAGEPARAM_DEFAULT); GxGfx_SetImageColor(IMAGEPALETTE_DEFAULT, IMAGEPARAM_DEFAULT); #if (DRAM_SIZE_64MB_DISP_OFF==ENABLE) GxGfx_SetImageTable((const IMAGE_TABLE *)NULL); GxGfx_SetTextStroke((const FONT *)NULL, FONTSTYLE_NORMAL, SCALE_1X); #else GxGfx_SetImageTable((const IMAGE_TABLE *)gDemoKit_Image); GxGfx_SetTextStroke((const FONT *)gDemoKit_Font, FONTSTYLE_NORMAL, SCALE_1X); #endif //set custom text state for GxGfx GxGfx_SetTextColor(TEXTFORECOLOR1_DEFAULT, TEXTFORECOLOR2_DEFAULT, TEXTFORECOLOR3_DEFAULT); } #endif static UINT32 PhotoFast_GetScreenNailSize(void) { UINT32 uiImageSize, ScreenNailSize; UINT32 BitStreamSize; ScreenNailSize = CFG_SCREENNAIL_SIZE; uiImageSize = UI_GetData(FL_PHOTO_SIZE); if (uiImageSize < ScreenNailSize) { #if HUNTING_CAMERA_MCU == ENABLE UIMenuStoreInfo *puiPara = sf_ui_para_get(); BitStreamSize = (sf_get_screen_nail_width(puiPara->SendPicSize)) * (sf_get_screen_nail_height(puiPara->SendPicSize)) / 2; #else BitStreamSize = CFG_SCREENNAIL_W * CFG_SCREENNAIL_H / 2; #endif } else { BitStreamSize = 0; } DBG_IND("[cap]ScreenNail BitStreamSize =%d K\r\n", BitStreamSize / 1024); return BitStreamSize; } UINT32 PhotoFast_GetExpectSize_RhoBRCrtl(UINT32 ImgIdx, BOOL bPrimaryOnly) { UINT32 BitstreamSize; BitstreamSize = GetPhotoSizeWidth(ImgIdx)*GetPhotoSizeHeight(ImgIdx)*3/2; switch (UI_GetData(FL_QUALITY)) { case QUALITY_FINE: BitstreamSize = (UINT32)(BitstreamSize / JPG_COMERESSED_RATIO_11); break; case QUALITY_NORMAL: BitstreamSize = (UINT32)(BitstreamSize / JPG_COMERESSED_RATIO_14); break; case QUALITY_ECONOMY: default: BitstreamSize = (UINT32)(BitstreamSize / JPG_COMERESSED_RATIO_18); break; } if (!bPrimaryOnly) { BitstreamSize += CFG_JPG_HEADER_SIZE + PhotoFast_GetScreenNailSize(); } return BitstreamSize; } static ER PhotoFast_InstallID(void) { ER ret = E_OK; T_CFLG cflg; memset(&cflg, 0, sizeof(T_CFLG)); if ((ret |= vos_flag_create(&PHOTOFAST_FLG_ID, &cflg, "PHOTOFAST_FLG")) != E_OK) { DBG_ERR("PHOTOFAST_FLG_ID fail\r\n"); } return ret; } static void PhotoFast_CmdTsk_Exit(void) { g_photofast_tsk_run = 0; } static THREAD_RETTYPE PhotoFast_CmdTsk(void* arg) { FLGPTN uiFlag = 0, wait_flag = 0; VK_TASK_HANDLE handle_movie_filenaming = 0; VK_TASK_HANDLE handle_movie_moviemode = 0; THREAD_ENTRY(); wait_flag = FLGPHOTOFAST_CHGMODE | FLGPHOTOFAST_SHUTDOWN; g_photofast_tsk_run = TRUE; while (g_photofast_tsk_run) { vos_flag_wait(&uiFlag, PHOTOFAST_FLG_ID, wait_flag, TWF_ORW | TWF_CLR); if (uiFlag & FLGPHOTOFAST_SHUTDOWN) { PhotoFast_ShutDown(); } else if (uiFlag & FLGPHOTOFAST_CHGMODE) { PhotoFast_CmdTsk_Exit(); switch (DrvGPIO_GetPhotoMovieModeFromMonitor()) { case DX_HUNTING_MODE_PHOTO_MOVIE: case DX_HUNTING_MODE_CAMERA_PHOTO_MOVIE: fwload_wait_done(CODE_SECTION_10); System_OnPowerPreInit(); System_OnVideoFastbootInit(); handle_movie_filenaming = vos_task_create(MovieFast_InitFileNamingThread, "init_fn", NULL, 10, 8192); if(!handle_movie_filenaming){ DBG_ERR("create MovieFast_InitFileNamingThread failed\n"); } else vos_task_resume(handle_movie_filenaming); fastboot_wait_done(BOOT_INIT_FILENAMINGOK); handle_movie_moviemode = vos_task_create(MovieFast_InitMovieModeThread, "init_movie", NULL, 10, 8192); if(!handle_movie_moviemode){ DBG_ERR("create MovieFast_InitMovieModeThread failed\n"); } else vos_task_resume(handle_movie_moviemode); break; } } else { DBG_WRN("No flag for PhotoFast_CmdTsk\r\n"); } } THREAD_RETURN(0); } HD_RESULT PhotoFast_get_hd_common_buf(PPHOTOFAST_HD_COM_BUF p_hd_comm_buf) { // get memory p_hd_comm_buf->blk = hd_common_mem_get_block(HD_COMMON_MEM_COMMON_POOL, p_hd_comm_buf->blk_size, DDR_ID0); // Get block from mem pool if (p_hd_comm_buf->blk == HD_COMMON_MEM_VB_INVALID_BLK) { DBG_ERR("config_vdo_frm: get blk fail, blk(0x%x)\n", p_hd_comm_buf->blk ); return HD_ERR_SYS; } p_hd_comm_buf->pa = hd_common_mem_blk2pa(p_hd_comm_buf->blk); // get physical addr if (p_hd_comm_buf->pa == 0) { DBG_ERR("config_vdo_frm: blk2pa fail, blk(0x%x)\n", p_hd_comm_buf->blk); return HD_ERR_SYS; } p_hd_comm_buf->va = (UINT32)hd_common_mem_mmap(HD_COMMON_MEM_MEM_TYPE_CACHE, p_hd_comm_buf->pa, p_hd_comm_buf->blk_size); if (p_hd_comm_buf->va == 0) { DBG_ERR("Convert to VA failed for file buffer for decoded buffer!\r\n"); return HD_ERR_SYS; } return HD_OK; } static void PhotoFast_FileNaming_Init(void) { static UINT8 is_init = 0; if(is_init == 1) return; is_init = 1; DCF_InstallID(); DCF_SetParm(DCF_PRMID_REMOVE_DUPLICATE_FOLDER, TRUE); DCF_SetParm(DCF_PRMID_REMOVE_DUPLICATE_FILE, TRUE); DCF_SetParm(DCF_PRMID_SET_VALID_FILE_FMT, DCF_FILE_TYPE_JPG|DCF_FILE_TYPE_MP4|DCF_FILE_TYPE_MOV); DCF_SetParm(DCF_PRMID_SET_DEP_FILE_FMT, DCF_FILE_TYPE_JPG|DCF_FILE_TYPE_WAV|DCF_FILE_TYPE_MPO); DCF_SetDirFreeChars(DCF_DIR_NAME); DCF_SetFileFreeChars(DCF_FILE_TYPE_ANYFORMAT, DCF_FILE_NAME); } INT32 PhotoFast_FileNaming_Open(void) { DCF_OPEN_PARM dcfParm = { .Drive = 'A', .WorkbuffAddr = mempool_dcf, .WorkbuffSize = POOL_SIZE_DCF_BUFFER, }; PhotoFast_FileNaming_Init(); if(g_dcf_hdl == -1){ g_dcf_hdl = DCF_Open(&dcfParm); if(g_dcf_hdl < 0){ DBG_ERR("get dcf handle error!\n"); } DCF_ScanObjEx(g_dcf_hdl); #if USE_RTOS_MMC_CHECK //SF_RtosStrgSetDcfHandle(MMC_DEV_SD, g_dcf_hdl); #endif } else{ DBG_WRN("dcf handle1 is already opened\n"); } return 0; } INT32 PhotoFast_FileNaming_Open2(void) { #if (FS_MULTI_STRG_FUNC) DCF_OPEN_PARM dcfParm = { .Drive = 'B', .WorkbuffAddr = mempool_dcf + POOL_SIZE_DCF_BUFFER, .WorkbuffSize = POOL_SIZE_DCF_BUFFER, }; PhotoFast_FileNaming_Init(); if(g_dcf_hdl2 == -1){ g_dcf_hdl2 = DCF_Open(&dcfParm); if(g_dcf_hdl2 < 0){ DBG_ERR("get dcf handle error!\n"); } DBG_WRN("DCF_ScanObjEx emmc handle=%d\n", g_dcf_hdl2); DCF_ScanObjEx(g_dcf_hdl2); #if USE_RTOS_MMC_CHECK //SF_RtosStrgSetDcfHandle(MMC_DEV_EMMC, g_dcf_hdl2); #endif } else{ DBG_WRN("dcf handle2 is already opened\n"); } #endif return 0; } INT32 PhotoFast_FileNaming_Close(void) { if(DrvGPIO_GetPhotoMovieModeFromMonitor() != DX_HUNTING_MODE_PHOTO_MOVIE ){ if(g_dcf_hdl >= 0){ DCF_Close(g_dcf_hdl); g_dcf_hdl = -1; } #if (FS_MULTI_STRG_FUNC) if(g_dcf_hdl2 >= 0){ DCF_Close(g_dcf_hdl2); g_dcf_hdl2 = -1; } #endif DCF_UnInstallID(); } #if USE_RTOS_MMC_CHECK //SF_RtosStrgSetDcfHandle(MMC_DEV_SD, g_dcf_hdl); //SF_RtosStrgSetDcfHandle(MMC_DEV_EMMC, g_dcf_hdl2); #endif return 0; } INT32 PhotoFast_FileNaming_MakePath(UINT32 filetype, CHAR *pPath, UINT32 uiPathId) { //if (filetype == IMGCAP_FSYS_RAW) if (filetype == HD_CODEC_TYPE_RAW) NH_CustomUti_MakePhotoPath(uiPathId, NAMERULECUS_FILETYPE_RAW, pPath); else NH_CustomUti_MakePhotoPath(uiPathId, NAMERULECUS_FILETYPE_JPG, pPath); return 0; } /* Set the record root name Set the folder name. @param[in] config_id. @param[in] value . @return INT32 */ INT32 PhotoFast_FileNaming_SetRootPath(CHAR *prootpath) { if (!prootpath) { return -1; } memset(g_photo_fast_fdb_root_folder, 0, _PHOTO_FDB_ROOT_MAX); memcpy(g_photo_fast_fdb_root_folder, prootpath, _PHOTO_FDB_ROOT_MAX); g_photo_fast_is_fdb_root_folder = TRUE; //NH_Custom_SetRootPathByPath(0, g_isf_photo_fdb_root_folder); return 0; } /** Set buffer for FileDB Set buffer for FileDB @param[in] PHOTO_CFG_MEM_RANGE @return void */ INT32 PhotoFast_FileNaming_SetFileDBPool(MEM_RANGE *pPool) { if (!pPool) { return -1; } memcpy(&g_photo_fast_fdb_pool, pPool, sizeof(MEM_RANGE)); return 0; } INT32 PhotoFast_FileNaming_SetFolder(PHOTO_CAP_FOLDER_NAMING *pfolder_naming) { NMC_FOLDER_INFO nmc_folder_info = {0}; if (!g_photo_fast_is_fdb_root_folder) { DBG_ERR("PhotoFast_Root_Path is not set!!!!\r\n"); return -1; } if (pfolder_naming->cap_id >= PHOTO_CAP_ID_MAX) { DBG_ERR("cap_id %d >= max %d\r\n",pfolder_naming->cap_id,PHOTO_CAP_ID_MAX); return -1; } NH_Custom_SetRootPathByPath(pfolder_naming->cap_id, g_photo_fast_fdb_root_folder); g_photo_fast_id_mapping[pfolder_naming->cap_id] = pfolder_naming->ipl_id; nmc_folder_info.pathid = pfolder_naming->cap_id; nmc_folder_info.pMovie = NULL; nmc_folder_info.pEMR = NULL; nmc_folder_info.pRO = NULL; nmc_folder_info.pPhoto = pfolder_naming->folder_path; nmc_folder_info.pEvent1 = NULL; nmc_folder_info.pEvent2 = NULL; nmc_folder_info.pEvent3 = NULL; NH_Custom_SetFolderPath(&nmc_folder_info); return 0; } void PhotoFast_FileNaming_SetFileNameCB(PHOTO_FILENAME_CB *pfFileNameCb) { if (pfFileNameCb) { g_fpPhotoFastFileNameCB = (PHOTO_FILENAME_CB *) pfFileNameCb; } } INT32 PhotoFast_Phy2LogID(UINT32 id) { return 0; } CHAR* PhotoFast_GetLastWriteFilePath(void) { return g_photo_fast_write_file_Path; } void PhotoFast_FileNaming_SetSortBySN(CHAR *pDelimStr, UINT32 nDelimCount, UINT32 nNumOfSn) { if (pDelimStr) { g_fdb_sn_fastboot.SortSN_Delim = pDelimStr; g_fdb_sn_fastboot.SortSN_DelimCount = nDelimCount; g_fdb_sn_fastboot.SortSN_CharNumOfSN = nNumOfSn; g_fdb_sn_fastboot.bIsSortBySn= TRUE; } else DBG_ERR("No set Delim String!!\r\n"); } DCF_HANDLE PhotoFast_Get_DCF_Handle() { //#if (FS_MULTI_STRG_FUNC) /* check free space here */ //return g_dcf_hdl2; //#else //return g_dcf_hdl; //#endif SF_RtosStrgSetDcfHandle(MMC_DEV_SD, g_dcf_hdl); SF_RtosStrgSetDcfHandle(MMC_DEV_EMMC, g_dcf_hdl2); #if SF_AGEING_EMMC_TEST == ENABLE return g_dcf_hdl2; #endif #if SF_AGEING_SD_TEST == ENABLE return g_dcf_hdl; #endif #if USE_RTOS_MMC_CHECK SF_RTOS_ST_MMC_DEV *mmc_dev = SF_RtosStrgCheckWorkableDev(); if(mmc_dev ==NULL) { DBG_ERR("No MMC_Dev Can use!\n"); return -1; } if(mmc_dev->dcf_handle < 0) { DBG_ERR("dcf_handle err\n"); return -1; } DBG_WRN("photofast DCF_GET_HANDLE, %d\n", mmc_dev->dcf_handle); return mmc_dev->dcf_handle; #else return g_dcf_hdl2; #endif } INT32 PhotoFast_Wait_FileSys(UINT32 timeout_ms) { DCF_HANDLE handle = PhotoFast_Get_DCF_Handle(); BOOT_INIT boot_init = BOOT_INIT_INVALID; if(handle == g_dcf_hdl){ boot_init = BOOT_INIT_FILESYSOK; } #if (FS_MULTI_STRG_FUNC) else if(handle == g_dcf_hdl2){ boot_init = BOOT_INIT_FILESYSOK_2; } #endif if(boot_init != BOOT_INIT_INVALID) return fastboot_wait_done_timeout(boot_init, timeout_ms); else{ DBG_ERR("boot_init = BOOT_INIT_INVALID\n"); return E_SYS; } } INT32 PhotoFast_Wait_FileNaming(UINT32 timeout_ms) { DCF_HANDLE handle = PhotoFast_Get_DCF_Handle(); BOOT_INIT boot_init = BOOT_INIT_INVALID; if(handle == g_dcf_hdl){ boot_init = BOOT_INIT_FILENAMINGOK; } #if (FS_MULTI_STRG_FUNC) else if(handle == g_dcf_hdl2){ boot_init = BOOT_INIT_FILENAMINGOK_2; } #endif if(boot_init != BOOT_INIT_INVALID) return fastboot_wait_done_timeout(boot_init, timeout_ms); else{ DBG_ERR("boot_init = BOOT_INIT_INVALID\n"); return E_SYS; } } INT32 PhotoFast_WriteFile(UINT32 Addr, UINT32 Size, UINT32 Fmt, UINT32 uiPathId, char* Path) { FST_FILE fp; INT32 rt; UINT32 Length; CHAR FilePath[NMC_TOTALFILEPATH_MAX_LEN]; UINT32 fileType; UINT32 open_flag; UINT32 nextFolderID = 0, nextFileID = 0; DCF_HANDLE handle = PhotoFast_Get_DCF_Handle(); /* handle determines which storage would be written */ if(Path == NULL){ if (DCF_GetDBInfoEx(handle, DCF_INFO_IS_9999)) { DBG_ERR("Exceed max dcf file!\r\n"); return FST_STA_NOFREE_SPACE; } else { if (Fmt == HD_CODEC_TYPE_RAW){ fileType = DCF_FILE_TYPE_RAW; } else{ fileType = DCF_FILE_TYPE_JPG; } DCF_GetNextIDEx(handle, &nextFolderID,&nextFileID); if(DrvGPIO_GetPhotoMovieModeFromMonitor() == DX_HUNTING_MODE_MOVIE2) { nextFolderID = Movie2_nextFolderID; nextFileID = Movie2_nextFileID; if (nextFileID > MAX_DCF_FILE_NUM) { nextFileID = 1; nextFolderID++; if (nextFolderID > MAX_DCF_DIR_NUM) { DBG_ERR("Exceed max dcf file!\r\n"); FilePath[0] = '\0'; } } Movie2_nextFileID++; if (Movie2_nextFileID > MAX_DCF_FILE_NUM) { Movie2_nextFileID = 1; Movie2_nextFolderID++; if (Movie2_nextFolderID > MAX_DCF_DIR_NUM) { DBG_ERR("Exceed max dcf file!\r\n"); FilePath[0] = '\0'; } } } DCF_MakeObjPathEx(handle, nextFolderID, nextFileID, fileType, FilePath); DCF_AddDBfileEx(handle, FilePath); DBG_DUMP("%s added to DCF\r\n", FilePath); } } else{ strncpy(FilePath, Path, sizeof(FilePath)); } #if HUNTING_CAMERA_MCU == ENABLE char tmp[NMC_TOTALFILEPATH_MAX_LEN] = {'\0'}; char str1[5] = { 0 }; char str2[5] = { 0 }; memcpy(str1, FilePath + 8, 3); memcpy(str2, FilePath + 21, 4); sprintf(tmp, "W%s%s.JPG", str1, str2); //sprintf(tmp, "W%03ld%04ld.JPG", nextFolderID, nextFileID); strncpy(g_photo_fast_write_file_Path, tmp, sizeof(g_photo_fast_write_file_Path) - 1); DBG_IND("last send file:%s\r\n", tmp); if(TRUE == sf_is_card_full() && TRUE == sf_is_emmc_full()) { DBG_ERR("ERR Addr=0x%x,Size=0x%x,Fmt=%d card full\r\n", Addr, Size, Fmt); rt =FST_STA_ERROR; return rt; } #else strncpy(g_photo_fast_write_file_Path, FilePath, sizeof(g_photo_fast_write_file_Path) - 1); #endif DBG_IND("Photo_WriteCB logical_id=%d, File=%s, Addr=0x%x, Size=0x%x, Fmt=%d\r\n",logical_id,FilePath, Addr, Size, Fmt); open_flag = FST_CREATE_ALWAYS | FST_OPEN_WRITE; if ((fp = FileSys_OpenFile(FilePath, open_flag)) != NULL) { Length = Size; rt = FileSys_WriteFile(fp, (UINT8 *)Addr, &Length, 0, NULL); FileSys_FlushFile(fp); FileSys_CloseFile(fp); if (rt == FST_STA_OK) { // DCF_AddDBfile(FilePath); // DBG_DUMP("%s added to DCF\r\n", FilePath); } else { DBG_ERR("Addr=0x%x,Size=0x%x,Fmt=%d\r\n", Addr, Size, Fmt); } }else{ DBG_ERR("FileSys_OpenFile fail\r\n"); rt =FST_STA_ERROR; } return rt; } static ER PhotoFast_Encode(HD_VIDEO_FRAME *p_video_frame, PHOTOFAST_ENC_INFO *pEncInfo) { //HD_VIDEOENC_OUT2 video_enc_out_param = {0}; HD_VIDEOENC_OUT video_enc_out_param = {0}; //VENDOR_VIDEOENC_JPG_BRC_CFG jpg_brc_cfg = {0}; HD_RESULT hd_ret; if ((!p_video_frame) || (!pEncInfo)) { DBG_ERR("p_video_frame or pEncParam is NULL\r\n"); return E_SYS; } #if 0 //VENDOR_VIDEOENC_JPG_BRC_CFG if (pEncInfo->EncJpgType == PHOTO_ENC_JPG_PRIMARY) { jpg_brc_cfg.upper_bound = pEncInfo->rho_hboundsize; jpg_brc_cfg.lower_bound = pEncInfo->rho_lboundsize; jpg_brc_cfg.brc_retry_cnt = pEncInfo->rho_retrycnt; jpg_brc_cfg.quality_step = pEncInfo->rho_retrycnt; jpg_brc_cfg.init_quality = pEncInfo->rho_initqf; hd_ret = set_enc_vendor((void *)&jpg_brc_cfg, VENDOR_VIDEOENC_PARAM_OUT_JPG_BRC, pEncInfo); if (hd_ret != HD_OK) { DBG_ERR("vendor_videoenc_set(VENDOR_VIDEOENC_PARAM_OUT_JPG_BRC) failed(%d)\r\n", hd_ret); return E_SYS; } } #endif //HD_VIDEOENC_PARAM_IN hd_ret = set_enc_param((void *)p_video_frame, HD_VIDEOENC_PARAM_IN, pEncInfo); if (hd_ret != HD_OK) { DBG_ERR("set_enc_param_in = %d\r\n", hd_ret); return E_SYS; } //HD_VIDEOENC_PARAM_OUT_ENC_PARAM #if 0 video_enc_out_param.codec_type = HD_CODEC_TYPE_JPEG; video_enc_out_param.jpeg.image_quality = 0; video_enc_out_param.jpeg.bitrate = pEncInfo->rho_targetbitrate; video_enc_out_param.jpeg.frame_rate_base = 0; video_enc_out_param.jpeg.frame_rate_incr = 1; hd_ret = set_enc_param((void *)&video_enc_out_param, HD_VIDEOENC_PARAM_OUT_ENC_PARAM, pEncInfo); if (hd_ret != HD_OK) { DBG_ERR("set_enc_param_out = %d\r\n", hd_ret); return E_SYS; } #else video_enc_out_param.codec_type = HD_CODEC_TYPE_JPEG; video_enc_out_param.jpeg.retstart_interval = 0; video_enc_out_param.jpeg.image_quality = 60; hd_ret = set_enc_param((void *)&video_enc_out_param, HD_VIDEOENC_PARAM_OUT_ENC_PARAM, pEncInfo); if (hd_ret != HD_OK) { DBG_ERR("set_enc_param_out = %d\r\n", hd_ret); return E_SYS; } #endif //Only take virtual address if ((hd_ret = hd_videoenc_start(g_video_enc_path[pEncInfo->EncJpgType])) != HD_OK) { DBG_ERR("hd_videoenc_start fail(%d)\n", hd_ret); return E_SYS; } g_bVideoEncPathStart[pEncInfo->EncJpgType] = TRUE; if ((hd_ret = hd_videoenc_get(g_video_enc_path[pEncInfo->EncJpgType], HD_VIDEOENC_PARAM_BUFINFO, &g_enc_buf_info[pEncInfo->EncJpgType])) != HD_OK) { DBG_ERR("hd_videoenc_get fail(%d)\n", hd_ret); return E_SYS; } // mmap for bs buffer (just mmap one time only, calculate offset to virtual address later) g_enc_vir_addr[pEncInfo->EncJpgType] = (UINT32)hd_common_mem_mmap(HD_COMMON_MEM_MEM_TYPE_CACHE, g_enc_buf_info[pEncInfo->EncJpgType].buf_info.phy_addr, g_enc_buf_info[pEncInfo->EncJpgType].buf_info.buf_size); if (g_enc_vir_addr[pEncInfo->EncJpgType] == 0) { DBG_ERR("mmap error, EncJpgType = %d!!\r\n\r\n", pEncInfo->EncJpgType); return E_SYS; } hd_ret = hd_videoenc_push_in_buf(g_video_enc_path[pEncInfo->EncJpgType], p_video_frame, NULL, PHOTOFAST_HD_PUSH_PULL_TIMEOUT_MS); // -1 = blocking mode if (hd_ret != HD_OK) { DBG_ERR("enc_push error=%d, EncJpgType = %d !!\r\n\r\n", hd_ret, pEncInfo->EncJpgType); return E_SYS; } hd_ret = hd_videoenc_pull_out_buf(g_video_enc_path[pEncInfo->EncJpgType], &g_bs_data_pull[pEncInfo->EncJpgType], PHOTOFAST_HD_PUSH_PULL_TIMEOUT_MS); // -1 = blocking mode if (hd_ret != HD_OK) { DBG_ERR("enc_pull error=%d, EncJpgType = %d !!\r\n\r\n", hd_ret, pEncInfo->EncJpgType); return E_SYS; } if ((hd_ret = hd_videoenc_stop(g_video_enc_path[pEncInfo->EncJpgType])) != HD_OK) { DBG_ERR("hd_videoenc_stop fail(%d)\n", hd_ret); return E_SYS; } g_bVideoEncPathStart[pEncInfo->EncJpgType] = FALSE; return E_OK; } #if POWERON_FAST_SLICE_ENC == ENABLE /* avoid compile warning */ static void _PhotoFast_Unused(void) { (void) PhotoFast_Encode; (void) set_enc_vendor; (void) set_enc_cfg; (void) uninit_enc_module; (void) init_enc_module; (void) g_enc_jpg_va; (void) g_enc_yuv_buf; (void) g_enc_jpg_size; } static ER PhotoFast_CaptureInit(void) { PhotoFast_InstallID(); if ((g_photofast_tsk_id = vos_task_create(PhotoFast_CmdTsk, 0, "PhotoFastTsk", PRI_PHOTOFAST_CMDTSK, STKSIZE_PHOTOFAST_CMDTSK)) == 0) { DBG_ERR("PhotoFastTsk create failed.\r\n"); } else { vos_task_resume(g_photofast_tsk_id); } #if HUNTING_CAMERA_MCU != ENABLE// The time is controlled by the MCU. sf_get_mcu_rtc_set_sys printf("[%s:%d] s \n",__FUNCTION__,__LINE__); struct tm Curr_DateTime = {0}; //temp test Curr_DateTime.tm_year = 2021; Curr_DateTime.tm_mon = 12; Curr_DateTime.tm_mday = 25; Curr_DateTime.tm_hour = 12; Curr_DateTime.tm_min = 12; Curr_DateTime.tm_sec = 12; hwclock_set_time(TIME_ID_CURRENT, *(struct tm*)&Curr_DateTime, 0); #endif _PhotoFast_Unused(); return E_OK; } #else static ER PhotoFast_CaptureInit(void) { UINT32 u32W, u32H; HD_RESULT hd_ret; PHOTOFAST_ENC_INFO EncInfo = {0}; VENDOR_VIDEOENC_BS_RESERVED_SIZE_CFG bs_reserved_size = {0}; //init videoenc module hd_ret = init_enc_module(); if (hd_ret != HD_OK){ DBG_ERR("init_enc_module failed (%d)\r\n", hd_ret); return E_SYS; } //init enc cfg hd_ret = set_enc_cfg(); if (hd_ret != HD_OK){ DBG_ERR("set_enc_cfg failed (%d)\r\n", hd_ret); return E_SYS; } //init enc vendor EncInfo.EncJpgType = PHOTO_ENC_JPG_PRIMARY; bs_reserved_size.reserved_size = CFG_JPG_HEADER_SIZE*2; //EXIF size hd_ret = set_enc_vendor((void *)&bs_reserved_size, VENDOR_VIDEOENC_PARAM_OUT_BS_RESERVED_SIZE, &EncInfo); if (hd_ret != HD_OK){ DBG_ERR("set_enc_vendor failed (%d)\r\n", hd_ret); return E_SYS; } PhotoFast_InstallID(); if ((g_photofast_tsk_id = vos_task_create(PhotoFast_CmdTsk, 0, "PhotoFastTsk", PRI_PHOTOFAST_CMDTSK, STKSIZE_PHOTOFAST_CMDTSK)) == 0) { DBG_ERR("PhotoFastTsk create failed.\r\n"); } else { vos_task_resume(g_photofast_tsk_id); } #if HUNTING_CAMERA_MCU != ENABLE// The time is controlled by the MCU. sf_get_mcu_rtc_set_sys struct tm Curr_DateTime = {0}; printf("[%s:%d] s \n",__FUNCTION__,__LINE__); //temp test Curr_DateTime.tm_year = 2021; Curr_DateTime.tm_mon = 12; Curr_DateTime.tm_mday = 25; Curr_DateTime.tm_hour = 12; Curr_DateTime.tm_min = 12; Curr_DateTime.tm_sec = 12; hwclock_set_time(TIME_ID_CURRENT, *(struct tm*)&Curr_DateTime, 0); #endif // allocate primary captured resolution u32W = GetPhotoSizeWidth(SysGetFlag(FL_PHOTO_SIZE)); u32H = GetPhotoSizeHeight(SysGetFlag(FL_PHOTO_SIZE)); g_enc_yuv_buf[PHOTO_ENC_JPG_PRIMARY].blk_size = u32W*u32H*3/2; PhotoFast_get_hd_common_buf(&g_enc_yuv_buf[PHOTO_ENC_JPG_PRIMARY]); // allocate screennail captured resolution #if HUNTING_CAMERA_MCU == ENABLE g_enc_yuv_buf[PHOTO_ENC_JPG_SCREENNAIL].blk_size = (sf_get_screen_nail_width(puiPara->SendPicSize))*(sf_get_screen_nail_height(puiPara->SendPicSize))*3/2; #else g_enc_yuv_buf[PHOTO_ENC_JPG_SCREENNAIL].blk_size = CFG_SCREENNAIL_W*CFG_SCREENNAIL_H*3/2; #endif PhotoFast_get_hd_common_buf(&g_enc_yuv_buf[PHOTO_ENC_JPG_SCREENNAIL]); // allocate thumbnail captured resolution g_enc_yuv_buf[PHOTO_ENC_JPG_THUMBNAIL].blk_size = CFG_THUMBNAIL_W*CFG_THUMBNAIL_H*3/2; PhotoFast_get_hd_common_buf(&g_enc_yuv_buf[PHOTO_ENC_JPG_THUMBNAIL]); // allocate exif data buffer g_exif_data_buf.blk_size = CFG_JPG_HEADER_SIZE; PhotoFast_get_hd_common_buf(&g_exif_data_buf); return E_OK; } #endif static BOOL bCaptureStartFirstEntry = TRUE; #if POWERON_FAST_SLICE_ENC == ENABLE static void PhotoFast_CaptureStop(void) { PhotoFast_Sliceencode2_Stop(); } static INT32 PhotoFast_CaptureStart(HD_VIDEO_FRAME *p_video_frame) { HD_PATH_ID vprc_path; flow_preview_get_path(&vprc_path, FLOW_PREIVEW_VPRC_PATH, 0); if (bCaptureStartFirstEntry) { bCaptureStartFirstEntry = FALSE; fwload_wait_done(CODE_SECTION_05); PhotoFast_CaptureInit(); PhotoFast_InitExif(); #if defined(_UI_STYLE_LVGL_) flow_lv_init(); #endif PhotoFastCapDateImprint_InitBuff(); #if !defined(_UI_STYLE_LVGL_) PhotoFast_InitGxGfx(); #endif hd_gfx_init(); PhotoFast_SliceEncode_Open(vprc_path); } #if POWERON_FAST_SLICE_ENC_VER2 == ENABLE return PhotoFast_Sliceencode2_Enq_Frame(p_video_frame); #else return PhotoFast_SliceEncode(vprc_path, p_video_frame); #endif } #else static void PhotoFast_CaptureStart(HD_VIDEO_FRAME *p_video_frame) { HD_VIDEO_FRAME video_frame_screennail = {0}; VF_GFX_SCALE gfx_scale = {0}; URECT dest_win = {0}; USIZE src_size = {0}, dest_size = {0}; HD_COMMON_MEM_VB_BLK blk = 0; UINT32 u32W = 0, u32H = 0; PHOTOFAST_HD_COM_BUF *pComBufInfo = NULL; ER ret = E_SYS; HD_RESULT hd_ret; PHOTOFAST_ENC_INFO EncInfo = {0}; UINT32 i; MEM_RANGE exif_data={0}, thumb_jpg={0}, pri_jpg={0}, scr_jpg={0}, dst_jpg_file={0}; UINT32 TargetBytes = PhotoFast_GetExpectSize_RhoBRCrtl(SysGetFlag(FL_PHOTO_SIZE), TRUE); UINT32 TargetUBoundBytes = PRIMARY_TARGETBYTERATE_UBOUND(TargetBytes); UINT32 TargetLBoundBytes = PRIMARY_TARGETBYTERATE_LBOUND(TargetBytes); if (bCaptureStartFirstEntry) { bCaptureStartFirstEntry = FALSE; fwload_wait_done(CODE_SECTION_05); PhotoFast_CaptureInit(); PhotoFast_InitExif(); #if defined(_UI_STYLE_LVGL_) flow_lv_init(); #endif PhotoFastCapDateImprint_InitBuff(); #if !defined(_UI_STYLE_LVGL_) PhotoFast_InitGxGfx(); #endif hd_gfx_init(); } /* --- The flow of encoded primary image. ---*/ //scale sensor original size to captured (primary) resolution u32W = GetPhotoSizeWidth(SysGetFlag(FL_PHOTO_SIZE)); u32H = GetPhotoSizeHeight(SysGetFlag(FL_PHOTO_SIZE)); src_size.w = p_video_frame->dim.w; src_size.h = p_video_frame->dim.h; dest_size.w = u32W; dest_size.h = u32H; PhotoFast_Cal_Jpg_Size(&src_size, &dest_size , &dest_win); pComBufInfo = &g_enc_yuv_buf[PHOTO_ENC_JPG_PRIMARY]; if ((blk = PhotoFast_Scale_YUV(&gfx_scale, p_video_frame, pComBufInfo, &dest_size, &dest_win, HD_VIDEO_PXLFMT_YUV420)) != E_OK) { DBG_ERR("Scale_YUV fail\r\n"); return; } //custom stamp ret = PhotoFastCapDateImprint_GenYuvData(&gfx_scale.dst_img); //encode primary image EncInfo.rho_targetbitrate = TargetBytes; EncInfo.rho_hboundsize = TargetUBoundBytes; EncInfo.rho_hboundsize = TargetLBoundBytes; EncInfo.rho_retrycnt = JPG_BRC_RETRY_CNT; EncInfo.rho_initqf_step = JPG_BRC_RETRY_CNT; EncInfo.rho_initqf = JPG_BRC_INIT_Q; EncInfo.EncJpgType = PHOTO_ENC_JPG_PRIMARY; ret = PhotoFast_Encode(&gfx_scale.dst_img, &EncInfo); if (ret != E_OK) { DBG_ERR("Captured the primary image failed\r\n"); return; } //Take the primary bitstream g_enc_jpg_va[PHOTO_ENC_JPG_PRIMARY] = PHY2VIRT_MAIN(g_bs_data_pull[PHOTO_ENC_JPG_PRIMARY].video_pack[0].phy_addr, g_enc_buf_info[PHOTO_ENC_JPG_PRIMARY].buf_info.phy_addr, g_enc_vir_addr[PHOTO_ENC_JPG_PRIMARY]); g_enc_jpg_size[PHOTO_ENC_JPG_PRIMARY] = g_bs_data_pull[PHOTO_ENC_JPG_PRIMARY].video_pack[0].size; /* --- The flow of encoded screenail image. ---*/ memset(&gfx_scale, 0, sizeof(VF_GFX_SCALE)); //scale to screennail resolution #if HUNTING_CAMERA_MCU == ENABLE u32W = (sf_get_screen_nail_width(puiPara->SendPicSize)); u32H = (sf_get_screen_nail_height(puiPara->SendPicSize)); #else u32W = CFG_SCREENNAIL_W; u32H = CFG_SCREENNAIL_H; #endif src_size.w = p_video_frame->dim.w; src_size.h = p_video_frame->dim.h; dest_size.w = u32W; dest_size.h = u32H; PhotoFast_Cal_Jpg_Size(&src_size, &dest_size , &dest_win); pComBufInfo = &g_enc_yuv_buf[PHOTO_ENC_JPG_SCREENNAIL]; if ((blk = PhotoFast_Scale_YUV(&gfx_scale, p_video_frame, pComBufInfo, &dest_size, &dest_win, HD_VIDEO_PXLFMT_YUV420)) != E_OK) { DBG_ERR("Scale_YUV fail\r\n"); return; } //custom stamp ret = PhotoFastCapDateImprint_GenYuvData(&gfx_scale.dst_img); //encode screennail image EncInfo.EncJpgType = PHOTO_ENC_JPG_SCREENNAIL; ret = PhotoFast_Encode(&gfx_scale.dst_img, &EncInfo); if (ret != E_OK) { DBG_ERR("Captured the screennail image failed\r\n"); return; } //Take the screennail bitstream g_enc_jpg_va[PHOTO_ENC_JPG_SCREENNAIL] = PHY2VIRT_MAIN(g_bs_data_pull[PHOTO_ENC_JPG_SCREENNAIL].video_pack[0].phy_addr, g_enc_buf_info[PHOTO_ENC_JPG_SCREENNAIL].buf_info.phy_addr, g_enc_vir_addr[PHOTO_ENC_JPG_SCREENNAIL]); g_enc_jpg_size[PHOTO_ENC_JPG_SCREENNAIL] = g_bs_data_pull[PHOTO_ENC_JPG_SCREENNAIL].video_pack[0].size; /* --- The flow of encoded thumbnail image. ---*/ //copy screenail info memcpy(&video_frame_screennail, &gfx_scale.dst_img, sizeof(HD_VIDEO_FRAME)); memset(&gfx_scale, 0, sizeof(VF_GFX_SCALE)); //scale screennai to thumbnaill resolution u32W = CFG_THUMBNAIL_W; u32H = CFG_THUMBNAIL_H; src_size.w = video_frame_screennail.dim.w; src_size.h = video_frame_screennail.dim.h; dest_size.w = u32W; dest_size.h = u32H; PhotoFast_Cal_Jpg_Size(&src_size, &dest_size , &dest_win); pComBufInfo = &g_enc_yuv_buf[PHOTO_ENC_JPG_THUMBNAIL]; if ((blk = PhotoFast_Scale_YUV(&gfx_scale, &video_frame_screennail, pComBufInfo, &dest_size, &dest_win, HD_VIDEO_PXLFMT_YUV420)) != E_OK) { DBG_ERR("Scale_YUV fail\r\n"); return; } //encode thumbnail image EncInfo.EncJpgType = PHOTO_ENC_JPG_THUMBNAIL; ret = PhotoFast_Encode(&gfx_scale.dst_img, &EncInfo); if (ret != E_OK) { DBG_ERR("Captured the screennail image failed\r\n"); return; } //Take the thumbnail bitstream g_enc_jpg_va[PHOTO_ENC_JPG_THUMBNAIL] = PHY2VIRT_MAIN(g_bs_data_pull[PHOTO_ENC_JPG_THUMBNAIL].video_pack[0].phy_addr, g_enc_buf_info[PHOTO_ENC_JPG_THUMBNAIL].buf_info.phy_addr, g_enc_vir_addr[PHOTO_ENC_JPG_THUMBNAIL]); g_enc_jpg_size[PHOTO_ENC_JPG_THUMBNAIL] = g_bs_data_pull[PHOTO_ENC_JPG_THUMBNAIL].video_pack[0].size; //EXIF data. ExifVendor_Write0thIFD(EXIF_HDL_ID_1); ExifVendor_WriteExifIFD(EXIF_HDL_ID_1); ExifVendor_Write0thIntIFD(EXIF_HDL_ID_1); exif_data.addr = g_exif_data_buf.va; exif_data.size = g_exif_data_buf.blk_size; thumb_jpg.addr = g_enc_jpg_va[PHOTO_ENC_JPG_THUMBNAIL]; thumb_jpg.size = g_enc_jpg_size[PHOTO_ENC_JPG_THUMBNAIL]; if (EXIF_CreateExif(EXIF_HDL_ID_1, &exif_data, &thumb_jpg) != EXIF_ER_OK) { DBG_ERR("Create Exif fail\r\n"); exif_data.size = 0; } //Combination pri_jpg.addr = g_enc_jpg_va[PHOTO_ENC_JPG_PRIMARY]; pri_jpg.size = g_enc_jpg_size[PHOTO_ENC_JPG_PRIMARY]; scr_jpg.addr = g_enc_jpg_va[PHOTO_ENC_JPG_SCREENNAIL]; scr_jpg.size = g_enc_jpg_size[PHOTO_ENC_JPG_SCREENNAIL]; GxImgFile_CombineJPG(&exif_data, &pri_jpg, &scr_jpg, &dst_jpg_file); fastboot_wait_done(BOOT_INIT_FILENAMINGOK); PhotoFast_WriteFile(dst_jpg_file.addr, dst_jpg_file.size, NAMERULE_FMT_JPG, 0, 0); for (i=0; i < PHOTO_ENC_JPG_TYPE_MAX_ID; i++) { hd_ret = hd_videoenc_release_out_buf(g_video_enc_path[i], &g_bs_data_pull[i]); if (hd_ret != HD_OK) { DBG_ERR("release data_pull_pri error=%d, EncJpgType=%d !!\r\n", hd_ret, i); } if (g_enc_vir_addr[i]) { hd_common_mem_munmap((void *)g_enc_vir_addr[i], g_enc_buf_info[i].buf_info.buf_size); g_enc_vir_addr[i] = 0; } } } #endif THREAD_RETTYPE PhotoFast_InitFileNamingThread(void *arg) { fastboot_wait_done(BOOT_INIT_FILESYSOK); PhotoFast_FileNaming_Open(); fastboot_set_done(BOOT_INIT_FILENAMINGOK); THREAD_RETURN(0); } THREAD_RETTYPE PhotoFast_InitFileNamingThread2(void *arg) { fastboot_wait_done(BOOT_INIT_FILESYSOK_2); PhotoFast_FileNaming_Open2(); fastboot_set_done(BOOT_INIT_FILENAMINGOK_2); THREAD_RETURN(0); } #include "kwrap/util.h" //extern void DrvGPIO_IRLed_Turn_Onoff(BOOL onoff); extern void DrvGOIO_Turn_Onoff_IRCUT(UINT8 onoff); extern void isp_dbg_set_dbg_mode(ISP_ID id, UINT32 cmd); extern void setet_preset_param(void); extern INT32 PhotoFast_SliceEncode_Dump_Frame(const HD_VIDEO_FRAME video_frame, UINT8 format); HD_RESULT PhotoFast_VideoCap_Pull_Out_Buf(HD_PATH_ID path_id, HD_VIDEO_FRAME *p_video_frame, INT32 wait_ms) { HD_RESULT ret; UINT32 cnt = 0; UINT32 delay_ms = 1; UINT32 timeout = 30; do { ret = hd_videocap_pull_out_buf(path_id, p_video_frame, PHOTOFAST_HD_PUSH_PULL_TIMEOUT_MS); if(ret != HD_OK && ret != HD_ERR_UNDERRUN){ DBG_ERR("failed to hd_videocap_pull_out_buf, er=%d\n", (int)ret); return ret; } else if(ret == HD_ERR_UNDERRUN){ DBG_ERR("failed to hd_videocap_pull_out_buf, er=%d, retrying(cnt = %lu) ... \n", (int)ret, cnt); vos_util_delay_ms(delay_ms); continue; } else{ break; } } while(cnt++ < timeout); return ret; } THREAD_RETTYPE PhotoFast_FlowPreviewThread(void *arg) { HD_RESULT hd_ret = HD_OK; HD_VIDEO_FRAME video_cap_frame = {0}; HD_VIDEO_FRAME video_frame = {0}; HD_PATH_ID vprc_path = 0, vout_path = 0, vcap_path = 0; UINT32 max_cnt = 0; BOOL start_cap = FALSE; BOOL stop_flag = FALSE; BOOL led_flag = FALSE; #if HUNTING_CAMERA_MCU == ENABLE UIMenuStoreInfo *puiPara = sf_ui_para_get(); // IQT_SHARPNESS_LV sharpness_lv = {0}; // IQT_NR_LV nr_lv = {0}; #endif flow_preview_get_path(&vcap_path, FLOW_PREIVEW_VCAP_PATH, 0); flow_preview_get_path(&vprc_path, FLOW_PREIVEW_VPRC_PATH, 0); flow_preview_get_path(&vout_path, FLOW_PREIVEW_VOUT_PATH, 0); // init variables g_bPreViewPullFlag = TRUE; bCaptureStartFirstEntry = TRUE; switch (UI_GetData(FL_CONTINUE_SHOT))//puiPara->Multishot { case CONTINUE_SHOT_BURST_5: max_cnt = 5; break; case CONTINUE_SHOT_BURST_4: max_cnt = 4; break; case CONTINUE_SHOT_BURST_3: max_cnt = 3; break; case CONTINUE_SHOT_BURST_2: max_cnt = 2; break; case CONTINUE_SHOT_OFF: default: max_cnt = 1; break; } #if POWERON_FAST_SLICE_ENC_VER2 == ENABLE UINT32 period = 0; #if HUNTING_CAMERA_MCU == ENABLE if(SF_MULTISHOT_INTEVEL_1S == puiPara->MultiShotIntevel) { period = 970;//The interval between consecutive shots of each photo is 1 second } else if(SF_MULTISHOT_INTEVEL_2S == puiPara->MultiShotIntevel) { period = 1970;//The interval between consecutive shots of each photo is 2 second } else { period = 1000 / max_cnt;//SF_MULTISHOT_INTEVEL_0S } #else period = 1000 / max_cnt; #endif DBG_DUMP("period = %lu ms, max_cnt = %lu\n", period, max_cnt); PhotoFast_SliceEncode2_Open(vprc_path, max_cnt); nvt_cmdsys_runcmd("ae set_speed 0 128 200 200 100"); #endif #if (FASTCAPTURE_AE_DEBUG == 1) if (g_vcap_frm_cnt == 1){ // Set_NIGHTMODE(0); // nvt_cmdsys_runcmd("vcap info"); // nvt_cmdsys_runcmd("vprc info"); // nvt_cmdsys_runcmd("ctl_ipp dump_hdl_all"); //ISPT_TOTAL_GAIN total; // nvt_cmdsys_runcmd("ae dbg 0 256 1 "); // isp_dbg_set_dbg_mode(0, 0x0202002 ); // nvt_cmdsys_runcmd("iq dbg 0 0 "); // nvt_cmdsys_runcmd("iq dbg 0 8 "); // nr_lv.id = 0; // nr_lv.lv = 200; // vendor_isp_set_iq(IQT_ITEM_NR_LV, &nr_lv); //50~200 // sharpness_lv.id = 0; // sharpness_lv.lv = 70; // vendor_isp_set_iq(IQT_ITEM_SHARPNESS_LV, &sharpness_lv); // total.id = 0; // total.gain = 1600; // vendor_isp_set_common(ISPT_ITEM_TOTAL_GAIN, &total); // nvt_cmdsys_runcmd("iq set_dbg 16 0x200000 "); } #endif while(g_bPreViewPullFlag) { if(TRUE == flow_preview_get_stop_flag()){ DBG_WRN("detected stop signal, power off ...\n"); stop_flag = TRUE; hd_ret = HD_ERR_ABORT; goto exit; } if((g_vcap_frm_cnt > 2) && (g_ae_preset_flag == FALSE)){ memset(&ae_status, 0, sizeof(AET_STATUS_INFO)); vendor_isp_get_ae(AET_ITEM_STATUS, &ae_status); if ((ae_status.status_info.state_adj == 0) || (g_vcap_frm_cnt >= PHOTOFAST_AE_PRESET_FRAME_CNT)){ g_ae_preset_flag = TRUE; g_vprc_frm_cnt_ae_preset = g_vprc_frm_cnt; DBG_DUMP("ae preset vprc frame cnt = %lu\n", g_vprc_frm_cnt_ae_preset); Set_AEMODE(1); setet_preset_param(); } } //DBG_WRN(">>>>>>> adj %d lum %d explum %d exp %d iso %d\r\n",ae_status.status_info.state_adj,ae_status.status_info.lum,ae_status.status_info.expect_lum,ae_status.status_info.iso_gain[0],ae_status.status_info.expotime[0]); #if POWERON_FAST_SLICE_ENC_VER2 == ENABLE if(start_cap == TRUE){ VOS_TICK t1, t2; UINT32 duration; UINT32 led_delay = 170; led_flag = FALSE; vos_perf_mark(&t1); /************************************************** * Keep pushing frame to vprc **************************************************/ do{ vos_perf_mark(&t2); duration = vos_perf_duration(t1, t2) / 1000; /************************************************** * IR LED , 60 fps, 16.66 = 17 **************************************************/ #if HUNTING_CAMERA_MCU == ENABLE if((duration >= period) ||((period - duration) <= (led_delay + 17)) ){ if((SF_MULTISHOT_INTEVEL_0S != puiPara->MultiShotIntevel) && (FALSE == led_flag) && (sf_is_night_mode(0) ==TRUE)){ led_flag = TRUE; sf_ir_led_set(((2 == puiPara->NightMode) ? 2 : 1),puiPara->FlashLed, puiPara->NightMode,0); } } #endif if((hd_ret = PhotoFast_VideoCap_Pull_Out_Buf(vcap_path, &video_cap_frame, PHOTOFAST_HD_PUSH_PULL_TIMEOUT_MS)) != HD_OK){ DBG_ERR("failed to hd_videocap_pull_out_buf, er=%d\n", (int)hd_ret); goto exit; } g_vcap_frm_cnt = video_cap_frame.count; if((hd_ret = hd_videoproc_push_in_buf(vprc_path, &video_cap_frame, NULL, PHOTOFAST_HD_PUSH_PULL_TIMEOUT_MS)) != HD_OK){ hd_videocap_release_out_buf(vcap_path, &video_cap_frame); DBG_ERR("failed to hd_videoproc_push_in_buf, er=%d\n", (int)hd_ret); goto exit; } if((hd_ret = hd_videocap_release_out_buf(vcap_path, &video_cap_frame)) != HD_OK){ DBG_ERR("failed to hd_videocap_release_out_buf, er=%d\n", (int)hd_ret); goto exit; } if ((hd_ret = hd_videoproc_pull_out_buf(vprc_path, &video_frame, PHOTOFAST_HD_PUSH_PULL_TIMEOUT_MS)) != HD_OK) { DBG_ERR("failed to hd_videoproc_pull_out_buf, er=%d\n", (int)hd_ret); goto exit; } DBG_DUMP("vcap:%lu vprc:%lu vprc_ae_preset:%lu\n", g_vcap_frm_cnt, g_vprc_frm_cnt, g_vprc_frm_cnt_ae_preset); ++g_vprc_frm_cnt; if(duration >= (period - 17)){ break; } else{ if ((hd_ret = hd_videoproc_release_out_buf(vprc_path, &video_frame))!= HD_OK) { DBG_ERR("failed to hd_videoproc_release_out_buf, er=%d\n", (int)hd_ret); goto exit; } continue; } } while(1); } else{ if((hd_ret = PhotoFast_VideoCap_Pull_Out_Buf(vcap_path, &video_cap_frame, PHOTOFAST_HD_PUSH_PULL_TIMEOUT_MS)) != HD_OK){ DBG_ERR("failed to hd_videocap_pull_out_buf, er=%d\n", (int)hd_ret); goto exit; } g_vcap_frm_cnt = video_cap_frame.count; if((hd_ret = hd_videoproc_push_in_buf(vprc_path, &video_cap_frame, NULL, PHOTOFAST_HD_PUSH_PULL_TIMEOUT_MS)) != HD_OK){ hd_videocap_release_out_buf(vcap_path, &video_cap_frame); DBG_ERR("failed to hd_videoproc_push_in_buf, er=%d\n", (int)hd_ret); goto exit; } if((hd_ret = hd_videocap_release_out_buf(vcap_path, &video_cap_frame)) != HD_OK){ DBG_ERR("failed to hd_videocap_release_out_buf, er=%d\n", (int)hd_ret); goto exit; } if ((hd_ret = hd_videoproc_pull_out_buf(vprc_path, &video_frame, PHOTOFAST_HD_PUSH_PULL_TIMEOUT_MS)) != HD_OK) { DBG_ERR("failed to hd_videoproc_pull_out_buf, er=%d\n", (int)hd_ret); goto exit; } DBG_DUMP("vcap:%lu vprc:%lu vprc_ae_preset:%lu\n", g_vcap_frm_cnt, g_vprc_frm_cnt, g_vprc_frm_cnt_ae_preset); ++g_vprc_frm_cnt; } #endif //#if HUNTING_PHOTO_FAST_AE_60_FPS == ENABLE // if((hd_ret = hd_videocap_pull_out_buf(vcap_path, &video_cap_frame, PHOTOFAST_HD_PUSH_PULL_TIMEOUT_MS)) != HD_OK){ // DBG_ERR("failed to hd_videocap_pull_out_buf, er=%d\n", (int)hd_ret); // goto exit; // } // // g_vcap_frm_cnt = video_cap_frame.count; // // if((hd_ret = hd_videoproc_push_in_buf(vprc_path, &video_cap_frame, NULL, PHOTOFAST_HD_PUSH_PULL_TIMEOUT_MS)) != HD_OK){ // hd_videocap_release_out_buf(vcap_path, &video_cap_frame); // DBG_ERR("failed to hd_videoproc_push_in_buf, er=%d\n", (int)hd_ret); // goto exit; // } // // if((hd_ret = hd_videocap_release_out_buf(vcap_path, &video_cap_frame)) != HD_OK){ // DBG_ERR("failed to hd_videocap_release_out_buf, er=%d\n", (int)hd_ret); // goto exit; // } //#else // (void) vcap_path; // (void) video_cap_frame; //#endif // if ((hd_ret = hd_videoproc_pull_out_buf(vprc_path, &video_frame, PHOTOFAST_HD_PUSH_PULL_TIMEOUT_MS)) != HD_OK) { // DBG_ERR("failed to hd_videoproc_pull_out_buf, er=%d\n", (int)hd_ret); // goto exit; // } // DBG_DUMP("vcap:%lu vprc:%lu vprc_ae_preset:%lu\n", g_vcap_frm_cnt, g_vprc_frm_cnt, g_vprc_frm_cnt_ae_preset); /***************************************************************************************** * trigger rule: * * 1. PHOTOFAST_START_CAP_FRAME_CNT arrived * * 2. third frame since ae preset ******************************************************************************************/ if(((g_vcap_frm_cnt >= PHOTOFAST_START_CAP_FRAME_CNT) || (g_ae_preset_flag == TRUE && g_vprc_frm_cnt >= (g_vprc_frm_cnt_ae_preset + 3))) && (start_cap == FALSE)){ if(g_vcap_frm_cnt >= PHOTOFAST_START_CAP_FRAME_CNT){ DBG_DUMP("triggered by PHOTOFAST_START_CAP_FRAME_CNT\n"); } else if(g_ae_preset_flag == TRUE && g_vprc_frm_cnt >= (g_vprc_frm_cnt_ae_preset + 3)){ DBG_DUMP("triggered by AE preset\n"); } //#if HUNTING_PHOTO_FAST_AE_60_FPS == ENABLE PhotoFast_SetTriggerFrmCnt(video_cap_frame.count); /* unbind mode , use vcap frame count */ //#else // PhotoFast_SetTriggerFrmCnt(video_frame.count); /* bind mode , vprc frame count = vcap frame count */ //#endif start_cap = TRUE; VOS_TICK tick; PhotoFast_GetTick(video_cap_frame.count, &tick); DBG_DUMP("*** trigger frame count = %llu (start from 1) frame timestamp = %llu, tick=%lu ms , \n", video_cap_frame.count, video_cap_frame.timestamp, tick); /* UINT64, use %llu */ //Set_AEMODE(1); } //#if HUNTING_PHOTO_FAST_AE_60_FPS == DISABLE // g_vprc_frm_cnt = video_frame.count; // g_vcap_frm_cnt = g_vprc_frm_cnt; //#else //#endif switch (DrvGPIO_GetPhotoMovieModeFromMonitor()) { case DX_HUNTING_MODE_PHOTO: case DX_HUNTING_MODE_PHOTO_MOVIE: if (start_cap == TRUE) { #if HUNTING_CAMERA_MCU == ENABLE if((SF_MULTISHOT_INTEVEL_0S != puiPara->MultiShotIntevel) && (sf_is_night_mode(0) ==TRUE)){ //DrvGPIO_IRLed_Turn_Onoff(0); sf_ir_led_set(0, 0, 0, 0); } #endif if(PhotoFast_CaptureStart(&video_frame) == E_OK){ g_u32PrvCapCnt++; } else{ DBG_WRN("enq frame failed...\n"); /* release */ if ((hd_ret = hd_videoproc_release_out_buf(vprc_path, &video_frame))!= HD_OK) { DBG_ERR("failed to hd_videoproc_release_out_buf, er=%d\n", (int)hd_ret); goto exit; } } if (g_u32PrvCapCnt >= max_cnt) { g_bPreViewPullFlag = FALSE; } } break; case DX_HUNTING_MODE_CAMERA_PHOTO: case DX_HUNTING_MODE_CAMERA_PHOTO_MOVIE: if (start_cap == TRUE) { #if HUNTING_CAMERA_MCU == ENABLE if((SF_MULTISHOT_INTEVEL_0S != puiPara->MultiShotIntevel) && (sf_is_night_mode(0) ==TRUE)){ //DrvGPIO_IRLed_Turn_Onoff(0); sf_ir_led_set(0, 0, 0, 0); } #endif PhotoFast_CaptureStart(&video_frame); g_bPreViewPullFlag = FALSE; } break; default: //fastboot_msg_en(ENABLE); DBG_ERR(" DrvGPIO_GetPhotoMovieModeFromMonitor default\n"); break; } #if (_PACKAGE_DISPLAY_) /* display */ if ((hd_ret = hd_videoout_push_in_buf(vout_path, &video_frame, NULL, 0)) != HD_OK) { //printf("videoout drop one frame, er=%d\n", (int)ret); } #endif #if POWERON_FAST_SLICE_ENC_VER2 == ENABLE /* release */ if (start_cap == FALSE) { if ((hd_ret = hd_videoproc_release_out_buf(vprc_path, &video_frame))!= HD_OK) { DBG_ERR("failed to hd_videoproc_release_out_buf, er=%d\n", (int)hd_ret); goto exit; } } #else /* release */ if ((hd_ret = hd_videoproc_release_out_buf(vprc_path, &video_frame))!= HD_OK) { DBG_ERR("failed to hd_videoproc_release_out_buf, er=%d\n", (int)hd_ret); goto exit; } #endif exit: if(hd_ret != HD_OK){ g_bPreViewPullFlag = FALSE; DBG_ERR("error occured, force close PhotoFast\n"); } if (g_bPreViewPullFlag == FALSE) { // DrvGPIO_IRLed_Turn_Onoff(0); #if HUNTING_CAMERA_MCU == ENABLE if((SF_MULTISHOT_INTEVEL_0S == puiPara->MultiShotIntevel) && (sf_is_night_mode(0) ==TRUE)){ sf_ir_led_set(0, 0, 0, 0); } #endif g_vprc_frm_cnt = 1; g_vcap_frm_cnt = 1; PhotoFast_PhotoClose(); vos_perf_list_mark("sie_vd", __LINE__, 3); #if HUNTING_CAMERA_MCU == ENABLE #if SF_TRIGGER_TIME_TEST == ENABLE sf_trigger_time_led_cb(0); #endif if((sf_get_power_off_flag()) || (TRUE == sf_is_card_full() && TRUE == sf_is_emmc_full())) { vos_flag_set(PHOTOFAST_FLG_ID, FLGPHOTOFAST_SHUTDOWN); } //else { // sf_file_thumb_cfg_sava(); //} /*UINT32 uiSelect = UI_GetData(FL_PHOTO_SIZE)+1; if(UI_GetData(FL_PHOTO_SIZE) >= PHOTO_SIZE_8M) { uiSelect = UI_GetData(FL_PHOTO_SIZE)+1; UI_SetData(FL_PHOTO_SIZE,PHOTO_SIZE_24M); if(puiPara->SendPicSize == SCREEN_PHOTO_SIZE_VGA) { puiPara->SendPicSize = SCREEN_PHOTO_SIZE_2_76M; } else { puiPara->SendPicSize = SCREEN_PHOTO_SIZE_VGA; } } else { UI_SetData(FL_PHOTO_SIZE,uiSelect); } Save_MenuInfo(); */ #endif if(stop_flag == TRUE){ /* Check if cmd task flag is already initialized or shutdown directly */ if(PHOTOFAST_FLG_ID){ vos_flag_set(PHOTOFAST_FLG_ID, FLGPHOTOFAST_SHUTDOWN); } else{ PhotoFast_ShutDown(); } } else{ switch (DrvGPIO_GetPhotoMovieModeFromMonitor()) { case DX_HUNTING_MODE_PHOTO: vos_flag_set(PHOTOFAST_FLG_ID, FLGPHOTOFAST_SHUTDOWN); break; case DX_HUNTING_MODE_PHOTO_MOVIE: case DX_HUNTING_MODE_CAMERA_PHOTO_MOVIE: vos_flag_set(PHOTOFAST_FLG_ID, FLGPHOTOFAST_CHGMODE); break; case DX_HUNTING_MODE_CAMERA_PHOTO: vos_flag_set(PHOTOFAST_FLG_ID, FLGPHOTOFAST_SHUTDOWN); break; } } } } // vos_flag_destroy(PHOTOFAST_FLG_ID); THREAD_RETURN(0); } #if POWERON_FAST_SLICE_ENC == ENABLE void PhotoFast_PhotoClose(void) { #if POWERON_FAST_SLICE_ENC_VER2 == ENABLE PhotoFast_CaptureStop(); PhotoFast_SliceEncode2_Close(); #endif PhotoFast_FileNaming_Close(); PhotoFast_SliceEncode_Close(); flow_preview_close_module(); flow_preview_uninit_module(); #if defined(_UI_STYLE_LVGL_) #else GxGfx_Exit(); #endif PhotoFast_UninitExif(); PhotoFastCapDateImprint_UninitBuff(); } #else void PhotoFast_PhotoClose(void) { UINT32 i; PhotoFast_FileNaming_Close(); uninit_enc_module(); flow_preview_close_module(); flow_preview_uninit_module(); for (i=0; i < PHOTO_ENC_JPG_TYPE_MAX_ID; i++) { if (g_enc_yuv_buf[i].blk != 0) { hd_common_mem_release_block(g_enc_yuv_buf[i].blk); memset(&g_enc_yuv_buf[i], 0, sizeof(PHOTOFAST_HD_COM_BUF)); } } #if defined(_UI_STYLE_LVGL_) #else GxGfx_Exit(); #endif PhotoFast_UninitExif(); PhotoFastCapDateImprint_UninitBuff(); } #endif static void PhotoFast_ShutDown(void) { PhotoFast_CmdTsk_Exit(); #if (POWERON_FAST_BOOT_MSG == DISABLE) #if SF_TRIGGER_TIME_TEST == ENABLE fastboot_msg_en(ENABLE); #endif #endif #if HUNTING_CAMERA_BOOT_LINUX /* Boot Linux */ #if POWERON_BOOT_REPORT == ENABLE vos_perf_list_dump(); PhotoFast_TriggerFrm_Dump(); #endif #if HUNTING_CAMERA_MCU == ENABLE #if SF_TRIGGER_TIME_TEST != ENABLE fastboot_msg_en(ENABLE); #endif sf_file_thumb_cfg_sava(); sf_para_print(); // DBG_DUMP("wait filesys close ...\n"); #if (LOGFILE_FUNC==ENABLE) UIMenuStoreInfo *puiPara = sf_ui_para_get(); if(puiPara->DebugMode) { DBG_DUMP("LogFile_Close ...\n"); LogFile_Suspend(); LogFile_Close(); } #endif FileSys_Close(FST_TIME_INFINITE); #if SF_IQ_TEST != ENABLE if(sf_get_power_off_flag()){ sf_mcu_reg_set(SF_MCU_POWEROFF,0); }else{ fastboot_set_done(BOOT_FLOW_BOOT); flow_wait_linux(); } #else sf_mcu_reg_set(SF_MCU_POWEROFF,0); #endif #else fastboot_set_done(BOOT_FLOW_BOOT); flow_wait_linux(); #endif #else /* ShutDown */ vos_perf_list_mark("pwr off", __LINE__, 0); #if POWERON_BOOT_REPORT == ENABLE vos_perf_list_dump(); PhotoFast_TriggerFrm_Dump(); #endif #if HUNTING_CAMERA_MCU == ENABLE sf_mcu_reg_set(SF_MCU_POWEROFF,0); #endif hwpower_set_power_key(POWER_ID_PSW1, 0xFF); #endif } #if 1 void Set_NIGHTMODE(UINT32 id, UINT8 isSnapVideo) { #if HUNTING_CAMERA_MCU == ENABLE UIMenuStoreInfo *puiPara = sf_ui_para_get(); IQT_NIGHT_MODE night_mode = {0}; AWBT_MANUAL awb_manual = {0}; HD_RESULT hd_ret; //static int tmpFlag = 2; //printf("[%s:%d]s tmpFlag:%d\n",__FUNCTION__,__LINE__,tmpFlag); //IQT_EDGE_PARAM edge = {0}; //vos_perf_list_mark("sie_vd", __LINE__, tmpFlag); //tmpFlag++; if(sf_is_night_mode(1) ==TRUE) { if ((hd_ret = vendor_isp_init()) != HD_OK) { DBG_ERR("vendor_isp_init() fail(%d)\r\n", hd_ret); } DrvGOIO_Turn_Onoff_IRCUT(0); //DrvGPIO_IRLed_Turn_Onoff(1); // printf("[%s:%d]s NightMode:%d FlashLed:%d\n",__FUNCTION__,__LINE__,((2 == SysGetFlag(NightMode)) ? 2 : 1), SysGetFlag(FlashLed)); sf_ir_led_set(((2 == puiPara->NightMode) ? 2 : 1),puiPara->FlashLed, puiPara->NightMode, isSnapVideo); awb_manual.id = 0; awb_manual.manual.en = 1; awb_manual.manual.r_gain= 256; awb_manual.manual.g_gain= 256; awb_manual.manual.b_gain= 256; vendor_isp_set_awb(AWBT_ITEM_MANUAL, &awb_manual); night_mode.id = 0; night_mode.mode = 1; vendor_isp_set_iq(IQT_ITEM_NIGHT_MODE, &night_mode); /* edge.id =0; vendor_isp_get_iq(IQT_ITEM_EDGE_PARAM, &edge); edge.edge.es_map_lut[8] = 64; edge.edge.es_map_lut[9] = 72; edge.edge.es_map_lut[10] = 80; edge.edge.es_map_lut[12] = 84; edge.edge.es_map_lut[13] = 84; edge.edge.es_map_lut[14] = 84; edge.edge.es_map_lut[15] = 84; vendor_isp_set_iq(IQT_ITEM_EDGE_PARAM, &edge); */ if ((hd_ret = vendor_isp_uninit()) != HD_OK) { DBG_ERR("vendor_isp_uninit() fail(%d)\r\n", hd_ret); } }else { DrvGOIO_Turn_Onoff_IRCUT(1); } #endif /* if (SysGetFlag(FL_CONTINUE_SHOT) == CONTINUE_SHOT_BURST_5) { ae_manual.id = 0; vendor_isp_get_ae(AET_ITEM_MANUAL, &ae_manual); ae_manual.manual.mode = LOCK_MODE; vendor_isp_set_ae(AET_ITEM_MANUAL, &ae_manual); awb_status.id = 0; vendor_isp_get_awb(AWBT_ITEM_STATUS, &awb_status); awb_manual.id = 0; awb_manual.manual.en = 1; awb_manual.manual.r_gain= awb_status.status.cur_r_gain; awb_manual.manual.g_gain= awb_status.status.cur_g_gain; awb_manual.manual.b_gain= awb_status.status.cur_b_gain; vendor_isp_set_awb(AWBT_ITEM_MANUAL, &awb_manual); } */ } void Set_AEMODE(UINT32 id) { AET_MANUAL ae_manual = {0}; AWBT_STATUS status = {0}; ISPT_C_GAIN c_gain = {0}; HD_RESULT hd_ret; #if HUNTING_CAMERA_MCU == ENABLE UIMenuStoreInfo *puiPara = sf_ui_para_get(); #endif memset(&ae_status, 0, sizeof(AET_STATUS_INFO)); if ((hd_ret = vendor_isp_init()) != HD_OK) { DBG_ERR("vendor_isp_init() fail(%d)\r\n", hd_ret); } if (1)//SysGetFlag(FL_CONTINUE_SHOT) == CONTINUE_SHOT_BURST_5) { ae_status.id = 0; vendor_isp_get_ae(AET_ITEM_STATUS, &ae_status); //DBG_ERR(">> aet status exp %d iso %d\r\n",ae_status_info.status_info.expotime[0],ae_status_info.status_info.iso_gain[0]); ae_manual.id = 0; vendor_isp_get_ae(AET_ITEM_MANUAL, &ae_manual); //DBG_ERR(">> aet manual exp %d iso %d\r\n",ae_manual.manual.expotime,ae_manual.manual.iso_gain); if (id == 1){ ae_manual.manual.mode = 1; #if HUNTING_CAMERA_MCU == ENABLE if(puiPara->CamMode == SF_CAM_MODE_VIDEO2) { ae_manual.manual.expotime = 33333; ae_manual.manual.iso_gain = ae_status.status_info.iso_gain[0]*ae_status.status_info.expotime[0]/33333; } else if (puiPara->NightMode == 0) { ae_manual.manual.expotime = 125000;//ae_status.status_info.expotime[0]; ae_manual.manual.iso_gain = ae_status.status_info.iso_gain[0]*ae_status.status_info.expotime[0]/125000; } else if (puiPara->NightMode == 1) { ae_manual.manual.expotime = 66666;//ae_status.status_info.expotime[0]; ae_manual.manual.iso_gain = ae_status.status_info.iso_gain[0]*ae_status.status_info.expotime[0]/66666; } else { ae_manual.manual.expotime = ae_status.status_info.expotime[0]; ae_manual.manual.iso_gain = ae_status.status_info.iso_gain[0]; } #else ae_manual.manual.expotime = ae_status.status_info.expotime[0]; ae_manual.manual.iso_gain = ae_status.status_info.iso_gain[0]; #endif /*ISPT_TOTAL_GAIN total; total.id = 0; total.gain = 1600; vendor_isp_set_common(ISPT_ITEM_TOTAL_GAIN, &total);*/ //nvt_cmdsys_runcmd("ae dbg 0 0 0 "); } else { ae_manual.manual.mode = 0; } //DBG_ERR(">> >>>>>>>>>aet manual mode %d\r\n",ae_manual.manual.mode); vendor_isp_set_ae(AET_ITEM_MANUAL, &ae_manual); #if HUNTING_CAMERA_MCU == ENABLE if(sf_is_night_mode(0) ==FALSE){ #else { #endif status.id = 0; vendor_isp_get_awb(AWBT_ITEM_STATUS, &status); c_gain.id = 0; c_gain.gain[0] = status.status.cur_r_gain; c_gain.gain[1] = status.status.cur_g_gain; c_gain.gain[2] = status.status.cur_b_gain; vendor_isp_set_common(ISPT_ITEM_C_GAIN, &c_gain); } } if ((hd_ret = vendor_isp_uninit()) != HD_OK) { DBG_ERR("vendor_isp_uninit() fail(%d)\r\n", hd_ret); } } void PhotoFast_TriggerFrm_Dump(void) { if(g_vcap_trigger_frm_count < VD_TICK_BUF_SIZE){ DBG_DUMP("\n\n**********************************************************\n" " Trigger Speed(vcap frame count = %lu) : %lu us\n" "**********************************************************\n", g_vcap_trigger_frm_count, g_tickBuf[g_vcap_trigger_frm_count]); } else if(g_vcap_trigger_frm_count == 0xFFFFFFFF){ DBG_DUMP("\n\n**********************************************************\n" " Trigger Speed : Unknown\n" "**********************************************************\n"); } else{ DBG_DUMP("\n\n**********************************************************\n" " Trigger Speed : Err (vcap frame count = %lu)\n" "**********************************************************\n", g_vcap_trigger_frm_count); } } BOOL PhotoFast_SetTriggerFrmCnt(UINT32 cnt) { g_vcap_trigger_frm_count = cnt; return TRUE; } UINT32 PhotoFast_GetTriggerFrmCnt(VOID) { return g_vcap_trigger_frm_count; } BOOL PhotoFast_SetTick(UINT32 cnt, VOS_TICK tick) { if(cnt > VD_TICK_BUF_SIZE){ DBG_WRN("%lu exceed tick buffer(%lu)\n", cnt, VD_TICK_BUF_SIZE); return FALSE; } g_tickBuf[cnt] = tick; return TRUE; } BOOL PhotoFast_GetTick(UINT32 cnt, VOS_TICK* tick) { if(tick == NULL){ DBG_WRN("tick is null!\n"); return FALSE; } if(cnt > VD_TICK_BUF_SIZE){ DBG_WRN("%lu exceed tick buffer(%lu)!\n", cnt, VD_TICK_BUF_SIZE); return FALSE; } *tick = g_tickBuf[cnt]; return TRUE; } UINT32 PhotoFast_GetTickBufSize(void) { return VD_TICK_BUF_SIZE; } #include "vendor_common.h" #define DBGINFO_BUFSIZE() (0x200) ER PhotoFast_Movie_Init(void) { PhotoFast_InitExif(); PhotoFastCapDateImprint_InitBuff(); hd_gfx_init(); HD_COMMON_MEM_INIT_CONFIG mem_cfg = {0}; UINT32 id = 0; /******************************************************************* * Slice encode thumbnail *******************************************************************/ #if HUNTING_CAMERA_MCU == ENABLE UIMenuStoreInfo *puiPara = sf_ui_para_get(); UINT32 blk_size = DBGINFO_BUFSIZE() + VDO_YUV_BUFSIZE(sf_get_screen_nail_width(puiPara->SendPicSize), sf_get_screen_nail_height(puiPara->SendPicSize), HD_VIDEO_PXLFMT_YUV420); #else UINT32 blk_size = DBGINFO_BUFSIZE() + VDO_YUV_BUFSIZE(CFG_SCREENNAIL_W, CFG_SCREENNAIL_H, HD_VIDEO_PXLFMT_YUV420); #endif mem_cfg.pool_info[id].type = HD_COMMON_MEM_COMMON_POOL; mem_cfg.pool_info[id].blk_size = blk_size; mem_cfg.pool_info[id].blk_cnt = 1; mem_cfg.pool_info[id].ddr_id = DDR_ID0; /******************************************************************* * Slice encode slice yuv buffer *******************************************************************/ id ++; mem_cfg.pool_info[id].type = HD_COMMON_MEM_COMMON_POOL; mem_cfg.pool_info[id].blk_size = PhotoFast_SliceEncode_Get_Max_Dst_Slice_Buffer_Size(HD_VIDEO_PXLFMT_YUV420); mem_cfg.pool_info[id].blk_cnt = 1; mem_cfg.pool_info[id].ddr_id = DDR_ID0; // config common pool (screennail image) id ++; mem_cfg.pool_info[id].type = HD_COMMON_MEM_COMMON_POOL; #if HUNTING_CAMERA_MCU == ENABLE mem_cfg.pool_info[id].blk_size = DBGINFO_BUFSIZE()+VDO_YUV_BUFSIZE(sf_get_screen_nail_width(puiPara->SendPicSize), sf_get_screen_nail_height(puiPara->SendPicSize), HD_VIDEO_PXLFMT_YUV420); #else mem_cfg.pool_info[id].blk_size = DBGINFO_BUFSIZE()+VDO_YUV_BUFSIZE(CFG_SCREENNAIL_W, CFG_SCREENNAIL_H, HD_VIDEO_PXLFMT_YUV420); #endif mem_cfg.pool_info[id].blk_cnt = 1; mem_cfg.pool_info[id].ddr_id = DDR_ID0; // config common pool (EXIF) id++; mem_cfg.pool_info[id].type = HD_COMMON_MEM_COMMON_POOL; mem_cfg.pool_info[id].blk_size = DBGINFO_BUFSIZE()+CFG_JPG_HEADER_SIZE; mem_cfg.pool_info[id].blk_cnt = 1; mem_cfg.pool_info[id].ddr_id = DDR_ID0; UIAPP_PHOTO_SENSOR_INFO *sensor_info = UIAppPhoto_get_SensorInfo(0); id++; mem_cfg.pool_info[id].type = HD_COMMON_MEM_COMMON_POOL; mem_cfg.pool_info[id].blk_size = DBGINFO_BUFSIZE()+VDO_YUV_BUFSIZE(sensor_info->sSize.w, sensor_info->sSize.h , HD_VIDEO_PXLFMT_YUV420); mem_cfg.pool_info[id].blk_cnt = 3; /* depending on cont shot */ mem_cfg.pool_info[id].ddr_id = DDR_ID0; vendor_common_mem_relayout(&mem_cfg); return E_OK; } #endif