1.Rtos视频水印改为与图片水印一致;

This commit is contained in:
payton 2023-12-04 14:29:00 +08:00
parent 50c9d9e839
commit e33afe0f54
4 changed files with 356 additions and 8 deletions

View File

@ -47,7 +47,7 @@
//..............................................................................
// FW version and name
#define FW_UPDATE_NAME "A:\\FW98565Z.bin"
#define FW_UPDATE_NAME "A:\\FW98565A.bin"
#define FW_VERSION_RELEASE DISABLE //DISABLE
#define FW_VERSION_NUM "REGULAR_0402_001"
@ -1053,8 +1053,9 @@
/* please always fill ARGB8888, alpha channel will be discarded if output format is yuv (Photo UIDateImprint) */
#define LV_USER_CFG_STAMP_COLOR_TEXT 0xFFFFFFFF /* text color */
#define LV_USER_CFG_STAMP_COLOR_BACKGROUND 0XFF000000 /* background color: black */
#define LV_USER_CFG_MOVIE_DATESTAMP_COLOR_BACKGROUND 0X00000000 /* background color: none */
#define LV_USER_CFG_MOVIE_DATESTAMP_COLOR_BACKGROUND 0XFF000000 /* background color: none */
#define LV_USER_CFG_STAMP_COLOR_FRAME 0x00000000 /* frame color */
#define LV_USER_CFG_MOVIE_STAMP_COLOR_BACKGROUND 0XF000 /* background color: black */
/*******************************************************************************************
* Enable LVGL rotate depend on VDO_USE_ROTATE_BUFFER (LV_USE_GPU_NVT_DMA2D in the lv_conf.h should be enabled)

View File

@ -20,6 +20,7 @@
#include "GxTime.h"
#include "hd_type.h"
#include "sys_fwload.h"
#include "sf_battery.h"
#if MOVIE_ISP_LOG
#include "vendor_isp.h"
@ -141,6 +142,7 @@ static UINT32 g_MultiWaterLogoVEncHDPathId[VENC_OUT_PORTID_MAX][MOVIE_MULTI_WATE
#define LV_USER_FONT_CONV_ALIGN_W 8
#define LV_USER_FONT_CONV_ALIGN_H 2
#define LV_USER_ICON_CONV_ALIGN_W 2
static inline uint32_t lv_color4444_to32(lv_user_color4444_t color)
{
@ -996,15 +998,283 @@ UINT32 MovieStamp_CalcBufSize(UINT32 Width, UINT32 Height, WATERLOGO_BUFFER *pWa
return BufSize;
}
#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 0x88
#define CKEY_V 0x88
void MovieStamp_SelStampFont(UINT32 uiImageWidth, lv_font_t** font)
{
lv_plugin_res_id red_id;
if (uiImageWidth >= 3840) {
red_id = LV_USER_CFG_STAMP_FONT_ID_XXL;
}
else if(uiImageWidth >=3600) {
red_id = LV_USER_CFG_STAMP_FONT_ID_XXL;
}
else if(uiImageWidth >=3200) {
red_id = LV_USER_CFG_STAMP_FONT_ID_XL;
}
else if(uiImageWidth >=2880) {
red_id = LV_USER_CFG_STAMP_FONT_ID_XL;
}
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 >=640) {
red_id = LV_USER_CFG_STAMP_FONT_ID_SMALL;
}
else if(uiImageWidth >=320) {
red_id = LV_USER_CFG_STAMP_FONT_ID_SMALL;
}
else {
red_id = LV_USER_CFG_STAMP_FONT_ID_XXL;
}
//printf("[%s:%d]uiImageWidth=%d,red_id=%d\n", __FUNCTION__, __LINE__, uiImageWidth, red_id);
*font = (lv_font_t*)lv_plugin_get_font(red_id)->font;
}
void MovieStamp_AttachString(
UINT32 stamp_height,
HD_VIDEO_FRAME* Img,
char* name,
lv_font_t* font,
bool enable_ckey,
UINT32 padding,
UINT32* x_curr_ofs)
{
VF_GFX_SCALE param_img = {0};
HD_VIDEO_FRAME src_img;
HD_VIDEO_PXLFMT out_fmt = HD_VIDEO_PXLFMT_ARGB4444;
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_color32_t color32;
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_TEXT;
draw_cfg.radius = LV_USER_CFG_STAMP_RADIUS;
draw_cfg.string.letter_space = LV_USER_CFG_STAMP_LETTER_SPACE;
draw_cfg.string.align = LV_USER_CFG_STAMP_TEXT_ALIGN;
draw_cfg.string.text = name;
draw_cfg.string.font = font;
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;
/* text color */
color32.full = LV_USER_CFG_STAMP_COLOR_TEXT;
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 = LV_USER_CFG_STAMP_COLOR_BACKGROUND;
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 = LV_USER_CFG_STAMP_COLOR_FRAME;
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;
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_string", &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(&param_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) * stamp_height;
param_img.dst_region.h = stamp_height;
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(&param_img, 1);
*x_curr_ofs = param_img.dst_region.x;
hd_common_mem_free(pa, va);
}
void MovieStamp_AttachICON(
UINT32 stamp_height,
UINT32 stamp_pos_y,
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_ARGB4444;
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_ICON_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
);
hd_common_mem_flush_cache(mem_cfg.output_buffer, mem_cfg.output_buffer_size);
memset(&param_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 * stamp_height/ src_img.dim.h);
param_img.dst_region.h = stamp_height;
param_img.dst_region.x = (*x_curr_ofs - padding - param_img.dst_region.w);
param_img.dst_region.y = stamp_pos_y;
vf_gfx_scale(&param_img, 1);
hd_common_mem_free(pa, va);
*x_curr_ofs = param_img.dst_region.x;
}
void sf_get_movie_resolution_ratio_str(char *movieRatioStr)
{
UIMenuStoreInfo *puiPara = sf_ui_para_get();
if(puiPara->VideoSize == MOVIE_SIZE_FRONT_1920x1080P30)
{
sprintf((char *)movieRatioStr, "1080P");
}
else if(puiPara->VideoSize == MOVIE_SIZE_FRONT_1280x720P30)
{
sprintf((char *)movieRatioStr, "720P");
}
else if(puiPara->VideoSize == MOVIE_SIZE_FRONT_848x480P30)
{
sprintf((char *)movieRatioStr, "WVGA");
}
else
{
sprintf((char *)movieRatioStr, "WVGA");
}
}
extern void sf_get_gps_info_str(UINT8 *str, UINT8 type);
void MovieStamp_CombineStamp(UINT32 vid_in, UINT32 bg_color)
{
UINT32 size;
UINT32 combined_stamp_w = g_ImageSize[vid_in].w;
UINT32 combined_stamp_h = g_VsOsdHight[vid_in];
UINT32 combined_stamp_pos_y = 0;
size = combined_stamp_w * combined_stamp_h * 2; /* ARGB4444 */
HD_COMMON_MEM_VIRT_INFO vir_info = {0};
UINT32 padding = 20;
UINT32 x_curr_ofs = 0; /* start from date stamp */
HD_VIDEO_FRAME Img = {0};
UINT32 lineoff[HD_VIDEO_MAX_PLANE] = {0};
UINT32 addr[HD_VIDEO_MAX_PLANE] = {0};
char name[16];
INT16 cTemper = 0;
INT16 fTemper = 0;
char customString[32] = {0};
INT32 year = 0, month = 0, day = 0;
UINT8 moonday = 0;
UINT8 batValue = 0;
sprintf(name, "mov_stamp%lu", vid_in);
@ -1019,7 +1289,11 @@ void MovieStamp_CombineStamp(UINT32 vid_in, UINT32 bg_color)
memset((void *)combined_stamp_addr[vid_in].pool_va, 0, size);
/* draw bg */
lineoff[0] = combined_stamp_w * 2;
addr[0] = combined_stamp_addr[vid_in].pool_pa;
vf_init_ex(&Img, combined_stamp_w, combined_stamp_h, HD_VIDEO_PXLFMT_ARGB4444, lineoff, addr);
//draw stamp background.
HD_GFX_DRAW_RECT rect = {0};
rect.color = bg_color;
@ -1033,7 +1307,7 @@ void MovieStamp_CombineStamp(UINT32 vid_in, UINT32 bg_color)
rect.dst_img.p_phy_addr[0] = combined_stamp_addr[vid_in].pool_pa; /* argb4444 accept virtual address */
hd_gfx_draw_rect(&rect);
/* copy date stamp to bg */
/*date stamp*/
HD_GFX_COPY copy = {0};
copy.alpha = 255;
copy.colorkey = 0;
@ -1055,7 +1329,7 @@ void MovieStamp_CombineStamp(UINT32 vid_in, UINT32 bg_color)
copy.src_region = (HD_IRECT) {0, 0, copy.src_img.dim.w, copy.src_img.dim.h};
hd_gfx_copy(&copy);
/* copy water logo to bg */
/*water logo*/
UINT32 water_size = g_MovieWaterInfo[vid_in].uiWidth * g_MovieWaterInfo[vid_in].uiHeight * 2;
if(water_logo_addr[vid_in].pool_va == 0){
@ -1090,6 +1364,79 @@ void MovieStamp_CombineStamp(UINT32 vid_in, UINT32 bg_color)
scale.dst_region.y = 0;
hd_gfx_scale(&scale);
x_curr_ofs = combined_stamp_w - g_VsFontOut[vid_in].GenImg.dim.w;
/*temperature stamp*/
lv_font_t* font = NULL;
MovieStamp_SelStampFont(combined_stamp_w, &font);
sf_stamp_temperature_get(&fTemper, &cTemper);
snprintf((char *)customString, sizeof(customString), "%d%c%cF %d%c%cC", fTemper, 0xC2, 0xB0, cTemper, 0xC2, 0xB0);
//printf("[%s:%d]customString=%s\n", __FUNCTION__, __LINE__, customString);
MovieStamp_AttachString(combined_stamp_h, &Img, customString, font, false, padding, &x_curr_ofs);
/*moon stamp*/
year = DateTime_Get(DATETIME_YEAR);
month = DateTime_Get(DATETIME_MONTH);
day = DateTime_Get(DATETIME_DAY);
//printf("[%s:%d]get date time:%04d %02d %02d\n", __FUNCTION__, __LINE__, year, month, day);
moonday = (sf_solar_to_Lunar(year, month, day)) - 1;
MovieStamp_AttachICON(
combined_stamp_h,
combined_stamp_pos_y,
&Img,
LV_PLUGIN_IMG_ID_ICON_10200_MOON + moonday,
false,
padding,
&x_curr_ofs);
//battery stamp
batValue = sf_battery_level_get();
if(batValue < SF_BATT_LEVEL_1)
{
batValue = 0;
}
else
{
batValue -= 1;
}
MovieStamp_AttachICON(
combined_stamp_h,
combined_stamp_pos_y,
&Img,
LV_PLUGIN_IMG_ID_ICON_10230_BATTERT + batValue,
false,
padding,
&x_curr_ofs);
/*printf("[%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));*/
//ratio stamp
//sf_get_movie_resolution_ratio_str(customString);
//printf("[%s:%d]customString=%s\n", __FUNCTION__, __LINE__, customString);
//MovieStamp_AttachString(combined_stamp_h, &Img, customString, font, false, padding, &x_curr_ofs);
//gps stamp
//sprintf((char *)puiPara->Latitude, "3458.3100N");
//sprintf((char *)puiPara->Longitude, "12294.4200E");
// sf_get_gps_info_str((UINT8*)customString, 1);
// if((puiPara->GpsSwitch == SF_ON) && (customString[0] != '\0'))
// {
// //snprintf((char *)customString, sizeof(customString), "N22%c%c34'57\" E113%c%c55'19\"", 0xC2, 0xB0, 0xC2, 0xB0);
// //printf("[%s:%d]customString=%s\n", __FUNCTION__, __LINE__, customString);
// MovieStamp_AttachString(combined_stamp_h, &Img, customString, font, false, padding, &x_curr_ofs);
// MovieStamp_AttachICON(
// combined_stamp_h,
// combined_stamp_pos_y,
// &Img,
// LV_PLUGIN_IMG_ID_ICON_10235_GPS,
// false,
// padding,
// &x_curr_ofs);
// }
hd_common_mem_flush_cache((void *)combined_stamp_addr[vid_in].pool_va, size);
}
@ -1211,7 +1558,7 @@ void MovieStamp_UpdateData(void)
//DBG_DUMP("i=%d, w=%d, %d, %d\r\n", i,g_VsOsdWidth[i], g_VsOsdHight[i],g_VsFontOut[i].GenImg.loff[0]);
//MovieStamp_VsUpdateOsd(i, TRUE, 1, g_MovieStampPos[i].uiX, g_MovieStampPos[i].uiY, g_VsOsdWidth[i], g_VsOsdHight[i], (void*)g_pVsFontDataAddr[i]);
MovieStamp_CombineStamp(i, 0x0);
MovieStamp_CombineStamp(i, LV_USER_CFG_MOVIE_STAMP_COLOR_BACKGROUND);
// update 1st stamp
// if(MovieStamp_VsUpdateOsd(g_VEncHDPathId[i], TRUE, MOVIE_STAMP_LAYER1, VS_DATESTAMP_REGION, g_MovieStampPos[i].uiX, g_MovieStampPos[i].uiY, g_VsOsdWidth[i], g_VsOsdHight[i], (void*)g_pVsFontDataAddr[i])){

View File

@ -14,7 +14,7 @@ static BOOL g_bMovieStampTskClosing = FALSE;
static MOVIESTAMP_UPDATE_CB g_MovieStampUpdateCb = NULL;
static MOVIESTAMP_TRIGGER_UPDATE_CHECK_CB g_MovieStampTrigUpdateChkCb = NULL;
#define PRI_MOVIESTAMP 9//10
#define STKSIZE_MOVIESTAMP 4096
#define STKSIZE_MOVIESTAMP 8192
ER MovieStampTsk_Open(void)
{

View File

@ -481,7 +481,7 @@ ER lv_user_font_conv_cfg_to_hd_frame(
switch(cfg->fmt)
{
case HD_VIDEO_PXLFMT_ARGB4444:
loff[0] = (width * height * HD_VIDEO_PXLFMT_BPP(cfg->fmt)) / 8;
loff[0] = width * 2;
loff[1] = 0;
break;