From 44f25bb7578a5e510f4d11bf600bd799c9dedd46 Mon Sep 17 00:00:00 2001 From: payton Date: Tue, 24 Oct 2023 18:06:42 +0800 Subject: [PATCH] =?UTF-8?q?1.=E5=90=8C=E6=AD=A5=E8=BF=9E=E6=8B=8D=E6=BC=8F?= =?UTF-8?q?=E5=9B=BE=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cardv/SrcCode/UIApp/PhotoFast/PhotoFast.c | 31 ++++++++++++- .../UIApp/PhotoFast/PhotoFastSliceEncode.c | 45 +++++++++++++++---- 2 files changed, 65 insertions(+), 11 deletions(-) diff --git a/rtos/code/application/source/cardv/SrcCode/UIApp/PhotoFast/PhotoFast.c b/rtos/code/application/source/cardv/SrcCode/UIApp/PhotoFast/PhotoFast.c index 2cebccf4c..10324ce43 100755 --- a/rtos/code/application/source/cardv/SrcCode/UIApp/PhotoFast/PhotoFast.c +++ b/rtos/code/application/source/cardv/SrcCode/UIApp/PhotoFast/PhotoFast.c @@ -1376,6 +1376,33 @@ 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; @@ -1530,7 +1557,7 @@ THREAD_RETTYPE PhotoFast_FlowPreviewThread(void *arg) } #endif - if((hd_ret = hd_videocap_pull_out_buf(vcap_path, &video_cap_frame, PHOTOFAST_HD_PUSH_PULL_TIMEOUT_MS)) != HD_OK){ + 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; } @@ -1575,7 +1602,7 @@ THREAD_RETTYPE PhotoFast_FlowPreviewThread(void *arg) } else{ - if((hd_ret = hd_videocap_pull_out_buf(vcap_path, &video_cap_frame, PHOTOFAST_HD_PUSH_PULL_TIMEOUT_MS)) != HD_OK){ + 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; } diff --git a/rtos/code/application/source/cardv/SrcCode/UIApp/PhotoFast/PhotoFastSliceEncode.c b/rtos/code/application/source/cardv/SrcCode/UIApp/PhotoFast/PhotoFastSliceEncode.c index 078be393d..5c4f17059 100755 --- a/rtos/code/application/source/cardv/SrcCode/UIApp/PhotoFast/PhotoFastSliceEncode.c +++ b/rtos/code/application/source/cardv/SrcCode/UIApp/PhotoFast/PhotoFastSliceEncode.c @@ -40,6 +40,9 @@ #define PHOTOFAST_SLICE_ENC_DBG_SCREENNAIL_JPG 0 #define PHOTOFAST_SLICE_ENC_DBG_THUMBNAIL_JPG 0 +#define PHOTOFAST_SLICE_ENC_QUEUE12_MAX_SIZE 2 +#define PHOTOFAST_SLICE_ENC_QUEUE23_MAX_SIZE 1 + #if PHOTOFAST_SLICE_ENC_DBG_PRIMARY_JPG || PHOTOFAST_SLICE_ENC_DBG_SCREENNAIL_JPG || PHOTOFAST_SLICE_ENC_DBG_THUMBNAIL_JPG #define PHOTOFAST_SLICE_ENC_DBG_JPG 1 #else @@ -1902,11 +1905,23 @@ INT32 PhotoFast_Sliceencode2_Enq_Frame(const HD_VIDEO_FRAME* video_frame) memset(queue_ele_out, 0, sizeof(PhotoFast_SliceEncode_Queue12_Param)); queue_ele_out->frame = *video_frame; - while (lfqueue_enq(&queue12, (void*) queue_ele_out) == -1) - { - vos_util_delay_ms(1); - DBG_ERR("ENQ Full ?\r\n"); - } + 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) + { + vos_util_delay_ms(1); + DBG_ERR("ENQ Full ?\r\n"); + } + break; + } + } return E_OK; } @@ -2184,10 +2199,22 @@ INT32 PhotoFast_SliceEncode_CB2(void* user_data) DBG_DUMP("%s added to DCF\r\n", queue_ele_out->file_path); #endif - while (lfqueue_enq(param->queue23, (void*) queue_ele_out) == -1) - { - DBG_ERR("ENQ Full ?\r\n"); - } + while(1) + { + if(lfqueue_size(param->queue23) >= PHOTOFAST_SLICE_ENC_QUEUE23_MAX_SIZE) + { + vos_util_delay_ms(1); + continue; + } + else + { + while(lfqueue_enq(param->queue23, (void*)queue_ele_out) == -1) + { + DBG_ERR("ENQ Full ?\r\n"); + } + break; + } + } /* check is vproc frame released */ if(queue_ele_in->frame.phy_addr[0]){