1.修复rtos下水印问题

This commit is contained in:
payton 2023-11-06 09:51:50 +08:00
parent 87feaba1d0
commit 00504f1031
2 changed files with 64 additions and 36 deletions

View File

View File

@ -80,6 +80,25 @@ static UINT32 PhotoFast_SliceEncode_Get_Encode_Max_Bitrate(HD_VIDEO_PXLFMT vproc
static INT32 PhotoFast_SliceEncode_Get_Comm_Buffer(PhotoFast_MEM_Info* mem_info); static INT32 PhotoFast_SliceEncode_Get_Comm_Buffer(PhotoFast_MEM_Info* mem_info);
static INT32 PhotoFast_SliceEncode_Release_Comm_Buffer(PhotoFast_MEM_Info mem_info); static INT32 PhotoFast_SliceEncode_Release_Comm_Buffer(PhotoFast_MEM_Info mem_info);
static INT32 PhotoFast_SliceEncode_Encode_Screennail(HD_VIDEO_FRAME* video_frame_in); static INT32 PhotoFast_SliceEncode_Encode_Screennail(HD_VIDEO_FRAME* video_frame_in);
#if PHOTOFAST_FAST_STAMP == ENABLE
INT32 PhotoFastCapDateImprint_Src_GenYuvData(
HD_VIDEO_FRAME *video_frame,
PhotoFast_SliceSize_Info* src_slice_info,
PhotoFast_SliceSize_Info* dst_slice_info)
{
HD_VIDEO_FRAME video_frame_src_stamp = *video_frame;
UINT32 dst_last_slice_scale_height = (src_slice_info->last_slice_height * dst_slice_info->slice_height) / src_slice_info->slice_height;
if(dst_last_slice_scale_height > dst_slice_info->last_slice_height)
{
video_frame_src_stamp.dim.h = video_frame_src_stamp.dim.h - ((src_slice_info->last_slice_height * (dst_last_slice_scale_height - dst_slice_info->last_slice_height)) / dst_last_slice_scale_height);
video_frame_src_stamp.ph[0] = video_frame_src_stamp.dim.h;
video_frame_src_stamp.ph[1] = video_frame_src_stamp.dim.h;
}
return PhotoFastCapDateImprint_GenYuvData(&video_frame_src_stamp);
}
#endif
static UINT32 PhotoFast_PHY2VIRT(UINT32 pa_pos, UINT32 pa_start, UINT32 va) static UINT32 PhotoFast_PHY2VIRT(UINT32 pa_pos, UINT32 pa_start, UINT32 va)
{ {
@ -187,7 +206,8 @@ INT32 PhotoFast_SliceEncode_Get_Curr_Dst_Slice_Info(PhotoFast_SliceSize_Info *in
PHOTOFAST_SLICE_ENC_DUMP("cap_size = %lu buf_size = %lu\n", cap_size, buf_size); PHOTOFAST_SLICE_ENC_DUMP("cap_size = %lu buf_size = %lu\n", cap_size, buf_size);
UINT32 lines = (buf_size / cap_size_w); UINT32 lines = (buf_size / cap_size_w);
max_slice_num = cap_size_h / lines + (cap_size_h % lines ? 1 : 0); UINT32 slice_height = ALIGN_CEIL(lines, 16);
max_slice_num = (cap_size_h / slice_height) + (cap_size_h % slice_height ? 1 : 0);
UINT32 tmp_src_h = src_frame.dim.h / 2; UINT32 tmp_src_h = src_frame.dim.h / 2;
UINT32 tmp_dst_h = cap_size_h / 16; UINT32 tmp_dst_h = cap_size_h / 16;
@ -249,7 +269,8 @@ static UINT32 PhotoFast_SliceEncode_Get_Max_Dst_Slice_Info(PhotoFast_SliceSize_I
PHOTOFAST_SLICE_ENC_DUMP("cap_size = %lu buf_size = %lu\n", tmp_cap_size.w * tmp_cap_size.h, buf_size); PHOTOFAST_SLICE_ENC_DUMP("cap_size = %lu buf_size = %lu\n", tmp_cap_size.w * tmp_cap_size.h, buf_size);
UINT32 lines = (buf_size / tmp_cap_size.w); UINT32 lines = (buf_size / tmp_cap_size.w);
max_slice_num = tmp_cap_size.h / lines + (tmp_cap_size.h % lines ? 1 : 0); UINT32 slice_height = ALIGN_CEIL(lines, 16);
max_slice_num = (tmp_cap_size.h / slice_height) + (tmp_cap_size.h % slice_height ? 1 : 0);
UINT32 tmp_src_h = sensor_info->sSize.h / 2; UINT32 tmp_src_h = sensor_info->sSize.h / 2;
UINT32 tmp_dst_h = tmp_cap_size.h / 16; UINT32 tmp_dst_h = tmp_cap_size.h / 16;
@ -708,6 +729,7 @@ static INT32 PhotoFast_SliceEncode_Init_VF_GFX_Slice(
UINT32 offset; UINT32 offset;
UINT32 scr_slice_height = (slice_idx == (src_slice_info.slice_num - 1)) ? src_slice_info.last_slice_height : src_slice_info.slice_height; UINT32 scr_slice_height = (slice_idx == (src_slice_info.slice_num - 1)) ? src_slice_info.last_slice_height : src_slice_info.slice_height;
UINT32 dst_slice_height = (slice_idx == (dst_slice_info.slice_num - 1)) ? dst_slice_info.last_slice_height : dst_slice_info.slice_height; UINT32 dst_slice_height = (slice_idx == (dst_slice_info.slice_num - 1)) ? dst_slice_info.last_slice_height : dst_slice_info.slice_height;
UINT32 dst_scale_slice_height = (slice_idx == (dst_slice_info.slice_num - 1)) ? (src_slice_info.last_slice_height * dst_slice_info.slice_height / src_slice_info.slice_height) : dst_slice_info.slice_height; UINT32 dst_scale_slice_height = (slice_idx == (dst_slice_info.slice_num - 1)) ? (src_slice_info.last_slice_height * dst_slice_info.slice_height / src_slice_info.slice_height) : dst_slice_info.slice_height;
/* dst img */ /* dst img */
@ -1900,28 +1922,20 @@ static lfqueue_t queue23 = {0};
INT32 PhotoFast_Sliceencode2_Enq_Frame(const HD_VIDEO_FRAME* video_frame) INT32 PhotoFast_Sliceencode2_Enq_Frame(const HD_VIDEO_FRAME* video_frame)
{ {
if(lfqueue_size(&queue12) >= PHOTOFAST_SLICE_ENC_QUEUE12_MAX_SIZE){
return E_SYS;
}
PhotoFast_SliceEncode_Queue12_Param* queue_ele_out = NULL; PhotoFast_SliceEncode_Queue12_Param* queue_ele_out = NULL;
queue_ele_out = (PhotoFast_SliceEncode_Queue12_Param*) malloc(sizeof(PhotoFast_SliceEncode_Queue12_Param)); queue_ele_out = (PhotoFast_SliceEncode_Queue12_Param*) malloc(sizeof(PhotoFast_SliceEncode_Queue12_Param));
memset(queue_ele_out, 0, sizeof(PhotoFast_SliceEncode_Queue12_Param)); memset(queue_ele_out, 0, sizeof(PhotoFast_SliceEncode_Queue12_Param));
queue_ele_out->frame = *video_frame; queue_ele_out->frame = *video_frame;
while(1)
{
if(lfqueue_size(&queue12) >= PHOTOFAST_SLICE_ENC_QUEUE12_MAX_SIZE)
{
vos_util_delay_ms(1);
continue;
}
else
{
while (lfqueue_enq(&queue12, (void*) queue_ele_out) == -1) while (lfqueue_enq(&queue12, (void*) queue_ele_out) == -1)
{ {
vos_util_delay_ms(1); vos_util_delay_ms(1);
DBG_ERR("ENQ Full ?\r\n"); DBG_ERR("ENQ Full ?\r\n");
} }
break;
}
}
return E_OK; return E_OK;
} }
@ -1949,7 +1963,6 @@ INT32 PhotoFast_SliceEncode_CB2(void* user_data)
PhotoFast_SliceEncode_Queue12_Param* queue_ele_in = NULL; PhotoFast_SliceEncode_Queue12_Param* queue_ele_in = NULL;
PhotoFast_SliceEncode_Queue23_Param* queue_ele_out = NULL; PhotoFast_SliceEncode_Queue23_Param* queue_ele_out = NULL;
HD_RESULT hd_ret = HD_OK; HD_RESULT hd_ret = HD_OK;
// PHOTO_VID_IN vid_in = PHOTO_VID_IN_1;
PhotoFast_SliceEncode_Info* slice_encode_primary_info = PhotoFast_SliceEncode_Get_Info(PHOTO_ENC_JPG_PRIMARY); PhotoFast_SliceEncode_Info* slice_encode_primary_info = PhotoFast_SliceEncode_Get_Info(PHOTO_ENC_JPG_PRIMARY);
PhotoFast_SliceEncode_Info* slice_encode_screennail_info = PhotoFast_SliceEncode_Get_Info(PHOTO_ENC_JPG_SCREENNAIL); PhotoFast_SliceEncode_Info* slice_encode_screennail_info = PhotoFast_SliceEncode_Get_Info(PHOTO_ENC_JPG_SCREENNAIL);
PhotoFast_SliceEncode_Info* slice_encode_thumbnail_info = PhotoFast_SliceEncode_Get_Info(PHOTO_ENC_JPG_THUMBNAIL); PhotoFast_SliceEncode_Info* slice_encode_thumbnail_info = PhotoFast_SliceEncode_Get_Info(PHOTO_ENC_JPG_THUMBNAIL);
@ -1963,7 +1976,6 @@ INT32 PhotoFast_SliceEncode_CB2(void* user_data)
UINT32 enc_accum_size = 0; UINT32 enc_accum_size = 0;
static UINT8 primary_quality = CFG_PHOTOFAST_SLICE_ENC_INIT_QUALITY_PRIMARY; static UINT8 primary_quality = CFG_PHOTOFAST_SLICE_ENC_INIT_QUALITY_PRIMARY;
static UINT8 screennail_quality = CFG_PHOTOFAST_SLICE_ENC_INIT_QUALITY_SCREENNAIL; static UINT8 screennail_quality = CFG_PHOTOFAST_SLICE_ENC_INIT_QUALITY_SCREENNAIL;
// PHOTO_CAP_CBMSG_FP PhotoCapMsgCb = (PHOTO_CAP_CBMSG_FP)Photo_CaptureCB;
if(!user_data){ if(!user_data){
DBG_ERR("user_data can't be null!\n"); DBG_ERR("user_data can't be null!\n");
@ -2035,14 +2047,7 @@ INT32 PhotoFast_SliceEncode_CB2(void* user_data)
goto EXIT; goto EXIT;
} }
DBG_DUMP("process frame %lu\n", param->cnt); DBG_IND("process frame %lu\n", param->cnt);
/*******************************************************************
* Fast Stamp (higher speed, lower quality)
******************************************************************/
#if PHOTOFAST_FAST_STAMP
PhotoFastCapDateImprint_GenYuvData(&queue_ele_in->frame);
#endif
/******************************************************************* /*******************************************************************
* Calculate dst slice info * Calculate dst slice info
@ -2056,6 +2061,15 @@ INT32 PhotoFast_SliceEncode_CB2(void* user_data)
******************************************************************/ ******************************************************************/
PhotoFast_SliceEncode_Get_Src_Slice_Info(&dst_slice_info, &src_slice_info, queue_ele_in->frame); PhotoFast_SliceEncode_Get_Src_Slice_Info(&dst_slice_info, &src_slice_info, queue_ele_in->frame);
#if PHOTOFAST_FAST_STAMP == ENABLE
/*******************************************************************
* Stamp on the src frame
******************************************************************/
if(PhotoFastCapDateImprint_Src_GenYuvData(&queue_ele_in->frame, &src_slice_info, &dst_slice_info) != E_OK){
goto EXIT;
}
#endif
slice_encode_primary_info->bs_buf_mem_info.blk_size = (VDO_YUV_BUFSIZE(dst_slice_info.width, dst_slice_info.height, queue_ele_in->frame.pxlfmt) / (CFG_PHOTOFAST_SLICE_ENC_BS_BUF_RATIO)) + CFG_JPG_HEADER_SIZE + PhotoFast_GetScreenNailSize() ; slice_encode_primary_info->bs_buf_mem_info.blk_size = (VDO_YUV_BUFSIZE(dst_slice_info.width, dst_slice_info.height, queue_ele_in->frame.pxlfmt) / (CFG_PHOTOFAST_SLICE_ENC_BS_BUF_RATIO)) + CFG_JPG_HEADER_SIZE + PhotoFast_GetScreenNailSize() ;
if(PhotoFast_SliceEncode_Alloc_Buffer_Retry( if(PhotoFast_SliceEncode_Alloc_Buffer_Retry(
&slice_encode_primary_info->bs_buf_mem_info, &slice_encode_primary_info->bs_buf_mem_info,
@ -2201,17 +2215,16 @@ INT32 PhotoFast_SliceEncode_CB2(void* user_data)
while(1) while(1)
{ {
if(lfqueue_size(param->queue23) >= PHOTOFAST_SLICE_ENC_QUEUE23_MAX_SIZE) if(lfqueue_size(param->queue23) >= PHOTOFAST_SLICE_ENC_QUEUE23_MAX_SIZE){
{
vos_util_delay_ms(1); vos_util_delay_ms(1);
continue; continue;
} }
else else{
{
while (lfqueue_enq(param->queue23, (void*) queue_ele_out) == -1) while (lfqueue_enq(param->queue23, (void*) queue_ele_out) == -1)
{ {
DBG_ERR("ENQ Full ?\r\n"); DBG_ERR("ENQ Full ?\r\n");
} }
break; break;
} }
} }
@ -2267,6 +2280,7 @@ INT32 PhotoFast_SliceEncode_CB3(void* user_data)
INT32 ret = E_OK; INT32 ret = E_OK;
PhotoFast_SliceEncode_CB3_Param* param = NULL; PhotoFast_SliceEncode_CB3_Param* param = NULL;
PhotoFast_SliceEncode_Queue23_Param* queue_ele_in = NULL; PhotoFast_SliceEncode_Queue23_Param* queue_ele_in = NULL;
VOS_TICK t1, t2, t3, t4;
if(!user_data){ if(!user_data){
DBG_ERR("user_data can't be null!\n"); DBG_ERR("user_data can't be null!\n");
@ -2305,6 +2319,8 @@ INT32 PhotoFast_SliceEncode_CB3(void* user_data)
goto EXIT; goto EXIT;
} }
vos_perf_mark(&t1);
#if !PHOTOFAST_FAST_CLOSE #if !PHOTOFAST_FAST_CLOSE
PhotoFast_WriteFile( PhotoFast_WriteFile(
(UINT32)queue_ele_in->jpg_combined_addr, (UINT32)queue_ele_in->jpg_combined_addr,
@ -2321,6 +2337,8 @@ INT32 PhotoFast_SliceEncode_CB3(void* user_data)
queue_ele_in->file_path); queue_ele_in->file_path);
#endif #endif
vos_perf_mark(&t2);
{ {
char tmp[NMC_TOTALFILEPATH_MAX_LEN] = {'\0'}; char tmp[NMC_TOTALFILEPATH_MAX_LEN] = {'\0'};
@ -2352,6 +2370,8 @@ INT32 PhotoFast_SliceEncode_CB3(void* user_data)
#endif #endif
DBG_IND("PHOTO THUMB %s\n", tmp); DBG_IND("PHOTO THUMB %s\n", tmp);
vos_perf_mark(&t3);
FST_FILE fp = FileSys_OpenFile(tmp, FST_CREATE_ALWAYS | FST_OPEN_WRITE); FST_FILE fp = FileSys_OpenFile(tmp, FST_CREATE_ALWAYS | FST_OPEN_WRITE);
FileSys_WriteFile(fp, (UINT8*)queue_ele_in->jpg_thumb_addr, &queue_ele_in->jpg_thumb_size, 0, NULL); FileSys_WriteFile(fp, (UINT8*)queue_ele_in->jpg_thumb_addr, &queue_ele_in->jpg_thumb_size, 0, NULL);
@ -2368,6 +2388,14 @@ INT32 PhotoFast_SliceEncode_CB3(void* user_data)
#endif #endif
} }
vos_perf_mark(&t4);
DBG_DUMP("CB3 cost %lu ms(%lu , %lu , %lu)\n",
vos_perf_duration(t1, t4) / 1000,
vos_perf_duration(t1, t2) / 1000,
vos_perf_duration(t2, t3) / 1000,
vos_perf_duration(t3, t4) / 1000
);
/* check user bs buffer is freed */ /* check user bs buffer is freed */
if(queue_ele_in->mem_info_combined.va){ if(queue_ele_in->mem_info_combined.va){