1607 lines
46 KiB
C
Executable File
1607 lines
46 KiB
C
Executable File
////////////////////////////////////////////////////////////////////////////////
|
|
#include "PrjInc.h"
|
|
#include "System/SysCommon.h"
|
|
#include "WiFiIpc/nvtwifi.h"
|
|
#include "UIWnd/UIFlow.h"
|
|
//#include "UIWnd/SPORTCAM/UIInfo/UIInfo.h"
|
|
//#include "UIWnd/SPORTCAM/UIInfo/UIPhotoInfo.h"
|
|
//#include "DateTimeInfo.h"
|
|
#include "UIDateImprint.h"
|
|
#include "UIDateImprintID.h"
|
|
//#include "UIWnd/SPORTCAM/Resource/UIResource.h"
|
|
//#include "Utility.h"
|
|
|
|
#include "FontConv/FontConv.h"
|
|
|
|
#include "Mode/UIMode.h"
|
|
#include "gximage/gximage.h"
|
|
//#include "UIWnd/SPORTCAM/UIInfo/UIPhotoMapping.h"
|
|
//#include "nvtmpp.h"
|
|
#include "UIAppPhoto.h"
|
|
#include "GxVideoFile.h"
|
|
#include <kflow_common/nvtmpp.h>
|
|
#include "kwrap/type.h"
|
|
#include "UIApp/MovieStamp/MovieStamp.h"
|
|
//#include "UIWnd/SPORTCAM/UIInfo/DateTimeInfo.h"
|
|
#include "vf_gfx.h"
|
|
|
|
#if HUNTING_CAMERA_MCU == ENABLE
|
|
#include <sf_common.h>
|
|
#endif
|
|
#define THIS_DBGLVL 2 // 0=FATAL, 1=ERR, 2=WRN, 3=UNIT, 4=FUNC, 5=IND, 6=MSG, 7=VALUE, 8=USER
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
#define __MODULE__ UIDateImprint
|
|
#define __DBGLVL__ ((THIS_DBGLVL>=PRJ_DBG_LVL)?THIS_DBGLVL:PRJ_DBG_LVL)
|
|
#define __DBGFLT__ "*" //*=All, [mark]=CustomClass
|
|
#include <kwrap/debug.h>
|
|
|
|
#include "UIInfo/UIInfo.h"
|
|
#include "sf_battery.h"
|
|
|
|
#define USE_DBG_STAMP DISABLE
|
|
|
|
/****************************************************
|
|
* IMPORTANT!!
|
|
*
|
|
* LVGL UI style only accept RGB color
|
|
*
|
|
****************************************************/
|
|
#if defined(_UI_STYLE_LVGL_)
|
|
|
|
#include "UIApp/lv_user_font_conv/lv_user_font_conv.h"
|
|
|
|
#define DATE_COLOR_TRANSPARENT lv_color_to32(LV_COLOR_OLIVE) /* it will be converted into yuv as color key */
|
|
#define DATE_COLOR_WHITE lv_color_to32(LV_COLOR_WHITE)
|
|
#define DATE_COLOR_BLACK lv_color_to32(LV_COLOR_BLACK)
|
|
#define DATE_COLOR_ORANGED lv_color_to32(LV_COLOR_ORANGE)
|
|
#define DATE_COLOR_RED lv_color_to32(LV_COLOR_RED)
|
|
|
|
#define LV_USER_FONT_CONV_ALIGN_W 8
|
|
#define LV_USER_FONT_CONV_ALIGN_H 2
|
|
|
|
lv_user_font_conv_draw_cfg draw_cfg = {0};
|
|
|
|
static void _movie_stamp_lv_cfg_init(lv_user_font_conv_draw_cfg *draw_cfg)
|
|
{
|
|
lv_user_font_conv_draw_cfg_init(draw_cfg);
|
|
|
|
|
|
draw_cfg->radius = LV_USER_CFG_STAMP_RADIUS;
|
|
draw_cfg->string.align = LV_USER_CFG_STAMP_TEXT_ALIGN;
|
|
draw_cfg->string.letter_space = LV_USER_CFG_STAMP_LETTER_SPACE;
|
|
draw_cfg->ext_w = LV_USER_CFG_STAMP_EXT_WIDTH;
|
|
draw_cfg->ext_h = LV_USER_CFG_STAMP_EXT_HEIGHT;
|
|
draw_cfg->border.width = LV_USER_CFG_STAMP_BORDER_WIDTH;
|
|
|
|
}
|
|
|
|
static UINT32 UIDateImprint_GetStampMemSize_LVGL(const lv_font_t *pFont, char* text)
|
|
{
|
|
//lv_user_font_conv_draw_cfg draw_cfg = {0};
|
|
lv_user_font_conv_calc_buffer_size_result result = {0};
|
|
|
|
_movie_stamp_lv_cfg_init(&draw_cfg);
|
|
|
|
draw_cfg.string.font = (lv_font_t *)pFont;
|
|
draw_cfg.string.text = text;
|
|
|
|
DBG_IND("[%s:%d]draw_cfg.string.text=%s\n", __FUNCTION__, __LINE__, draw_cfg.string.text);
|
|
|
|
draw_cfg.align_w = LV_USER_FONT_CONV_ALIGN_W;
|
|
draw_cfg.align_h = LV_USER_FONT_CONV_ALIGN_H;
|
|
|
|
if(PhotoExe_GetCapYUV420En()){
|
|
draw_cfg.fmt = HD_VIDEO_PXLFMT_YUV420;//GX_IMAGE_PIXEL_FMT_YUV420_PACKED;
|
|
}else{
|
|
draw_cfg.fmt = HD_VIDEO_PXLFMT_YUV422;//GX_IMAGE_PIXEL_FMT_YUV422_PACKED;
|
|
}
|
|
|
|
lv_user_font_conv_calc_buffer_size(&draw_cfg, &result);
|
|
|
|
DBG_IND("[%s:%d]result.output_buffer_size=%d\n", __FUNCTION__, __LINE__, result.output_buffer_size);
|
|
|
|
return result.output_buffer_size;
|
|
}
|
|
|
|
static ER FontConv_LVGL(FONT_CONV_IN *pIn, FONT_CONV_OUT *pOut)
|
|
{
|
|
HD_RESULT r;
|
|
//lv_user_font_conv_draw_cfg draw_cfg = {0};
|
|
lv_user_font_conv_mem_cfg mem_cfg = {0};
|
|
lv_user_font_conv_calc_buffer_size_result result = {0};
|
|
lv_color32_t color32;
|
|
|
|
_movie_stamp_lv_cfg_init(&draw_cfg);
|
|
|
|
draw_cfg.fmt = pIn->Format;
|
|
draw_cfg.string.font = (lv_font_t *) pIn->pFont;
|
|
draw_cfg.string.text = pIn->pStr;
|
|
draw_cfg.string.align = LV_USER_CFG_STAMP_TEXT_ALIGN;
|
|
draw_cfg.align_w = LV_USER_FONT_CONV_ALIGN_W;
|
|
draw_cfg.align_h = LV_USER_FONT_CONV_ALIGN_H;
|
|
|
|
/* text color */
|
|
color32.full = pIn->ciSolid;
|
|
draw_cfg.string.color = LV_COLOR_MAKE(color32.ch.red, color32.ch.green, color32.ch.blue);
|
|
draw_cfg.string.opa = LV_COLOR_GET_A32(color32);
|
|
|
|
/* bg color */
|
|
color32.full = pIn->ciTransparet;
|
|
draw_cfg.bg.color = LV_COLOR_MAKE(color32.ch.red, color32.ch.green, color32.ch.blue);
|
|
draw_cfg.bg.opa = LV_COLOR_GET_A32(color32);
|
|
|
|
/* border color */
|
|
color32.full = pIn->ciFrame;
|
|
draw_cfg.border.color = LV_COLOR_MAKE(color32.ch.red, color32.ch.green, color32.ch.blue);
|
|
draw_cfg.border.opa = LV_COLOR_GET_A32(color32);
|
|
draw_cfg.border.width = LV_USER_CFG_STAMP_BORDER_WIDTH;
|
|
|
|
/****************************************************************************
|
|
* IMPORTANT!!
|
|
*
|
|
* do not set color key to zero because engine may ignore zero value.
|
|
****************************************************************************/
|
|
draw_cfg.key_y = 255;
|
|
draw_cfg.key_u = 255;
|
|
draw_cfg.key_v = 255;
|
|
|
|
mem_cfg.output_buffer = (void*)pIn->MemAddr;
|
|
mem_cfg.output_buffer_size = pIn->MemSize;
|
|
|
|
DBG_IND("[%s:%d]mem_cfg.output_buffer_size=%d\n", __FUNCTION__, __LINE__, mem_cfg.output_buffer_size);
|
|
|
|
lv_user_font_conv_calc_buffer_size(&draw_cfg, &result);
|
|
lv_user_font_conv(&draw_cfg, &mem_cfg);
|
|
|
|
UINT32 LineOffs[2];
|
|
UINT32 PxlAddrs[2];
|
|
|
|
HD_COMMON_MEM_VIRT_INFO vir_meminfo = {0};
|
|
|
|
vir_meminfo.va = (void *)(mem_cfg.output_buffer);
|
|
if ( hd_common_mem_get(HD_COMMON_MEM_PARAM_VIRT_INFO, &vir_meminfo) != HD_OK) {
|
|
DBG_ERR("convert output_buffer to pa failed!\n");
|
|
return -1;
|
|
}
|
|
|
|
LineOffs[0] = (float)result.width * (float)(result.bpp / 8);
|
|
LineOffs[1] = LineOffs[0];
|
|
PxlAddrs[0] = (UINT32) vir_meminfo.pa;
|
|
PxlAddrs[1] = PxlAddrs[0] + (result.width * result.height); /* y plane is w * h for yuv420 & 422 */
|
|
|
|
r = vf_init_ex(&pOut->GenImg, result.width, result.height, pIn->Format, LineOffs, PxlAddrs);
|
|
if (r != HD_OK) {
|
|
DBG_ERR("vf_init_ex failed %d\r\n",r);
|
|
}
|
|
|
|
pOut->ColorKeyY = draw_cfg.key_y;
|
|
pOut->ColorKeyCb = draw_cfg.key_u;
|
|
pOut->ColorKeyCr = draw_cfg.key_v;
|
|
|
|
return 0;
|
|
}
|
|
|
|
|
|
#else
|
|
|
|
#include "UIApp/MovieStamp/DateStampFontTbl56x96.h"
|
|
#include "UIApp/MovieStamp/DateStampFontTbl42x72.h"
|
|
#include "UIApp/MovieStamp/DateStampFontTbl36x60.h"
|
|
#include "UIApp/MovieStamp/DateStampFontTbl26x44.h"
|
|
#include "UIApp/MovieStamp/DateStampFontTbl20x44.h"
|
|
#include "UIApp/MovieStamp/DateStampFontTbl18x30.h"
|
|
#include "UIApp/MovieStamp/DateStampFontTbl12x20.h"
|
|
#include "UIApp/MovieStamp/DateStampFontTbl10x16.h"
|
|
|
|
/****************************************************
|
|
* YUV
|
|
****************************************************/
|
|
#define DATE_COLOR_TRANSPARENT 0x00808000
|
|
#define DATE_COLOR_WHITE 0x008080FF
|
|
#define DATE_COLOR_BLACK 0x00818101
|
|
#define DATE_COLOR_ORANGED 0x00D4328A
|
|
#define DATE_COLOR_RED 0x00FF554E
|
|
|
|
#endif
|
|
|
|
#define FONT_BUF_RATIO (450)
|
|
|
|
typedef enum {
|
|
DATE_IMPRINT_EVENT_QV = 0, ///<quick view event
|
|
DATE_IMPRINT_EVENT_SCR, ///<screennail event
|
|
DATE_IMPRINT_EVENT_PRI, ///<primary image event
|
|
DATE_IMPRINT_EVENT_MAX, ///<Maximun value
|
|
} DATE_IMPRINT_EVENT;
|
|
|
|
|
|
typedef struct{
|
|
UINT32 PosX;
|
|
UINT32 PosY;
|
|
//IMG_BUF Img;
|
|
HD_VIDEO_FRAME Img;
|
|
UINT32 ColorKey; ///< format 0x00YYUUVV
|
|
UINT32 StampWeight; ///< 0 ~ 255
|
|
} DS_STAMP_INFOR;
|
|
|
|
|
|
typedef struct {
|
|
IMG_CAP_DATASTAMP_INFO *pCapInfo;
|
|
UINT32 MemAddr;
|
|
UINT32 MemSize;
|
|
FONT_CONV_IN tYuvDesc;
|
|
FONT_CONV_OUT tYuvInfo;
|
|
DS_STAMP_INFOR StampInfo;
|
|
//GX_IMAGE_CP_ENG copyEngine;
|
|
GXIMG_CP_ENG copyEngine;
|
|
UINT32 lockptn;
|
|
BOOL isStrDirty;
|
|
CHAR StrBuf[64];
|
|
UINT32 pic_cnt;
|
|
} DATE_IMPRINT_INFO;
|
|
|
|
|
|
typedef struct {
|
|
DATE_IMPRINT_INFO info[DATE_IMPRINT_EVENT_MAX];
|
|
|
|
} DATE_IMPRINT_CTRL;
|
|
|
|
DATE_IMPRINT_CTRL gDateImprintCtrl = {0};
|
|
DATE_IMPRINT_CTRL *pCtrl = &gDateImprintCtrl;
|
|
//static char gUiDateImprint_StrBuf[64] = {0};
|
|
//static NVTMPP_VB_POOL g_DateImprintPool[DATE_IMPRINT_EVENT_MAX]={NVTMPP_VB_INVALID_POOL, NVTMPP_VB_INVALID_POOL, NVTMPP_VB_INVALID_POOL};
|
|
static STAMP_ADDR_INFO g_DateImprintPool[DATE_IMPRINT_EVENT_MAX]={0};
|
|
void UiDateImprint_GetStampFont(UINT32 uiImageWidth, char **font);
|
|
char *UiDateImprint_InitStrBuf(void);
|
|
|
|
void UiDateImprint_Lock(UINT32 ptn)
|
|
{
|
|
FLGPTN uiFlag = 0;
|
|
wai_flg(&uiFlag, UI_DATEIMPRINT_FLG_ID, ptn, TWF_CLR);
|
|
}
|
|
|
|
void UiDateImprint_UnLock(UINT32 ptn)
|
|
{
|
|
set_flg(UI_DATEIMPRINT_FLG_ID, ptn);
|
|
}
|
|
|
|
|
|
void UiDateImprint_InitBuff(void)
|
|
{
|
|
|
|
DATE_IMPRINT_INFO *pInfo;
|
|
UINT32 i,genMaxw, genMaxh;
|
|
//NVTMPP_VB_BLK blk;
|
|
void *va;
|
|
UINT32 pa;
|
|
ER ret;
|
|
HD_COMMON_MEM_DDR_ID ddr_id = DDR_ID0;
|
|
CHAR pool_name[20] ={0};
|
|
ISIZE szStamp;
|
|
UINT32 FontWidth = 0;
|
|
UINT32 FontHight = 0;
|
|
FONT *pFont;
|
|
|
|
#if defined(_UI_STYLE_LVGL_)
|
|
LV_UNUSED(FontWidth);
|
|
LV_UNUSED(FontHight);
|
|
LV_UNUSED(szStamp);
|
|
#endif
|
|
|
|
|
|
DBG_IND("\r\n");
|
|
if (!UI_DATEIMPRINT_FLG_ID) {
|
|
DBG_ERR("ID is not installed\r\n");
|
|
return;
|
|
}
|
|
|
|
for (i=0;i<DATE_IMPRINT_EVENT_MAX;i++) {
|
|
pInfo = &pCtrl->info[i];
|
|
if ( i == DATE_IMPRINT_EVENT_QV && g_DateImprintPool[i].pool_va == 0) {
|
|
ISIZE size = GxVideo_GetDeviceSize(DOUT1);
|
|
|
|
UiDateImprint_GetStampFont(size.w,(char**)&pFont);
|
|
|
|
#if defined(_UI_STYLE_LVGL_)
|
|
pInfo->MemSize = UIDateImprint_GetStampMemSize_LVGL((const lv_font_t *)pFont, UiDateImprint_InitStrBuf());
|
|
//pInfo->MemSize = pInfo->MemSize/4*5; //add alloc buff.
|
|
#else
|
|
GxGfx_SetTextStroke((const FONT *)pFont, FONTSTYLE_NORMAL, SCALE_1X);
|
|
GxGfx_Text(0, 0, 0, UiDateImprint_InitStrBuf()); //not really draw
|
|
szStamp = GxGfx_GetTextLastSize(); //just get text size
|
|
|
|
FontWidth=ALIGN_CEIL(szStamp.w ,8);
|
|
FontHight=ALIGN_CEIL(szStamp.h, 2);
|
|
pInfo->MemSize = (FontWidth*FontHight*FONT_BUF_RATIO)/100;//0x5000;//0x80000;
|
|
#endif
|
|
|
|
DBG_IND("QV w=%d, %d, MemSize=0x%x\r\n", FontWidth,FontHight,pInfo->MemSize);
|
|
|
|
sprintf(pool_name,"DateImprint_QV");
|
|
|
|
ret = hd_common_mem_alloc(pool_name, &pa, (void **)&va, pInfo->MemSize, ddr_id);
|
|
|
|
if (ret != HD_OK) {
|
|
DBG_ERR("QV alloc fail size 0x%x, ddr %d\r\n", pInfo->MemSize, ddr_id);
|
|
return;
|
|
}
|
|
DBG_IND("pa = 0x%x, va = 0x%x\r\n", (unsigned int)(pa), (unsigned int)(va));
|
|
g_DateImprintPool[i].pool_va=(UINT32)va;
|
|
g_DateImprintPool[i].pool_pa=(UINT32)pa;
|
|
memset(va, 0, pInfo->MemSize);
|
|
|
|
pInfo->MemAddr = g_DateImprintPool[i].pool_va;
|
|
pInfo->copyEngine = GXIMG_CP_ENG1;
|
|
pInfo->lockptn = FLGPTN_BIT(i); //i
|
|
}
|
|
else if ( i == DATE_IMPRINT_EVENT_SCR && g_DateImprintPool[i].pool_va == 0) {
|
|
pInfo->MemSize = 0x80000;
|
|
#if HUNTING_CAMERA_MCU == ENABLE
|
|
UIMenuStoreInfo *puiPara = sf_ui_para_get();
|
|
UiDateImprint_GetStampFont(sf_get_screen_nail_width(puiPara->SendPicSize),(char**)&pFont);
|
|
#else
|
|
UiDateImprint_GetStampFont(CFG_SCREENNAIL_W,(char**)&pFont);
|
|
#endif
|
|
|
|
#if defined(_UI_STYLE_LVGL_)
|
|
pInfo->MemSize = UIDateImprint_GetStampMemSize_LVGL((const lv_font_t *)pFont, UiDateImprint_InitStrBuf());
|
|
//pInfo->MemSize = pInfo->MemSize/4*5; //add alloc buff.
|
|
#else
|
|
GxGfx_SetTextStroke((const FONT *)pFont, FONTSTYLE_NORMAL, SCALE_1X);
|
|
GxGfx_Text(0, 0, 0, UiDateImprint_InitStrBuf()); //not really draw
|
|
szStamp = GxGfx_GetTextLastSize(); //just get text size
|
|
|
|
FontWidth=ALIGN_CEIL(szStamp.w ,8);
|
|
FontHight=ALIGN_CEIL(szStamp.h, 2);
|
|
pInfo->MemSize = (FontWidth*FontHight*FONT_BUF_RATIO)/100;//0x5000;//0x80000;
|
|
#endif
|
|
|
|
|
|
DBG_IND("SRC w=%d, %d, MemSize=0x%x\r\n", FontWidth,FontHight,pInfo->MemSize);
|
|
|
|
sprintf(pool_name,"DateImprint_SCR");
|
|
|
|
ret = hd_common_mem_alloc(pool_name, &pa, (void **)&va, pInfo->MemSize, ddr_id);
|
|
|
|
if (ret != HD_OK) {
|
|
DBG_ERR("QV alloc fail size 0x%x, ddr %d\r\n", pInfo->MemSize, ddr_id);
|
|
return;
|
|
}
|
|
DBG_IND("pa = 0x%x, va = 0x%x\r\n", (unsigned int)(pa), (unsigned int)(va));
|
|
g_DateImprintPool[i].pool_va=(UINT32)va;
|
|
g_DateImprintPool[i].pool_pa=(UINT32)pa;
|
|
memset(va, 0, pInfo->MemSize);
|
|
|
|
pInfo->MemAddr = g_DateImprintPool[i].pool_va;
|
|
pInfo->copyEngine = GXIMG_CP_ENG2;
|
|
pInfo->lockptn = FLGPTN_BIT(i); //i
|
|
}
|
|
else if ( i == DATE_IMPRINT_EVENT_PRI && g_DateImprintPool[i].pool_va == 0) {
|
|
pInfo->MemSize = 0x80000;
|
|
UiDateImprint_GetStampFont(GetPhotoSizeWidth(PHOTO_MAX_CAP_SIZE),(char**)&pFont);
|
|
|
|
#if defined(_UI_STYLE_LVGL_)
|
|
pInfo->MemSize = UIDateImprint_GetStampMemSize_LVGL((const lv_font_t *)pFont, UiDateImprint_InitStrBuf());
|
|
//pInfo->MemSize = pInfo->MemSize/4*5; //add alloc buff.
|
|
#else
|
|
GxGfx_SetTextStroke((const FONT *)pFont, FONTSTYLE_NORMAL, SCALE_1X);
|
|
GxGfx_Text(0, 0, 0, UiDateImprint_InitStrBuf()); //not really draw
|
|
szStamp = GxGfx_GetTextLastSize(); //just get text size
|
|
|
|
FontWidth=ALIGN_CEIL(szStamp.w ,8);
|
|
FontHight=ALIGN_CEIL(szStamp.h, 2);
|
|
pInfo->MemSize = (FontWidth*FontHight*FONT_BUF_RATIO)/100;//0x80000;
|
|
#endif
|
|
|
|
DBG_IND("PRI w=%d, %d, MemSize=0x%x\r\n", FontWidth,FontHight,pInfo->MemSize);
|
|
|
|
|
|
sprintf(pool_name,"DateImprint_PRI");
|
|
|
|
ret = hd_common_mem_alloc(pool_name, &pa, (void **)&va, pInfo->MemSize, ddr_id);
|
|
|
|
if (ret != HD_OK) {
|
|
DBG_ERR("QV alloc fail size 0x%x, ddr %d\r\n", pInfo->MemSize, ddr_id);
|
|
return;
|
|
}
|
|
DBG_IND("pa = 0x%x, va = 0x%x\r\n", (unsigned int)(pa), (unsigned int)(va));
|
|
g_DateImprintPool[i].pool_va=(UINT32)va;
|
|
g_DateImprintPool[i].pool_pa=(UINT32)pa;
|
|
memset(va, 0, pInfo->MemSize);
|
|
|
|
pInfo->MemAddr = g_DateImprintPool[i].pool_va;
|
|
pInfo->copyEngine = GXIMG_CP_ENG2;
|
|
pInfo->lockptn =FLGPTN_BIT(i); //i
|
|
}
|
|
pInfo->isStrDirty = TRUE;
|
|
pInfo->StrBuf[0] = 0;
|
|
pInfo->pic_cnt = 0;
|
|
genMaxw = GetPhotoSizeWidth(0) / 2;
|
|
genMaxh = GetPhotoSizeHeight(0) * 0.04;
|
|
pInfo->StampInfo.Img.loff[0] = genMaxw;
|
|
pInfo->StampInfo.Img.loff[1] = genMaxw;
|
|
pInfo->StampInfo.Img.pw[0] = genMaxw;
|
|
pInfo->StampInfo.Img.ph[0] = genMaxh;
|
|
if(PhotoExe_GetCapYUV420En()){
|
|
pInfo->StampInfo.Img.pxlfmt = HD_VIDEO_PXLFMT_YUV420;//GX_IMAGE_PIXEL_FMT_YUV420_PACKED;
|
|
}else{
|
|
pInfo->StampInfo.Img.pxlfmt = HD_VIDEO_PXLFMT_YUV422;//GX_IMAGE_PIXEL_FMT_YUV422_PACKED;
|
|
}
|
|
}
|
|
set_flg(UI_DATEIMPRINT_FLG_ID, FLGPTN_BIT_ALL);
|
|
|
|
}
|
|
void UiDateImprint_DestroyBuff(void)
|
|
{
|
|
UINT32 i, ret;
|
|
for (i=0;i<DATE_IMPRINT_EVENT_MAX;i++) {
|
|
|
|
if (g_DateImprintPool[i].pool_va != 0) {
|
|
ret = hd_common_mem_free((UINT32)g_DateImprintPool[i].pool_pa, (void *)g_DateImprintPool[i].pool_va);
|
|
if (ret != HD_OK) {
|
|
DBG_ERR("FileIn release blk failed! (%d)\r\n", ret);
|
|
break;
|
|
}
|
|
g_DateImprintPool[i].pool_va = 0;
|
|
g_DateImprintPool[i].pool_pa = 0;
|
|
}
|
|
}
|
|
}
|
|
|
|
char StampStr[64] = {0};
|
|
|
|
extern BOOL UiDateImprint_UpdateDate(char *StrBuf, UINT32 buff_len);
|
|
char * UiDateImprint_InitStrBuf(void)
|
|
{
|
|
char *dateStr = NULL;
|
|
INT16 cTemper = 0;
|
|
INT16 fTemper = 0;
|
|
UINT8 temperStr[32] = {0};
|
|
|
|
DateTime_Load();
|
|
|
|
#if PHOTO_ISP_STAMP == ENABLE
|
|
|
|
str = DateTime_MakeYMD();
|
|
UiDateImprint_get_isp_status(0, str, DateTime_StrBuf_Size());
|
|
|
|
#else
|
|
|
|
switch (UI_GetData(FL_DATE_STAMP))
|
|
{
|
|
case DATEIMPRINT_DATE:
|
|
dateStr = DateTime_MakeYMD();
|
|
break;
|
|
|
|
case DATEIMPRINT_DATE_TIME:
|
|
default:
|
|
dateStr = DateTime_MakeYMDHMS();
|
|
break;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
sf_stamp_temperature_get(&fTemper, &cTemper);
|
|
snprintf((char *)temperStr, sizeof(temperStr), "%d%c%cF %d%c%cC", fTemper, 0xC2, 0xB0, cTemper, 0xC2, 0xB0);
|
|
//printf("[%s:%d]temperStr=%s\n", __FUNCTION__, __LINE__, temperStr);
|
|
|
|
snprintf((char *)StampStr, sizeof(StampStr), "%s %s", temperStr, dateStr);
|
|
DBG_IND("[%s:%d]StampStr=%s\n", __FUNCTION__, __LINE__, StampStr);
|
|
|
|
return StampStr;
|
|
}
|
|
|
|
UINT32 UiDateImprint_GetMaxWorkBufSize(DS_STAMP_INFOR *stampInfo)
|
|
{
|
|
return 0;//gximg_calc_require_size(stampInfo->Img.pw[0],stampInfo->Img.pw[0],stampInfo->Img.pxlfmt,stampInfo->Img.loff[0]);
|
|
}
|
|
|
|
void UiDateImprint_SelStampFont(UINT32 uiImageWidth, char **font, UINT32 *ScaleFactor)
|
|
{
|
|
#if defined(_UI_STYLE_LVGL_)
|
|
*ScaleFactor = 65536;
|
|
|
|
lv_plugin_res_id red_id;
|
|
|
|
if(uiImageWidth >= 5632)
|
|
{
|
|
red_id = LV_USER_CFG_STAMP_FONT_ID_24M;
|
|
}
|
|
else if(uiImageWidth >= 4608)
|
|
{
|
|
red_id = LV_USER_CFG_STAMP_FONT_ID_16M;
|
|
}
|
|
else if(uiImageWidth >= 4032)
|
|
{
|
|
red_id = LV_USER_CFG_STAMP_FONT_ID_12M;
|
|
}
|
|
else if(uiImageWidth >= 3264)
|
|
{
|
|
red_id = LV_USER_CFG_STAMP_FONT_ID_8M;
|
|
}
|
|
else if(uiImageWidth >= 1920)
|
|
{
|
|
red_id = LV_USER_CFG_STAMP_FONT_ID_LARGE;
|
|
}
|
|
else if(uiImageWidth >= 1080)
|
|
{
|
|
red_id = LV_USER_CFG_STAMP_FONT_ID_MEDIUM;
|
|
}
|
|
else if(uiImageWidth >= 1024)
|
|
{
|
|
red_id = LV_USER_CFG_STAMP_FONT_ID_SMALL_PIC;
|
|
}
|
|
else if(uiImageWidth >= 640)
|
|
{
|
|
red_id = LV_USER_CFG_STAMP_FONT_ID_SMALL;
|
|
}
|
|
else
|
|
{
|
|
red_id = LV_USER_CFG_STAMP_FONT_ID_XS;
|
|
}
|
|
|
|
DBG_IND("[%s:%d]uiImageWidth=%d,stamp font id=%d\n", __FUNCTION__, __LINE__, uiImageWidth, red_id);
|
|
|
|
*font = (char *) lv_plugin_get_font(red_id)->font;
|
|
|
|
#else
|
|
if (uiImageWidth >= 3840) {
|
|
*font = (char *)gDateStampFontTbl56x96;
|
|
*ScaleFactor = 65536;
|
|
}
|
|
else if(uiImageWidth >=3600) {
|
|
*font = (char *)&gDateStampFontTbl56x96;
|
|
*ScaleFactor = 65536*95/100;
|
|
}
|
|
else if(uiImageWidth >=3200) {
|
|
*font = (char *)&gDateStampFontTbl56x96;
|
|
*ScaleFactor = 65536*90/100;
|
|
}
|
|
else if(uiImageWidth >=2880) {
|
|
*font = (char *)&gDateStampFontTbl42x72;
|
|
*ScaleFactor = 65536;
|
|
}
|
|
else if(uiImageWidth >=1920) {
|
|
*font = (char *)&gDateStampFontTbl36x60;
|
|
*ScaleFactor = 65536;
|
|
}
|
|
else if(uiImageWidth >=1080) {
|
|
*font = (char *)&gDateStampFontTbl26x44;
|
|
*ScaleFactor = 65536;
|
|
}
|
|
else if(uiImageWidth >=640) {
|
|
*font = (char *)&gDateStampFontTbl12x20;
|
|
*ScaleFactor = 65536;
|
|
}
|
|
else if(uiImageWidth >=320) {
|
|
*font = (char *)&gDateStampFontTbl10x16;
|
|
*ScaleFactor = 65536;
|
|
}
|
|
else {
|
|
*font = (char *)&gDateStampFontTbl10x16;
|
|
*ScaleFactor = 65536/3;
|
|
}
|
|
#endif
|
|
|
|
|
|
}
|
|
void UiDateImprint_GetStampFont(UINT32 uiImageWidth, char **font)
|
|
{
|
|
#if defined(_UI_STYLE_LVGL_)
|
|
|
|
lv_plugin_res_id red_id;
|
|
|
|
|
|
if(uiImageWidth >= 5632)
|
|
{
|
|
red_id = LV_USER_CFG_STAMP_FONT_ID_24M;
|
|
}
|
|
else if(uiImageWidth >= 4608)
|
|
{
|
|
red_id = LV_USER_CFG_STAMP_FONT_ID_16M;
|
|
}
|
|
else if(uiImageWidth >= 4032)
|
|
{
|
|
red_id = LV_USER_CFG_STAMP_FONT_ID_12M;
|
|
}
|
|
else if(uiImageWidth >= 3264)
|
|
{
|
|
red_id = LV_USER_CFG_STAMP_FONT_ID_8M;
|
|
}
|
|
else if(uiImageWidth >= 1920)
|
|
{
|
|
red_id = LV_USER_CFG_STAMP_FONT_ID_LARGE;
|
|
}
|
|
else if(uiImageWidth >= 1080)
|
|
{
|
|
red_id = LV_USER_CFG_STAMP_FONT_ID_MEDIUM;
|
|
}
|
|
else if(uiImageWidth >= 1024)
|
|
{
|
|
red_id = LV_USER_CFG_STAMP_FONT_ID_SMALL_PIC;
|
|
}
|
|
else if(uiImageWidth >= 640)
|
|
{
|
|
red_id = LV_USER_CFG_STAMP_FONT_ID_SMALL;
|
|
}
|
|
else
|
|
{
|
|
red_id = LV_USER_CFG_STAMP_FONT_ID_XS;
|
|
}
|
|
|
|
DBG_IND("[%s:%d]uiImageWidth=%d,stamp font id=%d\n", __FUNCTION__, __LINE__, uiImageWidth, red_id);
|
|
|
|
*font = (char *) lv_plugin_get_font(red_id)->font;
|
|
|
|
#else
|
|
if (uiImageWidth >= 3840) {
|
|
*font = (char *)&gDateStampFontTbl56x96;
|
|
}
|
|
else if(uiImageWidth >=3600) {
|
|
*font = (char *)&gDateStampFontTbl56x96;
|
|
}
|
|
else if(uiImageWidth >=3200) {
|
|
*font = (char *)&gDateStampFontTbl56x96;
|
|
}
|
|
else if(uiImageWidth >=2880) {
|
|
*font = (char *)&gDateStampFontTbl42x72;
|
|
}
|
|
else if(uiImageWidth >=1920) {
|
|
*font = (char *)&gDateStampFontTbl36x60;
|
|
}
|
|
else if(uiImageWidth >=1080) {
|
|
*font = (char *)&gDateStampFontTbl26x44;
|
|
}
|
|
else if(uiImageWidth >=640) {
|
|
*font = (char *)&gDateStampFontTbl12x20;
|
|
}
|
|
else if(uiImageWidth >=320) {
|
|
*font = (char *)&gDateStampFontTbl10x16;
|
|
}
|
|
else {
|
|
*font = (char *)&gDateStampFontTbl10x16;
|
|
}
|
|
#endif
|
|
}
|
|
|
|
DATE_IMPRINT_INFO *UiDateImprint_Event2Info(IMG_CAP_DATASTAMP_EVENT event)
|
|
{
|
|
DATE_IMPRINT_INFO *pInfo;
|
|
if (event == CAP_DS_EVENT_QV)
|
|
pInfo = &pCtrl->info[DATE_IMPRINT_EVENT_QV];
|
|
else if (event == CAP_DS_EVENT_SCR)
|
|
pInfo = &pCtrl->info[DATE_IMPRINT_EVENT_SCR];
|
|
else if (event == CAP_DS_EVENT_PRI)
|
|
pInfo = &pCtrl->info[DATE_IMPRINT_EVENT_PRI];
|
|
else
|
|
pInfo = NULL;
|
|
return pInfo;
|
|
}
|
|
|
|
|
|
INT32 UiDateImprint_GenYuvData(DATE_IMPRINT_INFO *pInfo)
|
|
{
|
|
#if 1
|
|
FONT_CONV_IN *pIn = &pInfo->tYuvDesc;
|
|
FONT_CONV_OUT *pOut = &pInfo->tYuvInfo;
|
|
UINT32 photo_w = pInfo->pCapInfo->ImgInfo.ch[0].width;
|
|
// UINT32 photo_h = pInfo->pCapInfo->ImgInfo.ch[0].height;
|
|
|
|
DBG_IND("\r\n");
|
|
pIn->MemAddr = pInfo->MemAddr;
|
|
pIn->MemSize = pInfo->MemSize;
|
|
pIn->pStr = pInfo->StrBuf;
|
|
|
|
#if defined(_UI_STYLE_LVGL_)
|
|
pIn->ciSolid = LV_USER_CFG_STAMP_COLOR_TEXT;
|
|
pIn->ciFrame = LV_USER_CFG_STAMP_COLOR_FRAME;
|
|
pIn->ciTransparet = LV_USER_CFG_STAMP_COLOR_BACKGROUND;
|
|
#else
|
|
pIn->ciSolid = DATE_COLOR_RED;
|
|
pIn->ciFrame = DATE_COLOR_TRANSPARENT;
|
|
pIn->ciTransparet = DATE_COLOR_TRANSPARENT;
|
|
#endif
|
|
if(PhotoExe_GetCapYUV420En()){
|
|
pIn->Format = HD_VIDEO_PXLFMT_YUV420;//GX_IMAGE_PIXEL_FMT_YUV420_PACKED;
|
|
}else{
|
|
pIn->Format = HD_VIDEO_PXLFMT_YUV422;//GX_IMAGE_PIXEL_FMT_YUV422_PACKED;
|
|
}
|
|
pIn->bEnableSmooth = FALSE;
|
|
//ImgSize = photo_w*photo_h;
|
|
#if 0
|
|
if (photo_w * photo_h <= 160 * 120) {
|
|
//thumbnail Size
|
|
pIn->pFont = (FONT *)gDemo_SmallFont;
|
|
pIn->ScaleFactor = 65536 / 3; //0.33x
|
|
}
|
|
else if (photo_w * photo_h <= 640 * 480) {
|
|
//VGA Size
|
|
pIn->pFont = (FONT *)gDemo_SmallFont;
|
|
pIn->ScaleFactor = 65536; //1.0x
|
|
} else {
|
|
UINT32 font_h, stamp_ratio;
|
|
pIn->pFont = (FONT *)gDemo_BigFont;
|
|
|
|
font_h = 190;
|
|
stamp_ratio = 0x00000A00; //0.04x
|
|
pIn->ScaleFactor = photo_h * stamp_ratio / font_h;
|
|
}
|
|
#else
|
|
DBG_IND("photo_w=%d\r\n",photo_w);
|
|
UiDateImprint_SelStampFont(photo_w, (char**)&pIn->pFont, &pIn->ScaleFactor);
|
|
#endif
|
|
|
|
#if defined(_UI_STYLE_LVGL_)
|
|
if (FontConv_LVGL(pIn, pOut) != E_OK) {
|
|
DBG_ERR("FontConv err\r\n");
|
|
return -1;
|
|
}
|
|
#else
|
|
if (FontConv(pIn, pOut) != E_OK) {
|
|
DBG_ERR("FontConv err\r\n");
|
|
return -1;
|
|
}
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|
|
return 0;
|
|
}
|
|
|
|
INT32 UiDateImprint_CalcPosition(DATE_IMPRINT_INFO *pInfo, UPOINT *pos)
|
|
{
|
|
#if 1
|
|
IMG_CAP_DATASTAMP_INFO *pCapInfo = pInfo->pCapInfo;
|
|
FONT_CONV_OUT *pYuvInfo = &pInfo->tYuvInfo;
|
|
UINT32 ofs = 0;
|
|
|
|
|
|
UINT32 photo_w = pCapInfo->ImgInfo.ch[0].width;
|
|
UINT32 photo_h = pCapInfo->ImgInfo.ch[0].height;
|
|
|
|
DBG_IND("photo_w =%d, photo_h=%d, gen w=%d, h=%d\r\n",photo_w,photo_h,(pYuvInfo->GenImg.pw[0]),pYuvInfo->GenImg.ph[0]);
|
|
|
|
if ((pYuvInfo->GenImg.pw[0]) > photo_w)
|
|
{
|
|
DBG_ERR("event=%d, GenImg w %d> photo_w %d\r\n",pCapInfo->event,(pYuvInfo->GenImg.pw[0]),photo_w);
|
|
return -1;
|
|
}
|
|
|
|
if (pYuvInfo->GenImg.ph[0] > photo_h)
|
|
{
|
|
DBG_ERR("GenImg h %d> photo_h %d\r\n",pYuvInfo->GenImg.ph[0],photo_h);
|
|
return -1;
|
|
}
|
|
|
|
//Leave blank to the right of the date watermark
|
|
ofs = pYuvInfo->GenImg.ph[0]/2;
|
|
|
|
if(photo_w >= (pYuvInfo->GenImg.pw[0] + ofs)){
|
|
pos->x = ALIGN_ROUND_4(photo_w - pYuvInfo->GenImg.pw[0] - ofs);
|
|
}
|
|
else if(photo_w >= pYuvInfo->GenImg.pw[0]){
|
|
pos->x = ALIGN_ROUND_4(photo_w - pYuvInfo->GenImg.pw[0]);
|
|
}
|
|
else{
|
|
DBG_ERR("stamp width overflow!\n");
|
|
}
|
|
|
|
if(photo_w >= pYuvInfo->GenImg.pw[0]){
|
|
pos->y = ALIGN_ROUND_4(photo_h - pYuvInfo->GenImg.ph[0]);
|
|
}
|
|
else{
|
|
DBG_ERR("stamp height overflow!\n");
|
|
}
|
|
|
|
DBG_IND("pos->x =%d, pos->y=%d\r\n",pos->x, pos->y);
|
|
|
|
#endif
|
|
return 0;
|
|
}
|
|
|
|
ER UiDateImprint_UpdateData(DATE_IMPRINT_INFO *pInfo)
|
|
{
|
|
#if 1
|
|
DS_STAMP_INFOR *pStampInfo = &pInfo->StampInfo;
|
|
FONT_CONV_OUT *pYuvInfo = &pInfo->tYuvInfo;
|
|
UPOINT pos = {0};
|
|
|
|
if (UiDateImprint_GenYuvData(pInfo)< 0){
|
|
DBG_ERR("GenYuvData fail\r\n");
|
|
return E_SYS;
|
|
}
|
|
|
|
if (UiDateImprint_CalcPosition(pInfo,&pos) < 0){
|
|
DBG_ERR("CalcPosition fail\r\n");
|
|
return E_SYS;
|
|
}
|
|
pStampInfo->PosX = pos.x;
|
|
pStampInfo->PosY = pos.y;
|
|
DBG_IND("[%s:%d]pStampInfo->PosX=%d,pStampInfo->PosY=%d\n", __FUNCTION__, __LINE__, pStampInfo->PosX, pStampInfo->PosY);
|
|
pStampInfo->Img = pYuvInfo->GenImg;
|
|
|
|
//memcpy(&pStampInfo->Img, &pYuvInfo->GenImg, sizeof(VDO_FRAME));
|
|
|
|
pStampInfo->ColorKey = COLOR_MAKE_YUVD(pYuvInfo->ColorKeyY, pYuvInfo->ColorKeyCb, pYuvInfo->ColorKeyCr);
|
|
pStampInfo->StampWeight = 255;
|
|
DBG_IND("MemMax Use = %d bytes, MemMin Use=%d bytes\r\n", pYuvInfo->UsedMaxMemSize, pYuvInfo->UsedMemSize);
|
|
#endif
|
|
return E_OK;
|
|
}
|
|
|
|
void UiDateImprint_ChkUpdateData(DATE_IMPRINT_INFO *pInfo)
|
|
{
|
|
#if 1
|
|
UINT32 uiImageSize, ScreenNailSize;
|
|
UINT32 bScreenNailEn=0;
|
|
UINT32 bGenEn=0;
|
|
|
|
ScreenNailSize = CFG_SCREENNAIL_SIZE;
|
|
uiImageSize = UI_GetData(FL_PHOTO_SIZE);
|
|
if (uiImageSize < ScreenNailSize) {
|
|
bScreenNailEn=1;
|
|
}
|
|
|
|
if(pInfo->pCapInfo->event == CAP_DS_EVENT_SCR && bScreenNailEn){
|
|
bGenEn=1;
|
|
}else if(pInfo->pCapInfo->event == CAP_DS_EVENT_PRI && bScreenNailEn==0){
|
|
bGenEn=1;
|
|
}
|
|
|
|
DBG_IND("event=%d, bScreenNailEn=%d, bGenEn=%d\r\n",pInfo->pCapInfo->event,bScreenNailEn,bGenEn);
|
|
|
|
//if (pInfo->pCapInfo->event == CAP_DS_EVENT_QV || pInfo->pCapInfo->event == CAP_DS_EVENT_SCR) {
|
|
if (1/*pInfo->pCapInfo->event == CAP_DS_EVENT_PRI*/) {
|
|
#if HUNTING_CAMERA_MCU == ENABLE
|
|
pInfo->isStrDirty = UiDateImprint_UpdateDate(pInfo->StrBuf,sizeof(pInfo->StrBuf));
|
|
#else
|
|
if ((UI_GetData(FL_CONTINUE_SHOT) == CONTINUE_SHOT_BURST_3)) {
|
|
if (pInfo->pic_cnt == 0)
|
|
pInfo->isStrDirty = UiDateImprint_UpdateDate(pInfo->StrBuf,sizeof(pInfo->StrBuf));
|
|
else
|
|
pInfo->isStrDirty = FALSE;
|
|
}
|
|
else {
|
|
pInfo->isStrDirty = UiDateImprint_UpdateDate(pInfo->StrBuf,sizeof(pInfo->StrBuf));
|
|
}
|
|
#endif
|
|
}
|
|
#if 0
|
|
// need to update primary info to screenail
|
|
if (pInfo->pCapInfo->event == CAP_DS_EVENT_PRI)
|
|
{
|
|
DATE_IMPRINT_INFO *pScrInfo;
|
|
|
|
pScrInfo= UiDateImprint_Event2Info(CAP_DS_EVENT_SCR);
|
|
pScrInfo->isStrDirty = pInfo->isStrDirty;
|
|
if (pInfo->isStrDirty == TRUE){
|
|
strncpy(pScrInfo->StrBuf,pInfo->StrBuf,sizeof(pScrInfo->StrBuf));
|
|
}
|
|
}
|
|
#else
|
|
// need to update primary info to screenail
|
|
//if (pInfo->pCapInfo->event == CAP_DS_EVENT_SCR)
|
|
if (bGenEn && pInfo->pCapInfo->event == CAP_DS_EVENT_SCR)
|
|
{
|
|
DATE_IMPRINT_INFO *pScrInfo;
|
|
pScrInfo= UiDateImprint_Event2Info(CAP_DS_EVENT_PRI);
|
|
|
|
pScrInfo->isStrDirty = pInfo->isStrDirty;
|
|
if (pInfo->isStrDirty == TRUE){
|
|
strncpy(pScrInfo->StrBuf,pInfo->StrBuf,sizeof(pScrInfo->StrBuf));
|
|
}
|
|
}
|
|
#endif
|
|
pInfo->pic_cnt++;
|
|
#endif
|
|
}
|
|
|
|
void UiDateImprint_DrawBG(DS_STAMP_INFOR *stampInfo, HD_VIDEO_FRAME* Img)
|
|
{
|
|
HD_GFX_DRAW_RECT param = {0};
|
|
|
|
param.dst_img.dim = Img->dim;
|
|
param.dst_img.ddr_id = Img->ddr_id;
|
|
param.dst_img.format = Img->pxlfmt;
|
|
param.dst_img.lineoffset[0] = Img->loff[0];
|
|
param.dst_img.lineoffset[1] = Img->loff[1];
|
|
param.dst_img.p_phy_addr[0] = Img->phy_addr[0];
|
|
param.dst_img.p_phy_addr[1] = Img->phy_addr[1];
|
|
param.color = LV_USER_CFG_STAMP_COLOR_BACKGROUND; /* ARGB format */
|
|
param.thickness = 10;
|
|
param.rect.w = Img->dim.w;
|
|
if((Img->dim.w == 1920) || (Img->dim.w == 2560)) //bigger or 5M
|
|
{
|
|
param.rect.h = stampInfo->Img.dim.h;
|
|
}
|
|
else
|
|
{
|
|
param.rect.h = stampInfo->Img.dim.h*11/10; /*add heigt*/
|
|
}
|
|
param.rect.x = 0;
|
|
//param.rect.y = stampInfo->PosY;
|
|
param.rect.y = Img->dim.h - param.rect.h;
|
|
param.type = HD_GFX_RECT_SOLID;
|
|
DBG_IND("[%s:%d]Img->dim.h=%d,param.rect.h=%d,stampInfo->PosY=%d\n", __FUNCTION__, __LINE__, Img->dim.h, param.rect.h, stampInfo->PosY);
|
|
|
|
hd_gfx_draw_rect(¶m);
|
|
}
|
|
|
|
void UiDateImprint_AttachString(DS_STAMP_INFOR *stampInfo, HD_VIDEO_FRAME* Img, UINT8* name, bool enable_ckey, UINT32 padding, UINT32* x_curr_ofs)
|
|
{
|
|
//lv_user_font_conv_draw_cfg draw_cfg = {0};
|
|
lv_user_font_conv_calc_buffer_size_result buff_size = {0};
|
|
lv_user_font_conv_mem_cfg mem_cfg = {0};
|
|
VF_GFX_SCALE param_img = {0};
|
|
HD_VIDEO_FRAME src_img;
|
|
void *va;
|
|
UINT32 pa;
|
|
HD_RESULT ret;
|
|
HD_COMMON_MEM_DDR_ID ddr_id = DDR_ID0;
|
|
|
|
//_movie_stamp_lv_cfg_init(&draw_cfg);
|
|
|
|
draw_cfg.string.text = (char*)name;
|
|
/*draw_cfg.string.align = LV_USER_CFG_STAMP_TEXT_ALIGN;
|
|
draw_cfg.align_w = LV_USER_FONT_CONV_ALIGN_W;
|
|
draw_cfg.align_h = LV_USER_FONT_CONV_ALIGN_H;
|
|
draw_cfg.mode = LV_USER_FONT_CONV_DRAW_TEXT;
|
|
if(PhotoExe_GetCapYUV420En())
|
|
{
|
|
draw_cfg.fmt = HD_VIDEO_PXLFMT_YUV420;
|
|
}else
|
|
{
|
|
draw_cfg.fmt = HD_VIDEO_PXLFMT_YUV422;
|
|
}
|
|
UiDateImprint_GetStampFont(src_img.dim.w, (char**)&draw_cfg.string.font);*/
|
|
|
|
lv_user_font_conv_calc_buffer_size(&draw_cfg, &buff_size);
|
|
|
|
ret = hd_common_mem_alloc("stamp_font", &pa, (void **)&va, buff_size.output_buffer_size, ddr_id);
|
|
if (ret != HD_OK) {
|
|
DBG_ERR("custom_stamp_buffer allocate failed\n\r");
|
|
}
|
|
else {
|
|
mem_cfg.output_buffer = va;
|
|
mem_cfg.output_buffer_size = buff_size.output_buffer_size;
|
|
}
|
|
|
|
lv_user_font_conv(&draw_cfg, &mem_cfg);
|
|
lv_user_font_conv_cfg_to_hd_frame(
|
|
&draw_cfg,
|
|
&mem_cfg,
|
|
buff_size.width,
|
|
buff_size.height,
|
|
&src_img
|
|
);
|
|
|
|
memset(¶m_img, 0, sizeof(param_img));
|
|
param_img.quality = HD_GFX_SCALE_QUALITY_NULL;
|
|
param_img.src_img = src_img;
|
|
param_img.src_region.x = 0;
|
|
param_img.src_region.y = 0;
|
|
param_img.src_region.w = src_img.dim.w;
|
|
param_img.src_region.h = src_img.dim.h;
|
|
param_img.engine = 0;
|
|
param_img.dst_img = *Img;
|
|
param_img.dst_region.w = (src_img.dim.w / src_img.dim.h) * stampInfo->Img.ph[0];
|
|
param_img.dst_region.h = stampInfo->Img.ph[0];
|
|
param_img.dst_region.x = (*x_curr_ofs - padding - param_img.dst_region.w);
|
|
param_img.dst_region.y = param_img.dst_img.dim.h - param_img.dst_region.h;
|
|
|
|
vf_gfx_scale(¶m_img, 1);
|
|
hd_common_mem_free(pa, va);
|
|
*x_curr_ofs = param_img.dst_region.x;
|
|
}
|
|
|
|
#define LV_USER_FONT_CONV_ALIGN_W 8
|
|
#define LV_USER_FONT_CONV_ALIGN_H 2
|
|
|
|
/* YUV color key */
|
|
#define CKEY_Y 0x0
|
|
#define CKEY_U 0x80
|
|
#define CKEY_V 0x80
|
|
|
|
void UiDateImprint_AttachICON(DS_STAMP_INFOR *stampInfo, HD_VIDEO_FRAME* Img, lv_plugin_res_id res_id, bool enable_ckey, UINT32 padding, UINT32* x_curr_ofs)
|
|
{
|
|
HD_VIDEO_PXLFMT out_fmt = HD_VIDEO_PXLFMT_YUV420;
|
|
HD_VIDEO_FRAME src_img;
|
|
void *va;
|
|
UINT32 pa;
|
|
HD_RESULT ret;
|
|
HD_COMMON_MEM_DDR_ID ddr_id = DDR_ID0;
|
|
|
|
/******************************************************************************
|
|
* Stamp image
|
|
******************************************************************************/
|
|
|
|
lv_user_font_conv_draw_cfg draw_cfg = {0};
|
|
lv_user_font_conv_calc_buffer_size_result buff_size = {0};
|
|
lv_user_font_conv_mem_cfg mem_cfg = {0};
|
|
|
|
lv_user_font_conv_draw_cfg_init(&draw_cfg);
|
|
|
|
draw_cfg.align_w = LV_USER_FONT_CONV_ALIGN_W;
|
|
draw_cfg.align_h = LV_USER_FONT_CONV_ALIGN_H;
|
|
draw_cfg.fmt = out_fmt;
|
|
draw_cfg.mode = LV_USER_FONT_CONV_DRAW_IMG;
|
|
#if LV_COLOR_DEPTH == 8
|
|
extern uint32_t palette_define[];
|
|
draw_cfg.img.palette = palette_define;
|
|
#else
|
|
draw_cfg.img.palette = NULL;
|
|
#endif
|
|
draw_cfg.img.id = res_id;
|
|
|
|
draw_cfg.enable_ckey = enable_ckey;
|
|
draw_cfg.key_y = CKEY_Y;
|
|
draw_cfg.key_u = CKEY_U;
|
|
draw_cfg.key_v = CKEY_V;
|
|
|
|
lv_user_font_conv_calc_buffer_size(&draw_cfg, &buff_size);
|
|
|
|
|
|
ret = hd_common_mem_alloc("stamp_icon", &pa, (void **)&va, buff_size.output_buffer_size, ddr_id);
|
|
if (ret != HD_OK) {
|
|
DBG_ERR("custom_stamp_buffer allocate failed\n\r");
|
|
}
|
|
else {
|
|
mem_cfg.output_buffer = va;
|
|
mem_cfg.output_buffer_size = buff_size.output_buffer_size;
|
|
}
|
|
|
|
/***********************************************************
|
|
* draw image
|
|
**********************************************************/
|
|
|
|
VF_GFX_SCALE param_img = {0};
|
|
|
|
lv_user_font_conv(&draw_cfg, &mem_cfg);
|
|
|
|
lv_user_font_conv_cfg_to_hd_frame(
|
|
&draw_cfg,
|
|
&mem_cfg,
|
|
buff_size.width,
|
|
buff_size.height,
|
|
&src_img
|
|
);
|
|
|
|
memset(¶m_img, 0, sizeof(param_img));
|
|
param_img.quality = HD_GFX_SCALE_QUALITY_NULL;
|
|
param_img.src_img = src_img;
|
|
param_img.src_region.x = 0;
|
|
param_img.src_region.y = 0;
|
|
param_img.src_region.w = src_img.dim.w;
|
|
param_img.src_region.h = src_img.dim.h;
|
|
param_img.engine = 0;
|
|
param_img.dst_img = *Img;
|
|
param_img.dst_region.w = (src_img.dim.w / src_img.dim.h) * stampInfo->Img.ph[0];
|
|
param_img.dst_region.h = stampInfo->Img.ph[0];
|
|
DBG_IND("[%s:%d]padding=%d,param_img.dst_region.w=%d,stampInfo->PosY=%d\n", __FUNCTION__, __LINE__, padding, param_img.dst_region.w, stampInfo->PosY);
|
|
// if(res_id == LV_PLUGIN_IMG_ID_ICON_10234_GPS)
|
|
// {
|
|
// param_img.dst_region.x = ALIGN_FLOOR_8(*x_curr_ofs - param_img.dst_region.w);
|
|
// }
|
|
// else
|
|
{
|
|
param_img.dst_region.x = (*x_curr_ofs - padding - param_img.dst_region.w);
|
|
}
|
|
param_img.dst_region.y = stampInfo->PosY;
|
|
|
|
vf_gfx_scale(¶m_img, 1);
|
|
|
|
hd_common_mem_free(pa, va);
|
|
|
|
*x_curr_ofs = param_img.dst_region.x;
|
|
}
|
|
|
|
void UiDateImprint_AttachLogo(DS_STAMP_INFOR *stampInfo, HD_VIDEO_FRAME* Img)
|
|
{
|
|
extern const WATERLOGO_BUFFER g_WaterLogo_yuv420_486;
|
|
|
|
HD_RESULT ret;
|
|
VF_GFX_SCALE param = {0};
|
|
UINT32 pa;
|
|
void* va;
|
|
UINT32 blk_size = 0;
|
|
UINT8 ddr_id = DDR_ID0;
|
|
HD_VIDEO_FRAME logo = {0};
|
|
UINT32 lineoff[HD_VIDEO_MAX_PLANE] = {0};
|
|
UINT32 addr[HD_VIDEO_MAX_PLANE] = {0};
|
|
|
|
blk_size = (g_WaterLogo_yuv420_486.uiWidth * g_WaterLogo_yuv420_486.uiHeight * 3) / 2;
|
|
ret = hd_common_mem_alloc("jack", &pa, (void **)&va, blk_size, ddr_id);
|
|
if (ret != HD_OK) {
|
|
DBG_ERR("alloc fail size 0x%x, ddr %d\r\n", blk_size, ddr_id);
|
|
return;
|
|
}
|
|
|
|
memcpy(va,(void*) g_WaterLogo_yuv420_486.uiWaterLogoAddr, blk_size);
|
|
|
|
lineoff[0] = g_WaterLogo_yuv420_486.uiWidth;
|
|
lineoff[1] = g_WaterLogo_yuv420_486.uiWidth;
|
|
addr[0] = pa;
|
|
addr[1] = addr[0] + (lineoff[0] * g_WaterLogo_yuv420_486.uiHeight);
|
|
vf_init_ex(&logo, g_WaterLogo_yuv420_486.uiWidth, g_WaterLogo_yuv420_486.uiHeight, Img->pxlfmt, lineoff, addr);
|
|
|
|
DBG_IND("[%s:%d]Img->dim.w=%d, Img->dim.h=%d\n", __FUNCTION__, __LINE__, Img->dim.w, Img->dim.h);
|
|
|
|
param.quality = HD_GFX_SCALE_QUALITY_NULL;
|
|
param.src_img = logo;
|
|
param.src_region.x = 0;
|
|
param.src_region.y = 0;
|
|
param.src_region.w = g_WaterLogo_yuv420_486.uiWidth;
|
|
param.src_region.h = g_WaterLogo_yuv420_486.uiHeight;
|
|
param.engine = 0;
|
|
param.dst_img = *Img;
|
|
param.dst_region.x = 0;
|
|
param.dst_region.y = Img->dim.h - stampInfo->Img.ph[0];
|
|
param.dst_region.w = (g_WaterLogo_yuv420_486.uiWidth / g_WaterLogo_yuv420_486.uiHeight) * stampInfo->Img.ph[0];
|
|
param.dst_region.h = stampInfo->Img.ph[0];
|
|
|
|
DBG_IND("[%s:%d]param.dst_region:%d %d %d %d\n", __FUNCTION__, __LINE__, param.dst_region.x, param.dst_region.y, param.dst_region.w, param.dst_region.h);
|
|
vf_gfx_scale(¶m, 1);
|
|
|
|
hd_common_mem_free(pa, va);
|
|
}
|
|
|
|
#if HUNTING_CAMERA_MCU == ENABLE
|
|
|
|
unsigned long DayCode[12]= {0,31,59,90,120,151,181,212,243,273,304,334};
|
|
unsigned long DayCode_Leap[12]= {0,31,60,91,121,152,182,213,244,274,305,335};
|
|
|
|
UINT8 sf_solar_to_Lunar(UINT16 Year,UINT8 Month, UINT8 Day)
|
|
{
|
|
float temp = 0,Tempnum = 0;
|
|
UINT32 tempn = 0,tempQ = 0,tempR = 0,LunarDay = 0;
|
|
UINT32 LunarDaytemp = 0;
|
|
|
|
if(Year>=2000)
|
|
Year=Year-2000;
|
|
|
|
if (Year<21)
|
|
{
|
|
UINT16 wMonthAdd[12] = {0,31,59,90,120,151,181,212,243,273,304,334};
|
|
|
|
UINT32 wNongliData[100] =
|
|
{
|
|
2635,333387,1701,1748,267701,694,2391,133423,1175,396438
|
|
,3402,3749,331177,1453,694,201326,2350,465197,3221,3402
|
|
,400202,2901,1386,267611,605,2349,137515,2709,464533,1738
|
|
,2901,330421,1242,2651,199255,1323,529706,3733,1706,398762
|
|
,2741,1206,267438,2647,1318,204070,3477,461653,1386,2413
|
|
,330077,1197,2637,268877,3365,531109,2900,2922,398042,2395
|
|
,1179,267415,2635,661067,1701,1748,398772,2742,2391,330031
|
|
,1175,1611,200010,3749,527717,1452,2742,332397,2350,3222
|
|
,268949,3402,3493,133973,1386,464219,605,2349,334123,2709
|
|
,2890,267946,2773,592565,1210,2651,395863,1323,2707,265877
|
|
};
|
|
|
|
UINT16 wCurYear;
|
|
UINT8 wCurMonth,wCurDay;
|
|
int nIsEnd,m,k,n,i;
|
|
UINT16 nTheDate,nBit;
|
|
//static int wCurYear,wCurMonth,wCurDay;
|
|
//static int nTheDate,nIsEnd,m,k,n,i,nBit;
|
|
|
|
wCurYear = Year+2000;
|
|
wCurMonth = Month;
|
|
wCurDay = Day;
|
|
|
|
nTheDate = (wCurYear - 1921) * 365 + (wCurYear - 1921) / 4 + wCurDay +
|
|
wMonthAdd[wCurMonth - 1] - 38;
|
|
|
|
if((!(wCurYear % 4)) && (wCurMonth > 2))
|
|
nTheDate = nTheDate + 1;
|
|
|
|
nIsEnd = 0;
|
|
m = 0;
|
|
while(nIsEnd != 1)
|
|
{
|
|
if(wNongliData[m] < 4095)
|
|
k = 11;
|
|
else
|
|
k = 12;
|
|
n = k;
|
|
while(n>=0)
|
|
{
|
|
nBit = wNongliData[m];
|
|
|
|
for(i=1; i<n+1; i++) //
|
|
nBit = nBit/2;
|
|
|
|
nBit = nBit % 2;
|
|
|
|
if (nTheDate <= (29 + nBit))
|
|
{
|
|
nIsEnd = 1;
|
|
break;
|
|
}
|
|
|
|
nTheDate = nTheDate - 29 - nBit;
|
|
n = n - 1;
|
|
}
|
|
|
|
if(nIsEnd)
|
|
break;
|
|
|
|
m = m + 1;
|
|
}
|
|
|
|
wCurYear = 1921 + m;
|
|
wCurMonth = k - n + 1;
|
|
wCurDay = nTheDate;
|
|
|
|
LunarDay=wCurDay ;
|
|
}// new code
|
|
else
|
|
{
|
|
|
|
if(Year<=100)
|
|
Year=Year+2000;
|
|
|
|
if (((Year% 400) == 0) || ((Year% 4) != 0))
|
|
{
|
|
temp=DayCode[Month-1]+Day;
|
|
|
|
}
|
|
else
|
|
{
|
|
temp=DayCode_Leap[Month-1]+Day;
|
|
|
|
}
|
|
// UI_PrintOSDNumber(temp, 2, 0, 4);
|
|
// UI_PrintOSDNumber(Year, 10, 0, 4);
|
|
tempQ=(Year-1977)/4;
|
|
tempR=(Year-1977)%4;
|
|
// UI_PrintOSDNumber(tempQ, 2, 2, 4);
|
|
// UI_PrintOSDNumber(tempR, 2, 3, 4);
|
|
Tempnum=14*tempQ+10.6*(tempR+1)+temp;
|
|
// UI_PrintOSDNumber(temp, 2, 4, 4);
|
|
tempn=Tempnum/29.5;
|
|
// UI_PrintOSDNumber(Tempnum, 2, 5, 4);
|
|
LunarDaytemp=(Tempnum-tempn*29.5)*10;
|
|
if(LunarDaytemp%10>=5)
|
|
LunarDay=(Tempnum-tempn*29.5)+1;
|
|
else if (LunarDaytemp%1000<10)
|
|
LunarDay=30;
|
|
else if (LunarDaytemp%1000>300)
|
|
LunarDay=1;
|
|
else
|
|
LunarDay=Tempnum-tempn*29.5;
|
|
// UI_PrintOSDNumber(LunarDay, 2, 6, 4);
|
|
}
|
|
|
|
return LunarDay;
|
|
}
|
|
|
|
void sf_get_gps_info_str(UINT8 *str, UINT8 type)
|
|
{
|
|
UINT32 i = 0;
|
|
UIMenuStoreInfo *puiPara = sf_ui_para_get();
|
|
|
|
DBG_IND("[%s:%d]puiPara->GpsSwitch=%d,puiPara->Latitude:%s,puiPara->Longitude:%s\n",
|
|
__FUNCTION__, __LINE__, puiPara->GpsSwitch, puiPara->Latitude, puiPara->Longitude);
|
|
if(puiPara->GpsSwitch == SF_ON)
|
|
{
|
|
if((puiPara->Latitude[0] == '\0') || (puiPara->Longitude[0] == '\0'))
|
|
{
|
|
str[0] = '\0';
|
|
}
|
|
else if(type == 1)
|
|
{
|
|
str[i++] = puiPara->Latitude[9];
|
|
str[i++] = puiPara->Latitude[0];
|
|
str[i++] = puiPara->Latitude[1];
|
|
str[i++] = 0xC2;
|
|
str[i++] = 0xB0;
|
|
str[i++] = puiPara->Latitude[2];
|
|
str[i++] = puiPara->Latitude[3];
|
|
str[i++] = 0x27; // '
|
|
str[i++] = puiPara->Latitude[5];
|
|
str[i++] = puiPara->Latitude[6];
|
|
str[i++] = 0x22; // "
|
|
str[i++] = ' ';
|
|
str[i++] = puiPara->Longitude[10];
|
|
str[i++] = puiPara->Longitude[0];
|
|
str[i++] = puiPara->Longitude[1];
|
|
str[i++] = puiPara->Longitude[2];
|
|
str[i++] = 0xC2;
|
|
str[i++] = 0xB0;
|
|
str[i++] = puiPara->Longitude[3];
|
|
str[i++] = puiPara->Longitude[4];
|
|
str[i++] = 0x27; // '
|
|
str[i++] = puiPara->Longitude[6];
|
|
str[i++] = puiPara->Longitude[7];
|
|
str[i++] = 0x22; // "
|
|
str[i++] = '\0';
|
|
}
|
|
else if(type == 2)
|
|
{
|
|
str[i++] = puiPara->Latitude[9];
|
|
str[i++] = puiPara->Latitude[0];
|
|
str[i++] = puiPara->Latitude[1];
|
|
str[i++] = 0x2A;
|
|
str[i++] = puiPara->Latitude[2];
|
|
str[i++] = puiPara->Latitude[3];
|
|
str[i++] = 0x27; // '
|
|
str[i++] = puiPara->Latitude[5];
|
|
str[i++] = puiPara->Latitude[6];
|
|
str[i++] = 0x22; // "
|
|
str[i++] = ' ';
|
|
str[i++] = puiPara->Longitude[10];
|
|
str[i++] = puiPara->Longitude[0];
|
|
str[i++] = puiPara->Longitude[1];
|
|
str[i++] = puiPara->Longitude[2];
|
|
str[i++] = 0x2A;
|
|
str[i++] = puiPara->Longitude[3];
|
|
str[i++] = puiPara->Longitude[4];
|
|
str[i++] = 0x27; // '
|
|
str[i++] = puiPara->Longitude[6];
|
|
str[i++] = puiPara->Longitude[7];
|
|
str[i++] = 0x22; // "
|
|
str[i++] = '\0';
|
|
}
|
|
else if(type == 3)
|
|
{
|
|
str[i++] = puiPara->Latitude[9];
|
|
str[i++] = puiPara->Latitude[0];
|
|
str[i++] = puiPara->Latitude[1];
|
|
str[i++] = '.';
|
|
str[i++] = puiPara->Latitude[2];
|
|
str[i++] = puiPara->Latitude[3];
|
|
str[i++] = '.';
|
|
str[i++] = puiPara->Latitude[5];
|
|
str[i++] = puiPara->Latitude[6];
|
|
str[i++] = '-';
|
|
|
|
str[i++] = puiPara->Longitude[10];
|
|
str[i++] = puiPara->Longitude[0];
|
|
str[i++] = puiPara->Longitude[1];
|
|
str[i++] = puiPara->Longitude[2];
|
|
str[i++] = '.';
|
|
str[i++] = puiPara->Longitude[3];
|
|
str[i++] = puiPara->Longitude[4];
|
|
str[i++] = '.';
|
|
str[i++] = puiPara->Longitude[6];
|
|
str[i++] = puiPara->Longitude[7];
|
|
str[i++] = '\0';
|
|
}
|
|
}
|
|
else
|
|
{
|
|
str[0] = '\0';
|
|
}
|
|
|
|
DBG_IND("[%s:%d]str:%s\n", __FUNCTION__, __LINE__, str);
|
|
return;
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
ER UiDateImprint_CopyData(DS_STAMP_INFOR *stampInfo,HD_VIDEO_FRAME* Img, UINT32 copyEngine)
|
|
{
|
|
ER ret =E_OK;
|
|
VF_GFX_COPY param ={0};
|
|
UINT8 customString[32] = {0};
|
|
INT32 year = 0, month = 0, day = 0;
|
|
UINT8 moonday = 0;
|
|
UINT8 batValue = 0;
|
|
|
|
UIMenuStoreInfo *puiPara = sf_ui_para_get();
|
|
|
|
if (stampInfo->StampWeight == 255)
|
|
{
|
|
|
|
VOS_TICK t1, t2;
|
|
UINT32 padding = stampInfo->Img.ph[0];
|
|
UINT32 x_curr_ofs = stampInfo->PosX; /* start from date stamp */
|
|
|
|
DBG_IND("[%s:%d]padding=%d\n", __FUNCTION__, __LINE__, padding);
|
|
|
|
vos_perf_mark(&t1);
|
|
|
|
//draw stamp background.
|
|
UiDateImprint_DrawBG(stampInfo, Img);
|
|
|
|
|
|
//moon stamp
|
|
year = DateTime_Get(DATETIME_YEAR);
|
|
month = DateTime_Get(DATETIME_MONTH);
|
|
day = DateTime_Get(DATETIME_DAY);
|
|
DBG_IND("[%s:%d]get date time:%04d %02d %02d\n", __FUNCTION__, __LINE__, year, month, day);
|
|
moonday = (sf_solar_to_Lunar(year, month, day)) - 1;
|
|
UiDateImprint_AttachICON(stampInfo, Img, (LV_PLUGIN_IMG_ID_ICON_10200_MOON + moonday), true, padding, &x_curr_ofs);
|
|
|
|
//battery stamp
|
|
batValue = sf_cardv_battery_level_get();
|
|
if(batValue < SF_BATT_LEVEL_1)
|
|
{
|
|
batValue = 1;
|
|
}
|
|
batValue -= 1;
|
|
UiDateImprint_AttachICON(stampInfo, Img, (LV_PLUGIN_IMG_ID_ICON_10230_BATTERT + batValue), true, padding, &x_curr_ofs);
|
|
|
|
DBG_IND("[%s:%d]moon id=%d,battery id=%d\n", __FUNCTION__, __LINE__,
|
|
(LV_PLUGIN_IMG_ID_ICON_10200_MOON + moonday), (LV_PLUGIN_IMG_ID_ICON_10230_BATTERT + batValue));
|
|
|
|
//camid stamp
|
|
if((puiPara->CamNameSwitch == SF_CAMID_ON) && (puiPara->CamNameStr[0] != '\0'))
|
|
{
|
|
snprintf((char *)customString, sizeof(customString), "%s", puiPara->CamNameStr);
|
|
DBG_IND("[%s:%d]customString=%s\n", __FUNCTION__, __LINE__, customString);
|
|
UiDateImprint_AttachString(stampInfo, Img, customString, true, padding, &x_curr_ofs);
|
|
}
|
|
|
|
//gps stamp
|
|
//sprintf((char *)puiPara->Latitude, "3458.3100N");
|
|
//sprintf((char *)puiPara->Longitude, "12294.4200E");
|
|
sf_get_gps_info_str(customString, 1);
|
|
if(0/*(puiPara->GpsSwitch == SF_ON) && (customString[0] != '\0')*/)
|
|
{
|
|
if(customString[0] != '\0')
|
|
{
|
|
//snprintf((char *)customString, sizeof(customString), "N22%c%c34'57\" E113%c%c55'19\"", 0xC2, 0xB0, 0xC2, 0xB0);
|
|
DBG_IND("[%s:%d]customString=%s\n", __FUNCTION__, __LINE__, customString);
|
|
UiDateImprint_AttachString(stampInfo, Img, customString, true, padding, &x_curr_ofs);
|
|
}
|
|
|
|
// UiDateImprint_AttachICON(stampInfo, Img, LV_PLUGIN_IMG_ID_ICON_10234_GPS, true, padding, &x_curr_ofs);
|
|
}
|
|
|
|
//logo stamp
|
|
UiDateImprint_AttachLogo(stampInfo, Img);
|
|
|
|
vos_perf_mark(&t2);
|
|
|
|
DBG_DUMP("*** dur = %lu ms ***\n", vos_perf_duration(t1, t2));
|
|
|
|
param.src_img = stampInfo->Img;
|
|
param.src_region.x = 0;
|
|
param.src_region.y = 0;
|
|
param.src_region.w = stampInfo->Img.loff[0];
|
|
param.src_region.h = stampInfo->Img.ph[0];
|
|
param.dst_img = *Img;
|
|
param.dst_pos.x=stampInfo->PosX;
|
|
param.dst_pos.y=stampInfo->PosY;
|
|
param.colorkey=stampInfo->ColorKey;
|
|
param.engine=copyEngine;
|
|
param.alpha = 255;
|
|
|
|
ret = vf_gfx_copy(¶m);
|
|
}
|
|
else
|
|
{
|
|
DBG_ERR("Not support StampWeight = %d\r\n",stampInfo->StampWeight);
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
BOOL UiDateImprint_GenData(IMG_CAP_DATASTAMP_INFO *pCapInfo)
|
|
{
|
|
DATE_IMPRINT_INFO *pInfo;
|
|
//IMG_BUF Img = {0};
|
|
HD_VIDEO_FRAME Img = {0};
|
|
UINT32 LineOff[MAX_PLANE_NUM];
|
|
UINT32 PxlAddr[MAX_PLANE_NUM];
|
|
#if USE_DBG_STAMP
|
|
UINT32 time_start,time_end;
|
|
#endif
|
|
HD_RESULT hd_ret;
|
|
|
|
DBG_IND("event %d, width =%d, height =%d, line_ofs[0]=%d, line_ofs[1]=%d\r\n",pCapInfo->event,pCapInfo->ImgInfo.ch[0].width,pCapInfo->ImgInfo.ch[0].height,pCapInfo->ImgInfo.ch[0].line_ofs,pCapInfo->ImgInfo.ch[1].line_ofs);
|
|
|
|
pInfo = UiDateImprint_Event2Info(pCapInfo->event);
|
|
if (pInfo == NULL){
|
|
DBG_ERR("Unknown event %d\r\n",pCapInfo->event);
|
|
return FALSE;
|
|
}
|
|
UiDateImprint_Lock(pInfo->lockptn);
|
|
pInfo->pCapInfo = pCapInfo;
|
|
UiDateImprint_ChkUpdateData(pInfo);
|
|
DBG_IND("isStrDirty %d\r\n",pInfo->isStrDirty);
|
|
#if USE_DBG_STAMP
|
|
time_start = Perf_GetCurrent();
|
|
#endif
|
|
if (pInfo->isStrDirty) {
|
|
if (UiDateImprint_UpdateData(pInfo)!=E_OK){
|
|
return FALSE;
|
|
}
|
|
}
|
|
#if 0
|
|
GxImg_DumpBuf(&pYuvInfo->GenImg, TRUE);
|
|
#endif
|
|
PxlAddr[0] = pCapInfo->ImgInfo.pixel_addr[0];
|
|
PxlAddr[1] = pCapInfo->ImgInfo.pixel_addr[1];
|
|
LineOff[0] = pCapInfo->ImgInfo.ch[0].line_ofs;
|
|
LineOff[1] = pCapInfo->ImgInfo.ch[1].line_ofs;
|
|
|
|
if(PhotoExe_GetCapYUV420En()){
|
|
//gximg_init_buf_ex(&Img, pCapInfo->ImgInfo.ch[0].width, pCapInfo->ImgInfo.ch[0].height, GX_IMAGE_PIXEL_FMT_YUV420_PACKED, LineOff, PxlAddr);
|
|
if ((hd_ret = vf_init_ex(&Img, pCapInfo->ImgInfo.ch[0].width, pCapInfo->ImgInfo.ch[0].height, HD_VIDEO_PXLFMT_YUV420, LineOff, PxlAddr)) != HD_OK) {
|
|
DBG_ERR("vf_init_ex 420 failed(%d)\r\n", hd_ret);
|
|
}
|
|
}else{
|
|
//gximg_init_buf_ex(&Img, pCapInfo->ImgInfo.ch[0].width, pCapInfo->ImgInfo.ch[0].height, GX_IMAGE_PIXEL_FMT_YUV422_PACKED, LineOff, PxlAddr);
|
|
if ((hd_ret = vf_init_ex(&Img, pCapInfo->ImgInfo.ch[0].width, pCapInfo->ImgInfo.ch[0].height, HD_VIDEO_PXLFMT_YUV422, LineOff, PxlAddr)) != HD_OK) {
|
|
DBG_ERR("vf_init_ex 422 failed(%d)\r\n", hd_ret);
|
|
}
|
|
}
|
|
//DBG_ERR("Img.phy_addr=0x%x,0x%x,0x%x\r\n",Img.phy_addr[0],Img.phy_addr[1],Img.phy_addr[2]);
|
|
|
|
#if 1
|
|
UiDateImprint_CopyData(&pInfo->StampInfo,&Img,pInfo->copyEngine);
|
|
#else
|
|
IRECT srcRegion;
|
|
srcRegion.x = pInfo->StampInfo.PosX;
|
|
srcRegion.y = pInfo->StampInfo.PosY;
|
|
srcRegion.w = pInfo->StampInfo.Img.loff[0];
|
|
srcRegion.h = pInfo->StampInfo.Img.ph[0];
|
|
VF_GFX_COPY param ={0};
|
|
#if 0
|
|
param.src_img=Img;
|
|
param.src_region.x=srcRegion.x;
|
|
param.src_region.y=srcRegion.y;
|
|
param.src_region.w=srcRegion.w;
|
|
param.src_region.h=srcRegion.h;
|
|
param.dst_img=pInfo->StampInfo.Img;
|
|
|
|
param.dst_pos.x=0;
|
|
param.dst_pos.y=0;
|
|
#else
|
|
param.src_img=pInfo->StampInfo.Img;
|
|
param.src_region.x=0;
|
|
param.src_region.y=0;
|
|
param.src_region.w=srcRegion.w;
|
|
param.src_region.h=srcRegion.h;
|
|
|
|
param.dst_img=Img;
|
|
param.dst_pos.x=pInfo->StampInfo.PosX;
|
|
param.dst_pos.y=pInfo->StampInfo.PosY;
|
|
#endif
|
|
param.colorkey=pInfo->StampInfo.ColorKey;
|
|
param.engine=pInfo->copyEngine;
|
|
|
|
//DBG_ERR("param.src_img.phy_addr=0x%x,0x%x,0x%x\r\n",param.src_img.phy_addr[0],param.src_img.phy_addr[1],param.src_img.phy_addr[2]);
|
|
|
|
#if 0
|
|
{
|
|
FST_FILE hFile = NULL;
|
|
UINT32 filesize;
|
|
char filenamey[32]={0};
|
|
static UINT32 count=0;
|
|
sprintf(filenamey,"A:\\test_STASY_%d.RAW",count);
|
|
count++;
|
|
DBG_DUMP("wxh=%dx%d,loff=%d, %s...\r\n", param.dst_img.pw[0], param.dst_img.ph[0],param.dst_img.loff[0],filenamey);
|
|
filesize = param.dst_img.loff[0]*param.dst_img.ph[0];
|
|
hFile = FileSys_OpenFile(filenamey, FST_CREATE_ALWAYS | FST_OPEN_WRITE);
|
|
FileSys_WriteFile(hFile, (UINT8 *)param.dst_img.phy_addr[0], &filesize, 0, NULL);
|
|
FileSys_CloseFile(hFile);
|
|
}
|
|
#endif
|
|
//IRECT dst_region={388,440,240,20};
|
|
//gximg_fill_data((VDO_FRAME *)&(Img), GXIMG_REGION_MATCH_IMG, COLOR_YUV_RED);
|
|
//gximg_fill_data((VDO_FRAME *)&(param.dst_img), GXIMG_REGION_MATCH_IMG, COLOR_YUV_RED);
|
|
|
|
//ret = GxImg_CopyColorkeyData(Img,&srcRegion,&stampInfo->Img,REGION_MATCH_IMG,stampInfo->ColorKey,FALSE, copyEngine);
|
|
//ret = gximg_copy_color_key_data(Img,&srcRegion,&stampInfo->Img,GXIMG_REGION_MATCH_IMG,stampInfo->ColorKey,FALSE, copyEngine);
|
|
//vf_gfx_copy(¶m);
|
|
vf_gfx_I8_colorkey(¶m);
|
|
#endif
|
|
|
|
|
|
#if USE_DBG_STAMP
|
|
time_end = Perf_GetCurrent();
|
|
DBG_DUMP("Time Use = %d ms\r\n", (time_end-time_start) / 1000);
|
|
#endif
|
|
UiDateImprint_UnLock(pInfo->lockptn);
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
|
|
|