nt9856x/rtos/code/application/source/cardv/SrcCode/UIApp/MovieFast/MovieFast.c
2023-11-17 18:45:14 +08:00

1825 lines
55 KiB
C

////////////////////////////////////////////////////////////////////////////////
#include "PrjInc.h"
#include "ImageApp/ImageApp_MovieMulti.h"
#include "avfile/movieinterface_def.h"
#include "kwrap/task.h"
#include "sys_mempool.h"
#include "sys_fdt.h"
#include "UIApp/MovieStamp/MovieStamp.h"
#include "NamingRule/NameRule_Custom.h"
#include "FileDB.h"
#include "SysSensor.h"
#include "GxTime.h"
#include "vendor_isp.h"
#include "UIApp/Network/UIAppWiFiCmd.h"
#include "UIApp/AppDisp_PipView.h"
#include <vf_gfx.h>
#include "vendor_videocapture.h"
#include "UIApp/MovieStamp/MovieStampAPI.h"
#include <kwrap/util.h>
#if (USE_EXIF == ENABLE)
#include "UIApp/ExifVendor.h"
#endif
#include "vendor_videoout.h"
#include "sys_fastboot.h"
#include "MovieFast.h"
#include <FreeRTOS_POSIX.h>
#include <FreeRTOS_POSIX/pthread.h>
#include <comm/hwclock.h>
#include <comm/hwpower.h>
#include "DCF.h"
#include "flow_boot_linux.h"
#include "DxHunting.h"
#include "flow_preview.h"
#include <kwrap/cmdsys.h>
#include "UIApp/PhotoFast/PhotoFast.h"
#include "UIApp/PhotoFast/PhotoFastSliceEncode.h"
#include "UIApp/PhotoFast/PhotoFastCapDateImprint.h"
#include "UIAppPhoto_Param.h"
#include "sys_fwload.h"
#include "../lfqueue/lfqueue.h"
#include <sys_linuxboot.h>
#include <libfdt.h>
#include <rtosfdt.h>
#include <compiler.h>
#define MEM_PATH_LINUX "/memory"
#if defined(_UI_STYLE_LVGL_)
#include "flow_lvgl.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__ MovieFast
#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 <kwrap/debug.h>
#endif
#if HUNTING_CAMERA_MCU == ENABLE
#include <sf_mcu.h>
#include "sf_led.h"
#endif
#include <kwrap/cmdsys.h>
/**
Flags for control
*/
#define FLG_EXE_MOVIE_IDLE FLGPTN_BIT(0)
#define FLG_EXE_MOVIE_RECSTART FLGPTN_BIT(1) ///< trigger display task
#define FLG_EXE_MOVIE_RECSTOP FLGPTN_BIT(2) ///< stop task
#define VDO_YUV_BUFSIZE(w, h, pxlfmt) ALIGN_CEIL_4(((w) * (h) * HD_VIDEO_PXLFMT_BPP(pxlfmt)) / 8)
typedef enum {
MOVIEFAST_IQ_VIDEO,
MOVIEFAST_IQ_PHOTO,
} MOVIEFAST_IQ_CFG;
typedef struct {
void* va;
UINT32 size;
char path[256];
HD_VIDEO_FRAME frame;
HD_PATH_ID vprc_path_id;
} MOVIEFAST_WRITE_QUEUE_PARAM;
/**********************************************************************************
* independent thumbnail
*********************************************************************************/
static char thumb_current_path_main[256] = {'\0'};
static char thumb_current_path_clone[256] = {'\0'};
static lfqueue_t write_queue = {0};
#define FILE_SN_MAX 99999
#define FILEDB_MAX_NUM 5000
#define MOVIE_THUMB_WIDTH 640
#define PRI_MOVIEFAST_CMDTSK 11
#define STKSIZE_MOVIEFAST_CMDTSK 8192
//local variable
static DCF_HANDLE g_dcf_hdl = 0;
static ID MOVIEFAST_FLG_ID = 0;
static UINT32 g_moviefast_tsk_run = 1;
static UINT32 g_moviefast_poweroff_tsk_run = 1;
static THREAD_HANDLE g_moviefast_tsk_id = 0;
static THREAD_HANDLE g_moviefast_raw_tsk_id = 0;
static THREAD_HANDLE g_moviefast_power_off_tsk_id = 0;
static THREAD_HANDLE g_moviefast_write_tsk_id = 0;
static BOOL g_bIsRecStatus = FALSE;
static BOOL g_manual_raw_tsk_running = FALSE;
static BOOL g_is_manual_raw_tsk_running = FALSE;
static VOS_TICK g_rec_start_tick = 0;
static VOS_TICK g_alg_start_time= 0;
static VOS_TICK g_alg_end_time= 0;
static VOS_TICK g_vprc_trigger_frm_time= 0;
static UINT32 g_vprc_trigger_frm_count= 0;
//local function
static void MovieFast_OnRecStart(void);
static void MovieFast_OnRecStop(void);
static void MovieFast_CmdTsk_Exit(void);
static int MovieFast_GetWaterLogoSource(const UINT32 recWidth,WATERLOGO_BUFFER *waterSrc);
static void MovieFast_ShutDown(void);
static void MovieFast_Close(void);
static void MovieFast_Load_Sen_Cfg(MOVIEFAST_IQ_CFG cfg);
static VOID MovieFast_Set_RecStartTick(VOS_TICK tick)
{
g_rec_start_tick = tick;
}
static BOOL MovieFast_Get_RecStartTick(VOS_TICK* tick)
{
if(tick == NULL){
DBG_ERR("tick can't be null!\n");
return FALSE;
}
if(g_rec_start_tick == 0){
DBG_ERR("rec start tick is invalid!\n");
return FALSE;
}
*tick = g_rec_start_tick;
return TRUE;
}
static ER MovieFast_InstallID(void)
{
ER ret = E_OK;
T_CFLG cflg;
memset(&cflg, 0, sizeof(T_CFLG));
if ((ret |= vos_flag_create(&MOVIEFAST_FLG_ID, &cflg, "MOVIEFAST_FLG")) != E_OK) {
DBG_ERR("MOVIEFAST_FLG_ID fail\r\n");
}
return ret;
}
static THREAD_RETTYPE MovieFast_PowerOffTsk(void)
{
const BOOL delay_ms = 200;
THREAD_ENTRY();
DBG_DUMP("MovieFast_PowerOffTsk started\n");
g_moviefast_poweroff_tsk_run = TRUE;
while(g_moviefast_poweroff_tsk_run)
{
if(TRUE == flow_preview_get_stop_flag()){
DBG_WRN("detected stop signal, power off ...\n");
break;
}
vos_util_delay_ms(delay_ms);
}
if(MOVIEFAST_FLG_ID){
vos_flag_set(MOVIEFAST_FLG_ID, FLGMOVIEFAST_SHUTDOWN);
}
else{
MovieFast_ShutDown();
}
THREAD_RETURN(0);
}
static THREAD_RETTYPE MovieFast_CmdTsk(void)
{
FLGPTN uiFlag = 0, wait_flag = 0;
THREAD_ENTRY();
wait_flag = FLGMOVIEFAST_RECSTART |
FLGMOVIEFAST_RECSTOP |
FLGMOVIEFAST_SHUTDOWN;
g_moviefast_tsk_run = TRUE;
while (g_moviefast_tsk_run) {
vos_flag_wait(&uiFlag, MOVIEFAST_FLG_ID, wait_flag, TWF_ORW | TWF_CLR);
if (uiFlag & FLGMOVIEFAST_RECSTART) {
if (DCF_GetDBInfo(DCF_INFO_IS_9999)) {
DBG_ERR("Exceed max dcf file!\r\n");
MovieFast_ShutDown();
}
MovieFast_OnRecStart();
} else if (uiFlag & FLGMOVIEFAST_RECSTOP) {
MovieFast_OnRecStop();
} else if (uiFlag & FLGMOVIEFAST_SHUTDOWN) {
MovieFast_ShutDown();
}else{
DBG_WRN("No flag for MovieFast_CmdTsk\r\n");
}
}
THREAD_RETURN(0);
}
#if POWERON_BOOT_REPORT == ENABLE
/********************************************************************
* extern PhotoFast function
*********************************************************************/
extern UINT32 PhotoFast_GetTriggerFrmCnt(VOID);
extern BOOL PhotoFast_GetTick(UINT32 cnt, VOS_TICK* tick);
extern void PhotoFast_TriggerFrm_Dump(void);
static void MovieFast_PV_ChangeMode_Dump(void)
{
VOS_TICK rec_start_tick;
if(MovieFast_Get_RecStartTick(&rec_start_tick) == TRUE){
UINT32 cnt = PhotoFast_GetTriggerFrmCnt();
VOS_TICK trig_tick;
if(PhotoFast_GetTick(cnt, &trig_tick) == TRUE){
DBG_DUMP("\n\n**********************************************************\n"
" P + V Change mode: %lu ms\n"
"**********************************************************\n",
vos_perf_duration(trig_tick, rec_start_tick) / 1000
);
}
}
}
static void MovieFast_PV_Info_Dump(void)
{
/* report trigger speed */
PhotoFast_TriggerFrm_Dump();
/* report P + V change mode speed */
MovieFast_PV_ChangeMode_Dump();
}
#endif
static void MovieFast_ShutDown(void)
{
UINT8 mode = DrvGPIO_GetPhotoMovieModeFromMonitor();
MovieFast_CmdTsk_Exit();
MovieFast_Close();
#if (POWERON_FAST_BOOT_MSG == DISABLE)
// fastboot_msg_en(ENABLE);
#endif
#if HUNTING_CAMERA_BOOT_LINUX /* Boot Linux */
#if POWERON_BOOT_REPORT == ENABLE
DBG_DUMP("PhotoMovie mode = %u\n", mode);
VOS_TICK tick;
PhotoFast_GetTick(g_vprc_trigger_frm_count, &tick);
DBG_DUMP("\n\n**********************************************************\n"
" Trigger Speed(vcap frame count = %lu) : %lu us alg_start_time = %lu g_alg_end_time = %lu, perf tick = %lu us\n"
"**********************************************************\n",
g_vprc_trigger_frm_count, g_vprc_trigger_frm_time, g_alg_start_time, g_alg_end_time, tick);
vos_perf_list_dump();
if(mode == DX_HUNTING_MODE_PHOTO_MOVIE){
MovieFast_PV_Info_Dump();
}
#endif
#if HUNTING_CAMERA_MCU
fastboot_msg_en(ENABLE);
sf_file_thumb_cfg_sava();
sf_para_print();
DBG_DUMP("wait filesys close ...\n");
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
vos_perf_list_mark("pwr off", __LINE__, 0);
#if POWERON_BOOT_REPORT == ENABLE
VOS_TICK tick;
PhotoFast_GetTick(g_vprc_trigger_frm_count, &tick);
DBG_DUMP("\n\n**********************************************************\n"
" Trigger Speed(vcap frame count = %lu) : %lu us alg_start_time = %lu g_alg_end_time = %lu, perf tick = %lu us\n"
"**********************************************************\n",
g_vprc_trigger_frm_count, g_vprc_trigger_frm_time, g_alg_start_time, g_alg_end_time, tick);
vos_perf_list_dump();
if(mode == DX_HUNTING_MODE_PHOTO_MOVIE){
MovieFast_PV_Info_Dump();
}
#endif
#if HUNTING_CAMERA_MCU == ENABLE
sf_mcu_reg_set(SF_MCU_POWEROFF,0);
#else
hwpower_set_power_key(POWER_ID_PSW1, 0xFF);
#endif
#endif
}
static void MovieFast_SetRecParamByRecID(MOVIE_CFG_REC_ID rec_id)
{
// set record type (video only, video and audio, time-lapse, ...)
if (SysGetFlag(FL_MOVIE_TIMELAPSE_REC) == MOVIE_TIMELAPSEREC_OFF) {
if (SysGetFlag(FL_MovieAudioRec) == MOVIE_AUD_REC_OFF) {
ImageApp_MovieMulti_SetParam(rec_id, MOVIEMULTI_PARAM_REC_FORMAT, _CFG_REC_TYPE_VID);
} else {
ImageApp_MovieMulti_SetParam(rec_id, MOVIEMULTI_PARAM_REC_FORMAT, _CFG_REC_TYPE_AV);
}
ImageApp_MovieMulti_SetParam(rec_id, MOVIEMULTI_PARAM_TIMELAPSE_TIME, 0);
ImageApp_MovieMulti_SetParam(rec_id, MOVIEMULTI_PARAM_FILE_ENDTYPE, (SysGetFlag(FL_MOVIE_CYCLIC_REC) == MOVIE_CYCLICREC_OFF) ? MOVREC_ENDTYPE_CUT_TILLCARDFULL : MOVREC_ENDTYPE_CUTOVERLAP);
} else {
ImageApp_MovieMulti_SetParam(rec_id, MOVIEMULTI_PARAM_REC_FORMAT, _CFG_REC_TYPE_TIMELAPSE);
ImageApp_MovieMulti_SetParam(rec_id, MOVIEMULTI_PARAM_TIMELAPSE_TIME, Get_MovieTimeLapseValue(SysGetFlag(FL_MOVIE_TIMELAPSE_REC)));
//ImageApp_MovieMulti_SetParam(rec_id, MOVIEMULTI_PARAM_FILE_PLAYFRAMERATE, MOVIE_TIMELAPSE_PLAYFRAMERATE);
ImageApp_MovieMulti_SetParam(rec_id, MOVIEMULTI_PARAM_FILE_ENDTYPE, (SysGetFlag(FL_MOVIE_CYCLIC_REC) == MOVIE_CYCLICREC_OFF) ? MOVREC_ENDTYPE_CUT_TILLCARDFULL : MOVREC_ENDTYPE_CUTOVERLAP);
}
}
static void MovieFast_SetAq(HD_PATH_ID path_id, UINT8 ip_str)
{
HD_H26XENC_AQ aq_param = {0};
if(ip_str > 8)
ip_str = 8;
aq_param.enable = 1; // AQ enable. default: 0, range: 0~1 (0: disable, 1: enable)
aq_param.i_str = ip_str; // aq strength of I frame. default: 3, range: 1~8
aq_param.p_str = ip_str; // aq strength of P frame. default: 1, range: 1~8
aq_param.min_delta_qp = -8; // max delta qp of aq.
aq_param.max_delta_qp = 8; // min delta qp of aq.
hd_videoenc_set(path_id, HD_VIDEOENC_PARAM_OUT_AQ, &aq_param);
}
static void MovieFast_SetRRC(HD_PATH_ID path_id, UINT8 enable, UINT32 range, UINT32 step)
{
HD_H26XENC_ROW_RC rowrc = {0};
rowrc.enable = 1;
rowrc.i_qp_range = range;
rowrc.i_qp_step = step;
rowrc.p_qp_range = range;
rowrc.p_qp_step = step;
rowrc.min_i_qp = 1;
rowrc.max_i_qp = 51;
rowrc.min_p_qp = 1;
rowrc.max_p_qp = 51;
hd_videoenc_set(path_id, HD_VIDEOENC_PARAM_OUT_ROW_RC, &rowrc);
}
static void MovieFast_RecMovieStamp(void)
{
UINT32 Width, Height;
UINT32 uiStampAddr;
UINT32 uiStampMemSize;
WATERLOGO_BUFFER waterLogoSrc={0};
HD_PATH_ID uiVEncOutPortId = 0;
UINT32 i, mask;
UINT32 movie_rec_mask, clone_rec_mask;
#if defined(_UI_STYLE_LVGL_)
lv_color32_t color = (lv_color32_t){.full = LV_USER_CFG_STAMP_COLOR_BACKGROUND};
uint8_t r = LV_COLOR_GET_R32(color);
uint8_t g = LV_COLOR_GET_G32(color);
uint8_t b = LV_COLOR_GET_B32(color);
STAMP_COLOR StampColorBg = {RGB_GET_Y(r, g, b), RGB_GET_U(r, g, b), RGB_GET_V(r, g, b)}; // date stamp foreground color
#else
STAMP_COLOR StampColorBg = {RGB_GET_Y( 16, 16, 16), RGB_GET_U( 16, 16, 16), RGB_GET_V( 16, 16, 16)}; // date stamp background color
#endif
#if defined(_UI_STYLE_LVGL_)
color = (lv_color32_t){.full = LV_USER_CFG_STAMP_COLOR_FRAME};
r = LV_COLOR_GET_R32(color);
g = LV_COLOR_GET_G32(color);
b = LV_COLOR_GET_B32(color);
STAMP_COLOR StampColorFr = {RGB_GET_Y(r, g, b), RGB_GET_U(r, g, b), RGB_GET_V(r, g, b)}; // date stamp foreground color
#else
STAMP_COLOR StampColorFr = {RGB_GET_Y( 16, 16, 16), RGB_GET_U( 16, 16, 16), RGB_GET_V( 16, 16, 16)}; // date stamp frame color
#endif
#if defined(_UI_STYLE_LVGL_)
color = (lv_color32_t){.full = LV_USER_CFG_STAMP_COLOR_TEXT};
r = LV_COLOR_GET_R32(color);
g = LV_COLOR_GET_G32(color);
b = LV_COLOR_GET_B32(color);
STAMP_COLOR StampColorFg = {RGB_GET_Y(r, g, b), RGB_GET_U(r, g, b), RGB_GET_V(r, g, b)}; // date stamp foreground color
#else
STAMP_COLOR StampColorFg = {RGB_GET_Y(224, 224, 192), RGB_GET_U(224, 224, 192), RGB_GET_V(224, 224, 192)}; // date stamp foreground color
#endif
movie_rec_mask = Movie_GetMovieRecMask();
clone_rec_mask = Movie_GetCloneRecMask();
//DBG_DUMP("setup_rec_moviestamp sen_cnt=%d\r\n",sen_cnt);
mask = 1;
for (i = 0; i < SENSOR_CAPS_COUNT; i ++) {
// set main path 1st movie stamp
if ((movie_rec_mask & mask) || (SENSOR_INSERT_MASK & mask)) {
Width = gMovie_Rec_Info[i].size.w;
Height =gMovie_Rec_Info[i].size.h;
memset(&waterLogoSrc,0,sizeof(WATERLOGO_BUFFER));
MovieFast_GetWaterLogoSource(Width,&waterLogoSrc);
uiVEncOutPortId = HD_GET_OUT(ImageApp_MovieMulti_GetVdoEncPort(_CFG_REC_ID_1+i)) - 1; // since out is start from 1, so uiVidEncId should minus 1
DBG_DUMP("main VEncOutPortId=%d, [%d, %d] i=%d\r\n",uiVEncOutPortId,Width,Height, i);
#if (_BOARD_DRAM_SIZE_ == 0x04000000)
uiStampMemSize = MovieStamp_CalcBufSize(Width/2, Height,&waterLogoSrc);
#else
uiStampMemSize = MovieStamp_CalcBufSize(Width, Height,&waterLogoSrc);
#endif
uiStampAddr = MovieStamp_GetBufAddr(uiVEncOutPortId, uiStampMemSize); // stamp malloc vir addr
MovieStamp_SetBuffer(uiVEncOutPortId, uiStampAddr, uiStampMemSize, waterLogoSrc.uiWidth, waterLogoSrc.uiHeight);
MovieStamp_SetColor(uiVEncOutPortId, &StampColorBg, &StampColorFr, &StampColorFg);
MovieStamp_Setup(
uiVEncOutPortId,
STAMP_ON |
STAMP_AUTO |
STAMP_DATE_TIME |
STAMP_BOTTOM_LEFT |
STAMP_POS_NORMAL |
STAMP_YY_MM_DD,
Width,
Height,
#if defined (WATERLOGO_FUNCTION) && (WATERLOGO_FUNCTION == ENABLE)
(WATERLOGO_BUFFER *)&waterLogoSrc);
#else
NULL);
#endif
}
// set clone path 1st movie stamp
if ((clone_rec_mask & mask) || (SENSOR_INSERT_MASK & mask)) {
Width = gMovie_Clone_Info[i].size.w;
Height = gMovie_Clone_Info[i].size.h;
memset(&waterLogoSrc,0,sizeof(WATERLOGO_BUFFER));
MovieFast_GetWaterLogoSource(Width,&waterLogoSrc);
uiVEncOutPortId = HD_GET_OUT(ImageApp_MovieMulti_GetVdoEncPort(_CFG_CLONE_ID_1+i)) - 1; // since out is start from 1, so uiVidEncId should minus 1
DBG_DUMP("clone VEncOutPortId=%d, GetVdoEncPort(_CFG_CLONE_ID_1+%d)=0x%x\r\n",uiVEncOutPortId,i,ImageApp_MovieMulti_GetVdoEncPort(_CFG_CLONE_ID_1+i));
#if (_BOARD_DRAM_SIZE_ == 0x04000000)
uiStampMemSize = MovieStamp_CalcBufSize(Width/2, Height,&waterLogoSrc);
#else
uiStampMemSize = MovieStamp_CalcBufSize(Width, Height,&waterLogoSrc);
#endif
uiStampAddr = MovieStamp_GetBufAddr(uiVEncOutPortId, uiStampMemSize);
MovieStamp_SetBuffer(uiVEncOutPortId, uiStampAddr, uiStampMemSize, waterLogoSrc.uiWidth, waterLogoSrc.uiHeight);
MovieStamp_SetColor(uiVEncOutPortId, &StampColorBg, &StampColorFr, &StampColorFg);
MovieStamp_Setup(
uiVEncOutPortId,
STAMP_ON |
STAMP_AUTO |
STAMP_DATE_TIME |
STAMP_BOTTOM_RIGHT |
STAMP_POS_NORMAL |
STAMP_YY_MM_DD,
Width,
Height,
#if defined (WATERLOGO_FUNCTION) && (WATERLOGO_FUNCTION == ENABLE)
(WATERLOGO_BUFFER *)&waterLogoSrc);
#else
NULL);
#endif
}
#if 0
// set rawenc path 1st movie stamp
if (movie_rec_mask & mask) {
Width = gMovie_Rec_Info[i].size.w;
Height =gMovie_Rec_Info[i].size.h;
memset(&waterLogoSrc,0,sizeof(WATERLOGO_BUFFER));
MovieFast_GetWaterLogoSource(Width,&waterLogoSrc);
//uiVEncOutPortId = HD_GET_OUT(ImageApp_MovieMulti_GetRawEncPort(_CFG_REC_ID_1+i)) - 1;
//DBG_DUMP("main Rewenc VEncOutPortId=%d, GetVdoEncPort(_CFG_REC_ID_1+%d)=0x%x\r\n",uiVEncOutPortId,i,ImageApp_MovieMulti_GetRawEncPort(_CFG_REC_ID_1+i));
uiVEncOutPortId =MovieStamp_GetRawEncVirtualPort(i);
DBG_DUMP("main Rewenc VEncOutPortId=%d, i=%d, w=%d, %d\r\n",uiVEncOutPortId,i,Width,Height);
#if (_BOARD_DRAM_SIZE_ == 0x04000000)
uiStampMemSize = MovieStamp_CalcBufSize(Width/2, Height,&waterLogoSrc);
#else
uiStampMemSize = MovieStamp_CalcBufSize(Width, Height,&waterLogoSrc);
#endif
uiStampAddr = MovieStamp_GetBufAddr(uiVEncOutPortId,uiStampMemSize);
MovieStamp_SetBuffer(uiVEncOutPortId, uiStampAddr, uiStampMemSize, waterLogoSrc.uiWidth, waterLogoSrc.uiHeight);
MovieStamp_SetColor(uiVEncOutPortId, &StampColorBg, &StampColorFr, &StampColorFg);
MovieStamp_Setup(
uiVEncOutPortId,
STAMP_ON |
STAMP_AUTO |
STAMP_DATE_TIME |
STAMP_BOTTOM_RIGHT |
STAMP_POS_NORMAL |
STAMP_YY_MM_DD,
Width,
Height,
#if defined (WATERLOGO_FUNCTION) && (WATERLOGO_FUNCTION == ENABLE)
(WATERLOGO_BUFFER *)&waterLogoSrc);
#else
NULL);
#endif
}
#endif
mask <<= 1;
}
MovieStamp_Enable();
}
static void MovieFast_SetRecInfoByUISetting(void)
{
UINT32 movie_size_idx, size_idx = 0;
UINT32 movie_aspect_ratio_idx = 0;
UINT32 i, rec_type;
UINT32 mask, ipl_id = 0, setting_count = 0;
UINT32 movie_rec_mask;//, clone_rec_mask;
movie_size_idx = UI_GetData(FL_MOVIE_SIZE);
rec_type = MovieMapping_GetRecType(movie_size_idx);
movie_rec_mask = SENSOR_ALL; //All ImagePipe must be initialized first, but they isn't running state
//clone_rec_mask = SENSOR_ALL;
mask = 1;
for (i = 0; i < SENSOR_CAPS_COUNT; i++) {
if (rec_type == MOVIE_REC_TYPE_FRONT || rec_type == MOVIE_REC_TYPE_CLONE) { // single recording
if (movie_rec_mask & mask) { // active sensor, for movie recording
ipl_id = 0; // get data from the mapping table of single recording, so IPL ID = 0
size_idx = movie_size_idx;
}
} else if (rec_type == MOVIE_REC_TYPE_DUAL) { // dual recording
if ((movie_rec_mask & mask) && (setting_count < 2)) { // active sensor, for movie recording
ipl_id = 0; // get data from the mapping table of dual recording, 1st IPL ID = 0
size_idx = movie_size_idx;
setting_count++;
}
} else if (rec_type == MOVIE_REC_TYPE_TRI) { // tri recording
if ((movie_rec_mask & mask) && (setting_count < 3)) { // active sensor, for movie recording
if (setting_count == 0) { // 1st active sensor
ipl_id = 0; // get data from the mapping table of tri recording, 1st IPL ID = 0
} else if (setting_count == 1) { // 2nd active sensor
ipl_id = 1; // get data from the mapping table of tri recording, 2nd IPL ID = 1
} else { // 3rd active sensor
ipl_id = 2; // get data from the mapping table of tri recording, 3rd IPL ID = 2
}
size_idx = movie_size_idx;
setting_count++;
}
} else { // quad recording
ipl_id = i;
size_idx = movie_size_idx;
}
// set main movie
gMovie_Rec_Info[i].size.w = MovieMapping_GetWidth(size_idx, ipl_id);
gMovie_Rec_Info[i].size.h = MovieMapping_GetHeight(size_idx, ipl_id);
gMovie_Rec_Info[i].raw_enc_size.w = MovieMapping_GetWidth(size_idx, ipl_id);
gMovie_Rec_Info[i].raw_enc_size.h = MovieMapping_GetHeight(size_idx, ipl_id);
gMovie_Rec_Info[i].frame_rate = MovieMapping_GetFrameRate(size_idx, ipl_id);
gMovie_Rec_Info[i].target_bitrate = MovieMapping_GetTargetBitrate(size_idx, ipl_id);
gMovie_Rec_Info[i].dar = MovieMapping_GetDispAspectRatio(size_idx, ipl_id);
gMovie_Rec_Info[i].codec = (UI_GetData(FL_MOVIE_CODEC) == MOVIE_CODEC_H265) ? _CFG_CODEC_H265 : _CFG_CODEC_H264;
//#NT#2018/02/14#KCHong -begin
//#NT#support sensor rotate setting
gMovie_Rec_Info[i].sensor_rotate = FALSE;
//#NT#2018/02/14#KCHong -end
MovieMapping_GetAqInfo(size_idx, ipl_id, (UINT32)&gMovie_Rec_Info[i].aq_info);
MovieMapping_GetCbrInfo(size_idx, ipl_id, (UINT32)&gMovie_Rec_Info[i].cbr_info);
movie_aspect_ratio_idx = MovieMapping_GetImageRatio(size_idx, ipl_id);
switch (movie_aspect_ratio_idx) {
case IMAGERATIO_16_9:
gMovie_Rec_Info[i].ratio.w = 16;
gMovie_Rec_Info[i].ratio.h = 9;
gMovie_Rec_Info[i].disp_ratio.w = 16;
gMovie_Rec_Info[i].disp_ratio.h = 9;
break;
default:
gMovie_Rec_Info[i].ratio.w = 4;
gMovie_Rec_Info[i].ratio.h = 3;
gMovie_Rec_Info[i].disp_ratio.w = 4;
gMovie_Rec_Info[i].disp_ratio.h = 3;
break;
}
// set clone movie
if (rec_type == MOVIE_REC_TYPE_CLONE) {
gMovie_Clone_Info[i].size.w = MovieMapping_GetCloneWidth(size_idx, ipl_id);
gMovie_Clone_Info[i].size.h = MovieMapping_GetCloneHeight(size_idx, ipl_id);
gMovie_Clone_Info[i].raw_enc_size.w = MovieMapping_GetCloneWidth(size_idx, ipl_id);
gMovie_Clone_Info[i].raw_enc_size.h = MovieMapping_GetCloneHeight(size_idx, ipl_id);
gMovie_Clone_Info[i].frame_rate = MovieMapping_GetCloneFrameRate(size_idx, ipl_id);
gMovie_Clone_Info[i].target_bitrate = MovieMapping_GetCloneTargetBitrate(size_idx, ipl_id);
gMovie_Clone_Info[i].dar = MovieMapping_GetCloneDispAspectRatio(size_idx, ipl_id);
gMovie_Clone_Info[i].codec = (UI_GetData(FL_MOVIE_CODEC) == MOVIE_CODEC_H265) ? _CFG_CODEC_H265 : _CFG_CODEC_H264;
MovieMapping_GetCloneAqInfo(size_idx, ipl_id, (UINT32)&gMovie_Clone_Info[i].aq_info);
MovieMapping_GetCloneCbrInfo(size_idx, ipl_id, (UINT32)&gMovie_Clone_Info[i].cbr_info);
movie_aspect_ratio_idx = MovieMapping_GetCloneImageRatio(size_idx, ipl_id);
switch (movie_aspect_ratio_idx) {
case IMAGERATIO_16_9:
gMovie_Clone_Info[i].ratio.w = 16;
gMovie_Clone_Info[i].ratio.h = 9;
gMovie_Clone_Info[i].disp_ratio.w = 16;
gMovie_Clone_Info[i].disp_ratio.h = 9;
break;
default:
gMovie_Clone_Info[i].ratio.w = 4;
gMovie_Clone_Info[i].ratio.h = 3;
gMovie_Clone_Info[i].disp_ratio.w = 4;
gMovie_Clone_Info[i].disp_ratio.h = 3;
break;
}
}
mask <<= 1;
}
}
static void MovieFast_OnRecStart(void)
{
UINT32 i, mask;
UINT32 movie_rec_mask, clone_rec_mask;
USIZE thmub_size;
UINT32 uifile_buffer_reserved_sec = 5;
#if HUNTING_CAMERA_MCU == ENABLE
UIMenuStoreInfo *puiPara = sf_ui_para_get();
#endif
if (g_bIsRecStatus) {
return;
} else {
g_bIsRecStatus = TRUE;
}
{
HD_FILEOUT_CONFIG fout_cfg = {0};
HD_PATH_ID fileout_ctrl = 0;
HD_RESULT hd_ret = 0;
if ((hd_ret = hd_fileout_open(0, HD_FILEOUT_CTRL(0), &fileout_ctrl)) != HD_OK) {
DBG_ERR("hd_fileout_open(HD_FILEOUT_CTRL) fail(%d)\n", hd_ret);
}
if ((hd_ret = hd_fileout_get(fileout_ctrl, HD_FILEOUT_PARAM_CONFIG, &fout_cfg)) != HD_OK) {
DBG_ERR("hd_fileout_get(HD_FILEOUT_PARAM_CONFIG) fail(%d)\n", hd_ret);
}
{ //wait_ready
fout_cfg.wait_ready = (UINT32) FALSE; // TRUE or FALSE
}
if ((hd_ret = hd_fileout_set(fileout_ctrl, HD_FILEOUT_PARAM_CONFIG, &fout_cfg)) != HD_OK) {
DBG_ERR("hd_fileout_set(HD_FILEOUT_PARAM_CONFIG) fail(%d)\n", hd_ret);
}
if ((hd_ret = hd_fileout_close(fileout_ctrl)) != HD_OK) {
DBG_ERR("hd_fileout_close(HD_FILEOUT_CTRL) fail(%d)\n", hd_ret);
}
}
#if defined(_UI_STYLE_LVGL_)
fwload_wait_done(CODE_SECTION_05);
flow_lv_init();
#endif
movie_rec_mask = Movie_GetMovieRecMask();
clone_rec_mask = Movie_GetCloneRecMask();
mask = 1;
for (i = 0; i < SENSOR_CAPS_COUNT; i++) {
if ((movie_rec_mask & mask) || (SENSOR_INSERT_MASK & mask)) {
// set thumbnail size
thmub_size.w = MOVIE_THUMB_WIDTH;
thmub_size.h = (thmub_size.w * gMovie_Rec_Info[i].size.h) / gMovie_Rec_Info[i].size.w;
ImageApp_MovieMulti_SetParam(gMovie_Rec_Info[i].rec_id, MOVIEMULTI_PARAM_IMGCAP_THUM_SIZE, (UINT32)&thmub_size);
MovieFast_SetRecParamByRecID(gMovie_Rec_Info[i].rec_id);
MovieFast_SetAq(ImageApp_MovieMulti_GetVdoEncPort(gMovie_Rec_Info[i].rec_id), 4);
}
if (clone_rec_mask & mask) {
// set thumbnail size
thmub_size.w = MOVIE_THUMB_WIDTH;
thmub_size.h = (thmub_size.w * gMovie_Clone_Info[i].size.h) / gMovie_Clone_Info[i].size.w;
ImageApp_MovieMulti_SetParam(gMovie_Clone_Info[i].rec_id, MOVIEMULTI_PARAM_IMGCAP_THUM_SIZE, (UINT32)&thmub_size);
MovieFast_SetRecParamByRecID(gMovie_Clone_Info[i].rec_id);
MovieFast_SetAq(ImageApp_MovieMulti_GetVdoEncPort(gMovie_Clone_Info[i].rec_id), 2);
MovieFast_SetRRC(ImageApp_MovieMulti_GetVdoEncPort(gMovie_Clone_Info[i].rec_id), 1, 1, 1);
}
mask <<= 1;
}
MovieFast_RecMovieStamp();
// trigger record
mask = 1;
for (i = 0; i < SENSOR_CAPS_COUNT; i++)
{
// start clone path first due to some functions (such as 2v1a need this procedure)
if (clone_rec_mask & mask) {
ImageApp_MovieMulti_SetParam(gMovie_Clone_Info[i].rec_id, MOVIEMULTI_PARAM_FILE_WRITE_BLKSIZE, 0x200000);
ImageApp_MovieMulti_SetParam(gMovie_Clone_Info[i].rec_id, MOVIEMULTI_PARAM_FILE_BUFRESSEC, uifile_buffer_reserved_sec);
//ImageApp_MovieMulti_RecStart(gMovie_Clone_Info[i].rec_id);
#if HUNTING_CAMERA_MCU == ENABLE
ImageApp_MovieMulti_SetParam(gMovie_Clone_Info[i].rec_id, MOVIEMULTI_PARAM_FILE_SEAMLESSSEC, puiPara->VideoLenth);
ImageApp_MovieMulti_TrigOnce(gMovie_Clone_Info[i].rec_id, puiPara->VideoLenth);
#else
ImageApp_MovieMulti_SetParam(gMovie_Clone_Info[i].rec_id, MOVIEMULTI_PARAM_FILE_SEAMLESSSEC, 10);
ImageApp_MovieMulti_TrigOnce(gMovie_Clone_Info[i].rec_id, 10);
#endif
}
if (movie_rec_mask & mask) {
ImageApp_MovieMulti_SetParam(gMovie_Rec_Info[i].rec_id, MOVIEMULTI_PARAM_FILE_WRITE_BLKSIZE, 0x200000);
ImageApp_MovieMulti_SetParam(gMovie_Rec_Info[i].rec_id, MOVIEMULTI_PARAM_FILE_BUFRESSEC, uifile_buffer_reserved_sec);
//ImageApp_MovieMulti_RecStart(gMovie_Rec_Info[i].rec_id);
#if HUNTING_CAMERA_MCU == ENABLE
ImageApp_MovieMulti_SetParam(gMovie_Rec_Info[i].rec_id, MOVIEMULTI_PARAM_FILE_SEAMLESSSEC, puiPara->VideoLenth);
ImageApp_MovieMulti_TrigOnce(gMovie_Rec_Info[i].rec_id, puiPara->VideoLenth);
#else
ImageApp_MovieMulti_SetParam(gMovie_Rec_Info[i].rec_id, MOVIEMULTI_PARAM_FILE_SEAMLESSSEC, 10);
ImageApp_MovieMulti_TrigOnce(gMovie_Rec_Info[i].rec_id, 10);
#endif
}
#if SF_TRIGGER_TIME_TEST == ENABLE && HUNTING_CAMERA_MCU == ENABLE
sf_trigger_time_led_cb(1);
#endif
VOS_TICK rec_start_tick;
vos_perf_mark(&rec_start_tick);
MovieFast_Set_RecStartTick(rec_start_tick);
mask <<= 1;
}
//nvt_cmdsys_runcmd("venc info");
}
static void MovieFast_OnRecStop(void)
{
UINT32 i, mask;
UINT32 movie_rec_mask, clone_rec_mask;
if (g_bIsRecStatus) {
g_bIsRecStatus = FALSE;
} else {
return;
}
movie_rec_mask = Movie_GetMovieRecMask();
clone_rec_mask = Movie_GetCloneRecMask();
mask = 1;
for (i = 0; i < SENSOR_CAPS_COUNT; i++) {
// stop clone path first due to some functions (such as 2v1a need this procedure)
if (clone_rec_mask & mask) {
ImageApp_MovieMulti_RecStop(gMovie_Clone_Info[i].rec_id);
}
if (movie_rec_mask & mask) {
ImageApp_MovieMulti_RecStop(gMovie_Rec_Info[i].rec_id);
}
mask <<= 1;
}
if (UI_GetData(FL_MOVIE_DATEIMPRINT) == MOVIE_DATEIMPRINT_ON && ImageApp_MovieMulti_IsStreamRunning(_CFG_STRM_ID_1)==0) {
MovieStamp_Disable();
}
}
static void MovieFast_FileNamingCB(MOVIE_CFG_REC_ID id, char *pFileName)
{
//1. The FileID and DirID is set at booting.
//2. When it can erntry this function, only the File ID (serial number) is accumulated.
//3. If the working mode is normal and it is cyclic recording, please judge the DirID and FileID by yourself before enering next new file recording.
UINT32 nextFolderID = 0, nextFileID = 0;
if (DCF_GetDBInfo(DCF_INFO_IS_9999)) {
DBG_ERR("Exceed max dcf file!\r\n");
pFileName[0] = '\0';
} else {
DCF_GetNextID(&nextFolderID,&nextFileID);
DCF_MakeObjPath(nextFolderID, nextFileID, DCF_FILE_TYPE_MP4, pFileName);
DCF_AddDBfile(pFileName);
DBG_DUMP("%s added to DCF\r\n", pFileName);
#if HUNTING_CAMERA_MCU == ENABLE
char tmp[NMC_TOTALFILEPATH_MAX_LEN] = {'\0'};
sprintf(tmp, "S%03ld%04ld.JPG", nextFolderID, nextFileID);
if(id == _CFG_REC_ID_1){
snprintf(thumb_current_path_main, sizeof(thumb_current_path_main), "%s", tmp);
}
else if(id == _CFG_CLONE_ID_1){
snprintf(thumb_current_path_clone, sizeof(thumb_current_path_clone), "%s", tmp);
}
DBG_DUMP("last send file:%s\r\n", tmp);
#else
if(id == _CFG_REC_ID_1){
snprintf(thumb_current_path_main, sizeof(thumb_current_path_main), "%s", pFileName);
}
else if(id == _CFG_CLONE_ID_1){
snprintf(thumb_current_path_clone, sizeof(thumb_current_path_clone), "%s", pFileName);
}
#endif
}
}
static void MovieFast_Manual_Raw_Task(void* arg)
{
HD_PATH_ID vcap_path = ImageApp_MovieMulti_GetVcapPort(_CFG_REC_ID_1);
HD_PATH_ID vprc_path = ImageApp_MovieMulti_GetVprcInPort(_CFG_REC_ID_1);
HD_RESULT ret;
HD_VIDEO_FRAME frame;
g_is_manual_raw_tsk_running = TRUE;
while(g_manual_raw_tsk_running)
{
ret = hd_videocap_pull_out_buf(vcap_path, &frame, PHOTOFAST_HD_PUSH_PULL_TIMEOUT_MS);
if(ret != HD_OK){
DBG_ERR("hd_videocap_pull_out_buf failed!(%d)\n", ret);
continue;
}
ret = hd_videoproc_push_in_buf(vprc_path, &frame, NULL, PHOTOFAST_HD_PUSH_PULL_TIMEOUT_MS);
if(ret != HD_OK){
DBG_ERR("hd_videoproc_push_in_buf failed!(%d)\n", ret);
hd_videocap_release_out_buf(vcap_path, &frame);
continue;
}
ret = hd_videocap_release_out_buf(vcap_path, &frame);
if(ret != HD_OK){
DBG_ERR("hd_videocap_release_out_buf failed!(%d)\n", ret);
continue;
}
}
while(1)
{
ret = hd_videocap_pull_out_buf(vcap_path, &frame, 33);
if(ret != HD_OK){
DBG_ERR("hd_videocap_pull_out_buf failed!(%d)\n", ret);
break;
}
ret = hd_videoproc_push_in_buf(vprc_path, &frame, NULL, 33);
if(ret != HD_OK){
DBG_ERR("hd_videoproc_push_in_buf failed!(%d)\n", ret);
hd_videocap_release_out_buf(vcap_path, &frame);
break;
}
ret = hd_videocap_release_out_buf(vcap_path, &frame);
if(ret != HD_OK){
DBG_ERR("hd_videocap_release_out_buf failed!(%d)\n", ret);
break;
}
}
DBG_DUMP("MovieFast_Manual_Raw_Task finished\n");
g_is_manual_raw_tsk_running = FALSE;
THREAD_RETURN(0);
}
static void MovieFast_WriteFile_Task(void* arg)
{
lfqueue_t* queue = (lfqueue_t*)arg;
MOVIEFAST_WRITE_QUEUE_PARAM* param;
fastboot_wait_done(BOOT_INIT_FILESYSOK);
if(TRUE == sf_is_card_full())
{
DBG_ERR("ERR card full\r\n");
return ;
}
while(1)
{
param = (MOVIEFAST_WRITE_QUEUE_PARAM*) lfqueue_deq(queue);
if(param == NULL){
vos_util_delay_ms(5);
continue;
}
if(param->va){
DBG_DUMP("Write %s\n", param->path);
FST_FILE fp = FileSys_OpenFile(param->path, FST_OPEN_ALWAYS | FST_OPEN_WRITE);
FileSys_WriteFile(fp, (UINT8*)param->va, &param->size, 0, NULL);
FileSys_CloseFile(fp);
free(param->va);
}
else if(param->frame.phy_addr[0]){
DBG_DUMP("Write %s\n", param->path);
FST_FILE fp = FileSys_OpenFile(param->path, FST_OPEN_ALWAYS | FST_OPEN_WRITE);
FileSys_WriteFile(fp, (UINT8*)param->frame.phy_addr[0], &param->size, 0, NULL);
FileSys_CloseFile(fp);
hd_videoproc_release_out_buf(param->vprc_path_id, &param->frame);
}
if(param){
free(param);
}
}
DBG_DUMP("MovieFast_WriteFile_Task finished\n");
}
static void MovieFast_UserEventCb(UINT32 id, MOVIE_USER_CB_EVENT event_id, UINT32 value)
{
//static UINT32 u32Cnt = 0;
switch ((UINT32)event_id) {
#if 0
case MOVIE_USER_CB_EVENT_REC_ONE_SECOND: {
u32Cnt++;
//DBG_DUMP("%s: u32Cnt=%d\r\n", __func__, u32Cnt);
if (u32Cnt == 10) {
u32Cnt = 0;
vos_flag_set(MOVIEFAST_FLG_ID, FLGMOVIEFAST_SHUTDOWN);
}
}
break;
#endif
case MOVIE_USER_CB_EVENT_CLOSE_FILE_COMPLETED: {
sf_ir_led_set(0, 0, 0, 0);
//MOVIEMULTI_CLOSE_FILE_INFO *info = (MOVIEMULTI_CLOSE_FILE_INFO *)value;
//DCF_AddDBfile(info->path);
//DBG_DUMP("%s added to DCF\r\n", info->path);
vos_flag_set(MOVIEFAST_FLG_ID, FLGMOVIEFAST_SHUTDOWN);
}
break;
case MOVIE_USER_CB_EVENT_RAWENC_PREPARED: {
#if (USE_EXIF == ENABLE)
EXIF_HANDLE_ID HandleID;
HandleID = value;
ExifVendor_Write0thIFD(HandleID);
ExifVendor_WriteExifIFD(HandleID);
ExifVendor_Write0thIntIFD(HandleID);
#endif
}
break;
case MOVIE_USER_CB_EVENT_JENC_DONE:{
MOVIE_JPEG_INFO *ptr = (MOVIE_JPEG_INFO*)value;
if(ptr->sign == MAKEFOURCC('T', 'H', 'U', 'M')){
char* thumb_current_path = NULL;
if(id == _CFG_REC_ID_1){
thumb_current_path = thumb_current_path_main;
}
else if(id == _CFG_CLONE_ID_1){
thumb_current_path = thumb_current_path_clone;
}
if(thumb_current_path){
UINT32 length = strlen(thumb_current_path);
if(length){
char tmp[256] = {'\0'};
#if HUNTING_CAMERA_MCU == ENABLE
snprintf(tmp, sizeof(tmp), "%s%s", MOVIE_THUMB_PATH, thumb_current_path); /* DCF 8.3 naming rule */
#else
snprintf(tmp, sizeof(tmp), "%s%s", MOVIE_THUMB_PATH, (thumb_current_path + (length - 12))); /* DCF 8.3 naming rule */
snprintf(tmp + strlen(tmp) - 3, sizeof(tmp), "%s", "JPG");
#endif
DBG_DUMP("MOVIE_USER_CB_EVENT_JENC_DONE %s\n", tmp);
MOVIEFAST_WRITE_QUEUE_PARAM* param = (MOVIEFAST_WRITE_QUEUE_PARAM*) malloc(sizeof(MOVIEFAST_WRITE_QUEUE_PARAM));
if(param){
memset(param, 0, sizeof(MOVIEFAST_WRITE_QUEUE_PARAM));
param->size = ptr->size;
param->va = (void *)malloc(param->size);
snprintf(param->path, sizeof(param->path), tmp);
if(param->va){
memcpy(param->va, (void*)ptr->addr_va, param->size);
while (lfqueue_enq(&write_queue, (void*) param) == -1)
{
DBG_ERR("ENQ Full ?\r\n");
}
}
else{
DBG_ERR("malloc thumb va err!\n");
free(param);
}
}
thumb_current_path[0] = '\0';
}
}
}
break;
}
case MOVIE_USER_CB_EVENT_FILENAMING_MOV_CB:
case MOVIE_USER_CB_EVENT_FILENAMING_EMR_CB: {
CHAR *pFileName = (CHAR *) value;
if(fastboot_wait_done_timeout(BOOT_INIT_FILENAMINGOK, FASTBOOT_WAIT_FILENAMING_TIMEOUT_MS) == E_OK){
MovieFast_FileNamingCB(id, pFileName);
}
else{
vos_flag_set(MOVIEFAST_FLG_ID, FLGMOVIEFAST_SHUTDOWN);
}
}
break;
}
}
static void MovieFast_CmdTsk_Exit(void)
{
g_moviefast_tsk_run = 0;
}
int MovieFast_GetWaterLogoSource(const UINT32 recWidth,WATERLOGO_BUFFER *waterSrc)
{
#if 0 /* defined (WATERLOGO_FUNCTION) && (WATERLOGO_FUNCTION == ENABLE) */
if(recWidth >= 1080){
memcpy(waterSrc,&g_WaterLogo_1440,sizeof(WATERLOGO_BUFFER));
}else{
memcpy(waterSrc,&g_WaterLogo_640,sizeof(WATERLOGO_BUFFER));
}
#else
memcpy(waterSrc,&g_WaterLogo_640,sizeof(WATERLOGO_BUFFER));
#endif
return E_OK;
}
THREAD_RETTYPE MovieFast_InitFileNamingThread(void *arg)
{
if(DrvGPIO_GetPhotoMovieModeFromMonitor() != DX_HUNTING_MODE_PHOTO_MOVIE ){
if(fastboot_wait_done_timeout(BOOT_INIT_FILESYSOK, FASTBOOT_WAIT_FILESYS_TIMEOUT_MS) != E_OK){
goto EXIT;
}
DCF_InstallID();
DCF_OPEN_PARM dcfParm = {
.Drive = 'A',
.WorkbuffAddr = mempool_dcf,
.WorkbuffSize = POOL_SIZE_DCF_BUFFER,
};
g_dcf_hdl = DCF_Open(&dcfParm);
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);
DCF_ScanObj();
fastboot_set_done(BOOT_INIT_FILENAMINGOK);
}
EXIT:
THREAD_RETURN(0);
}
extern void Set_NIGHTMODE(UINT32 id, UINT8 isSnapVideo);
extern void Set_AEMODE(UINT32 id);
extern void setet_preset_param(void);
void MovieFast_Set_Shutdown_flag(void)
{
vos_flag_set(MOVIEFAST_FLG_ID, FLGMOVIEFAST_SHUTDOWN);
}
static void MovieFast_Load_Sen_Cfg(MOVIEFAST_IQ_CFG cfg)
{
MOVIE_SENSOR_INFO sen_cfg = {0};
MOVIE_SENSOR_INFO *pSenCfg = &sen_cfg;
UINT32 size = sizeof(pSenCfg->iq_path.path) - 1;
for (int i = 0; i < SENSOR_CAPS_COUNT; i++) {
// get sensor info
sen_cfg.rec_id = _CFG_REC_ID_1 + i;
System_GetSensorInfo(i, SENSOR_DRV_CFG, &(sen_cfg.vcap_cfg));
System_GetSensorInfo(i, SENSOR_SENOUT_FMT, &(sen_cfg.senout_pxlfmt));
System_GetSensorInfo(i, SENSOR_CAPOUT_FMT, &(sen_cfg.capout_pxlfmt));
System_GetSensorInfo(i, SENSOR_DATA_LANE, &(sen_cfg.data_lane));
System_GetSensorInfo(i, SENSOR_AE_PATH, &(sen_cfg.ae_path));
System_GetSensorInfo(i, SENSOR_AWB_PATH, &(sen_cfg.awb_path));
System_GetSensorInfo(i, SENSOR_IQ_PATH, &(sen_cfg.iq_path));
System_GetSensorInfo(i, SENSOR_IQ_SHADING_PATH, &(sen_cfg.iq_shading_path));
System_GetSensorInfo(i, SENSOR_IQ_DPC_PATH, &(sen_cfg.iq_dpc_path));
System_GetSensorInfo(i, SENSOR_IQ_LDC_PATH, &(sen_cfg.iq_ldc_path));
if(cfg == MOVIEFAST_IQ_VIDEO){
strncpy(pSenCfg->iq_path.path, "/isp/iq/os05b10_iq_0_vid", size);
}
else{ /* MOVIEFAST_IQ_PHOTO */
if(sf_is_night_mode(0) ==TRUE)
strncpy(pSenCfg->iq_path.path, "/isp/iq/os05b10_iq_0", size);
else
strncpy(pSenCfg->iq_path.path, "/isp/iq/os05b10_iq_0_cap", size);
}
ImageApp_MovieMulti_Config(MOVIE_CONFIG_SENSOR_INFO, (UINT32)&sen_cfg);
}
}
static int MovieFast_fdt_read_mem_node(const char *path, unsigned int *p_addr, unsigned int *p_size)
{
unsigned char *p_fdt = (unsigned char *)fdt_get_base();
if (p_fdt == NULL) {
DBG_ERR("p_fdt is NULL.\n");
return -1;
}
int len;
int nodeoffset;
const void *nodep; /* property node pointer */
// get linux space
nodeoffset = fdt_path_offset(p_fdt, path);
if (nodeoffset < 0) {
DBG_ERR("failed to offset for %s = %d \n", path, nodeoffset);
return -1;
}
nodep = fdt_getprop(p_fdt, nodeoffset, "reg", &len);
if (len == 0 || nodep == NULL) {
DBG_ERR("failed to access reg.\n");
return -1;
} else {
unsigned int *p_data = (unsigned int *)nodep;
*p_addr = be32_to_cpu(p_data[0]);
*p_size = be32_to_cpu(p_data[1]);
}
return 0;
}
static int MovieFast_fdt_get_info(FDT_INFO *p_info)
{
int er;
if ((er = MovieFast_fdt_read_mem_node(MEM_PATH_LINUX, &p_info->linux_addr, &p_info->linux_size)) != 0) {
return er;
}
DBG_DUMP("linux addr:%lx size:%lx\n", p_info->linux_addr, p_info->linux_size);
return 0;
}
static int MovieFast_fdt_get_tmp_buf(FDT_INFO *p_info, UINT32* addr, UINT32* size)
{
if(p_info && addr && size){
*addr = (UINT32)(p_info->linux_addr + 0x1000); /* linux kernel is start from 0x0, add offset to avoid null check */
*size = (UINT32)(p_info->linux_size - 0x1000);
return E_OK;
}
else{
DBG_ERR("p_inf or addr or size is null\n");
return E_SYS;
}
}
static INT32 MovieFast_Mode2_Get_Cont_Shot(UINT32* max_cnt, UINT32* duration)
{
#if HUNTING_CAMERA_MCU == ENABLE
UIMenuStoreInfo *puiPara = sf_ui_para_get();
#endif
if(max_cnt == NULL || duration == NULL){
DBG_ERR("max_cnt & max_cnt can't be null!\n");
return E_SYS;
}
switch (UI_GetData(FL_CONTINUE_SHOT))//puiPara->Multishot
{
case CONTINUE_SHOT_BURST_5:
case CONTINUE_SHOT_BURST_4:
{
DBG_WRN("MovieFast mode2 only support CONTINUE_SHOT_BURST_3\n");
*max_cnt = 3;
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 HUNTING_CAMERA_MCU == ENABLE
if(SF_MULTISHOT_INTEVEL_1S == puiPara->MultiShotIntevel)
{
*duration = 1000;//The interval between consecutive shots of each photo is 1 second
}
else if(SF_MULTISHOT_INTEVEL_2S == puiPara->MultiShotIntevel) {
*duration = 2000;//The interval between consecutive shots of each photo is 2 second
}
else {
*duration = 1000 / *max_cnt;//SF_MULTISHOT_INTEVEL_0S
}
#else
*duration = 1000 / *max_cnt;
#endif
return E_OK;
}
THREAD_RETTYPE MovieFast_InitMovieModeThread(void *arg)
{
UINT32 i;
MOVIEMULTI_MAX_LINK_INFO MaxLinkInfo = {1, 0, 0, 1, 0}; //Img, Disp, Wifi, AudCap, EthCam
DBG_FUNC("\r\n");
// UINT32 rec_type = MovieMapping_GetRecType(UI_GetData(FL_MOVIE_SIZE));
Movie_CommPoolInit();
if(DrvGPIO_GetPhotoMovieModeFromMonitor() == DX_HUNTING_MODE_MOVIE2){
//UI_SetData(FL_MOVIE_SIZE, MOVIE_SIZE_CLONE_1920x1080P30_1280x720P30);
Set_NIGHTMODE(0, 0);
nvt_cmdsys_runcmd("ae set_speed 0 128 700 700 100 ");
}
else{
Set_NIGHTMODE(0, 1);
Set_AEMODE(0);
}
MovieFast_SetRecInfoByUISetting();
#if (_PACKAGE_DISPLAY_)
gMovie_Disp_Info.vout_ctrl = GxVideo_GetDeviceCtrl(DOUT1,DISPLAY_DEVCTRL_CTRLPATH);
gMovie_Disp_Info.vout_path = GxVideo_GetDeviceCtrl(DOUT1,DISPLAY_DEVCTRL_PATH);
gMovie_Disp_Info.ratio = GxVideo_GetDeviceAspect(0);
gMovie_Disp_Info.dir = SysVideo_GetDirbyID(0);
#endif
MaxLinkInfo.MaxImgLink = SENSOR_CAPS_COUNT;
#if (_PACKAGE_DISPLAY_)
MaxLinkInfo.MaxDispLink = 1;
#endif
ImageApp_MovieMulti_Config(MOVIE_CONFIG_MAX_LINK_INFO, (UINT32) &MaxLinkInfo);
ImageApp_MovieMulti_Config(MOVIE_CONFIG_RECORD_INFO, (UINT32)&gMovie_Rec_Info[0]);
ImageApp_MovieMulti_Config(MOVIE_CONFIG_RECORD_INFO, (UINT32)&gMovie_Clone_Info[0]);
ImageApp_MovieMulti_Config(MOVIE_CONFIG_ALG_INFO, (UINT32)&gMovie_Alg_Info[0]);
if(DrvGPIO_GetPhotoMovieModeFromMonitor() != DX_HUNTING_MODE_MOVIE2){
MovieFast_Load_Sen_Cfg(MOVIEFAST_IQ_VIDEO);
}
else{
MovieFast_Load_Sen_Cfg(MOVIEFAST_IQ_PHOTO);
}
MovieMapping_GetStreamInfo(UI_GetData(FL_MOVIE_SIZE), (UINT32)&gMovie_Strm_Info);
ImageApp_MovieMulti_Config(MOVIE_CONFIG_STREAM_INFO, (UINT32)&gMovie_Strm_Info);
ImageApp_MovieMulti_Config(MOVIE_CONFIG_AUDIO_INFO, (UINT32)&gMovie_Audio_Info);
#if (_PACKAGE_DISPLAY_)
ImageApp_MovieMulti_Config(MOVIE_CONFIG_DISP_INFO, (UINT32)&gMovie_Disp_Info);
#endif
// File option
ImageApp_MovieMulti_FileOption((MOVIE_RECODE_FILE_OPTION *) &gMovie_Rec_Option);
// User Callback
ImageApp_MovieMulti_RegUserCB(MovieFast_UserEventCb);
#if (MOVIE_DIRECT_FUNC == ENABLE)
ImageApp_MovieMulti_SetParam(_CFG_REC_ID_1, MOVIEMULTI_PARAM_VCAP_OUTFUNC, HD_VIDEOCAP_OUTFUNC_DIRECT);
#endif
ImageApp_MovieMulti_SetParam(_CFG_REC_ID_1, MOVIEMULTI_PRARM_FILEDB_MAX_MUM, 5000);
ImageApp_MovieMulti_SetParam(_CFG_CTRL_ID, MOVIEMULTI_PARAM_FILE_UTC_AUTO_EN, TRUE);
if(DrvGPIO_GetPhotoMovieModeFromMonitor() != DX_HUNTING_MODE_MOVIE2){
MOVIEMULTI_IPL_SIZE_INFO ipl_size={{2560,1440}, 30};
ImageApp_MovieMulti_SetParam(_CFG_REC_ID_1 , MOVIEMULTI_PARAM_IPL_USER_IMG_SIZE, (UINT32)&ipl_size);
ImageApp_MovieMulti_SetParam(_CFG_REC_ID_1 , MOVIEMULTI_PARAM_IPL_FORCED_IMG_SIZE, MOVIE_IPL_SIZE_USER);
}
else{
UIAPP_PHOTO_SENSOR_INFO *sensor_info = UIAppPhoto_get_SensorInfo(0);
MOVIEMULTI_IPL_SIZE_INFO ipl_size={{sensor_info->sSize.w, sensor_info->sSize.h}, 60};
ImageApp_MovieMulti_SetParam(_CFG_REC_ID_1 , MOVIEMULTI_PARAM_IPL_USER_IMG_SIZE, (UINT32)&ipl_size);
ImageApp_MovieMulti_SetParam(_CFG_REC_ID_1 , MOVIEMULTI_PARAM_IPL_FORCED_IMG_SIZE, MOVIE_IPL_SIZE_USER);
MOVIEMULTI_IME_CROP_INFO crop_info = {0};
UINT32 movie_size_idx;
UINT32 rec_type;
movie_size_idx = UI_GetData(FL_MOVIE_SIZE);
rec_type = MovieMapping_GetRecType(movie_size_idx);
if (rec_type == MOVIE_REC_TYPE_FRONT || rec_type == MOVIE_REC_TYPE_CLONE) { // single recording
/* 4:3 -> 16:9 */
// crop_info.IMESize = (USIZE){1920, 1440};
// crop_info.IMEWin = (URECT){0, 180, 1920, 1080};
crop_info.IMESize = (USIZE){
gMovie_Rec_Info[0].size.w,
(gMovie_Rec_Info[0].size.w * 3) / 4};
crop_info.IMEWin = (URECT){
0,
(crop_info.IMESize.h - gMovie_Rec_Info[0].size.h) / 2,
gMovie_Rec_Info[0].size.w,
gMovie_Rec_Info[0].size.h};
ImageApp_MovieMulti_SetParam(_CFG_REC_ID_1 , MOVIEMULTI_PARAM_MAIN_IME_CROP, (UINT32)&crop_info);
}
if (rec_type == MOVIE_REC_TYPE_CLONE) {
/* 4:3 -> 16:9 */
// crop_info.IMESize = (USIZE){640, 480};
// crop_info.IMEWin = (URECT){0, 60, 640, 360};
crop_info.IMESize = (USIZE){
gMovie_Clone_Info[0].size.w,
(gMovie_Clone_Info[0].size.w * 3) / 4};
crop_info.IMEWin = (URECT){
0,
(crop_info.IMESize.h - gMovie_Clone_Info[0].size.h) / 2,
gMovie_Clone_Info[0].size.w,
gMovie_Clone_Info[0].size.h};
ImageApp_MovieMulti_SetParam(_CFG_REC_ID_1 , MOVIEMULTI_PARAM_CLONE_IME_CROP, (UINT32)&crop_info);
}
}
#if (ANR_FUNC == ENABLE)
HD_AUDIOCAP_ANR audio_cfg_param = {0};
// set audio ANR function parameter
audio_cfg_param.enabled = TRUE;
audio_cfg_param.suppress_level = 13;
audio_cfg_param.hpf_cut_off_freq = 200;
audio_cfg_param.bias_sensitive = 9;
ImageApp_MovieMulti_SetParam(_CFG_REC_ID_1, MOVIEMULTI_PARAM_AUD_ACAP_ANR, (UINT32)&audio_cfg_param);
#endif
setet_preset_param();
ImageApp_MovieMulti_SetParam(_CFG_REC_ID_1, MOVIEMULTI_PARAM_FILE_USE_FILEDB, FALSE);
ImageApp_MovieMulti_SetParam(_CFG_REC_ID_1, MOVIEMULTI_PARAM_FILE_CB_CLOSED_FILE_INFO, TRUE);
#if FIX_RECORD_NOISE == ENABLE
ImageApp_MovieMulti_SetParam(0, MOVIEMULTI_PARAM_AUD_MUTE_ENC_FUNC_EN, TRUE);
ImageApp_MovieMulti_SetParam(0, MOVIEMULTI_PARAM_AUD_MUTE_ENC, TRUE);
#endif
ImageApp_MovieMulti_SetParam(_CFG_REC_ID_1, MOVIEMULTI_PARAM_MANUAL_PUSH_RAW_FRAME, TRUE);
ImageApp_MovieMulti_Open();
for (i = 0; i < SENSOR_CAPS_COUNT; i++) {
ImageApp_MovieMulti_SetParam(_CFG_REC_ID_1 + i, MOVIEMULTI_PARAM_FILE_FRONT_MOOV, TRUE);
ImageApp_MovieMulti_SetParam(_CFG_REC_ID_1 + i, MOVIEMULTI_PARAM_FILE_FRONT_MOOV_FLUSH_SEC, 2);
}
if(DrvGPIO_GetPhotoMovieModeFromMonitor() == DX_HUNTING_MODE_MOVIE2){
HD_PATH_ID vprc_in_id = ImageApp_MovieMulti_GetVprc3DNRPort(_CFG_REC_ID_1);
HD_PATH_ID vprc_main_id = ImageApp_MovieMulti_GetVprcPort(_CFG_REC_ID_1, IAMOVIE_VPRC_EX_MAIN);
HD_PATH_ID vprc_alg_id = ImageApp_MovieMulti_GetVprcPort(_CFG_REC_ID_1, IAMOVIE_VPRC_EX_ALG);
HD_PATH_ID vprc_clone_id = ImageApp_MovieMulti_GetVprcPort(_CFG_REC_ID_1, IAMOVIE_VPRC_EX_CLONE);
HD_VIDEOPROC_OUT_EX vprc_out = {0};
HD_VIDEOPROC_IN vprc_in = {0};
hd_videoproc_get(vprc_in_id, HD_VIDEOPROC_PARAM_IN, &vprc_in);
vprc_in.frc = HD_VIDEO_FRC_RATIO(1, 1);
hd_videoproc_set(vprc_in_id, HD_VIDEOPROC_PARAM_IN, &vprc_in);
/* alg */
hd_videoproc_get(vprc_alg_id, HD_VIDEOPROC_PARAM_OUT_EX, &vprc_out);
vprc_out.frc = HD_VIDEO_FRC_RATIO(1, 1);
hd_videoproc_set(vprc_alg_id, HD_VIDEOPROC_PARAM_OUT_EX, &vprc_out);
/* main */
hd_videoproc_get(vprc_main_id, HD_VIDEOPROC_PARAM_OUT_EX, &vprc_out);
vprc_out.frc = HD_VIDEO_FRC_RATIO(1, 1);
// vprc_out.depth = 0; /* raw encode */
hd_videoproc_set(vprc_main_id, HD_VIDEOPROC_PARAM_OUT_EX, &vprc_out);
/* clone */
hd_videoproc_get(vprc_clone_id, HD_VIDEOPROC_PARAM_OUT_EX, &vprc_out);
vprc_out.frc = HD_VIDEO_FRC_RATIO(1, 1);
// vprc_out.depth = 0;
hd_videoproc_set(vprc_clone_id, HD_VIDEOPROC_PARAM_OUT_EX, &vprc_out);
}
if (1){//gMovie_Alg_Info[_CFG_REC_ID_1 + i].path13.ImgSize.w && gMovie_Alg_Info[_CFG_REC_ID_1 + i].path13.ImgSize.h) {
ImageApp_MovieMulti_ImgLinkForAlg((_CFG_REC_ID_1 ), _CFG_ALG_PATH3, ENABLE, TRUE);
}
#if (_PACKAGE_DISPLAY_)
ImageApp_MovieMulti_ImgLinkForDisp(_CFG_REC_ID_1, DISABLE, TRUE);
#endif
// start acap function
ImageApp_MovieMulti_AudCapStart(0);
#if (USE_EXIF == ENABLE)
ImageApp_MovieMulti_SetParam(_CFG_REC_ID_1, MOVIEMULTI_PARAM_IMGCAP_EXIF_EN, TRUE);
//ImageApp_MovieMulti_SetParam(_CFG_REC_ID_1, MOVIEMULTI_PARAM_IMGCAP_THUM_WITH_EXIF, TRUE); // enable if wants exif in mp4 thumbnail
MovieExe_InitExif();
#endif
if(lfqueue_init(&write_queue)){
DBG_ERR("init write_queue failed\n");
}
else{
if ((g_moviefast_write_tsk_id = vos_task_create(MovieFast_WriteFile_Task, &write_queue, "MovieFastThumTsk", PRI_MOVIEFAST_CMDTSK, STKSIZE_MOVIEFAST_CMDTSK)) == 0) {
DBG_ERR("MovieFast_Thumb_Task create failed.\r\n");
} else {
vos_task_resume(g_moviefast_write_tsk_id);
}
}
MovieFast_InstallID();
{
HD_VIDEO_FRAME frame;
HD_PATH_ID alg_path;
HD_PATH_ID vcap_path, vprc_path;
BOOL stop = FALSE;
UINT32 ae_cnt = 0;
UINT32 stop_cnt = 0;
BOOL ae_locked = FALSE;
HD_RESULT ret;
if(DrvGPIO_GetPhotoMovieModeFromMonitor() == DX_HUNTING_MODE_MOVIE2){
ae_cnt = 6;
stop_cnt = 12;
}
else{
ae_cnt = 9999;
stop_cnt = 12;
}
alg_path = ImageApp_MovieMulti_GetAlgDataPort(_CFG_REC_ID_1, _CFG_ALG_PATH3);
vcap_path = ImageApp_MovieMulti_GetVcapPort(_CFG_REC_ID_1);
vprc_path = ImageApp_MovieMulti_GetVprcInPort(_CFG_REC_ID_1);
vos_perf_mark(&g_alg_start_time);
do {
ret = hd_videocap_pull_out_buf(vcap_path, &frame, PHOTOFAST_HD_PUSH_PULL_TIMEOUT_MS);
if(ret != HD_OK){
DBG_ERR("hd_videocap_pull_out_buf failed!(%d)\n", ret);
}
ret = hd_videoproc_push_in_buf(vprc_path, &frame, NULL, PHOTOFAST_HD_PUSH_PULL_TIMEOUT_MS);
if(ret != HD_OK){
DBG_ERR("hd_videoproc_push_in_buf failed!(%d)\n", ret);
}
ret = hd_videocap_release_out_buf(vcap_path, &frame);
if(ret != HD_OK){
DBG_ERR("hd_videocap_release_out_buf failed!(%d)\n", ret);
}
ret = hd_videoproc_pull_out_buf(alg_path, &frame, PHOTOFAST_HD_PUSH_PULL_TIMEOUT_MS);
if(ret != HD_OK){
DBG_ERR("hd_videoproc_pull_out_buf failed!(%d)\n", ret);
}
DBG_DUMP("count = %llu, timestamp = %llu\n", frame.count, frame.timestamp);
if(frame.count >= ae_cnt && ae_locked == FALSE){
DBG_DUMP("timestamp = %llu count = %llu\n", frame.timestamp, frame.count);
if(DrvGPIO_GetPhotoMovieModeFromMonitor() == DX_HUNTING_MODE_MOVIE2){
#if 0
HD_PATH_ID vprc_in_id = ImageApp_MovieMulti_GetVprc3DNRPort(_CFG_REC_ID_1);
HD_VIDEOPROC_IN vprc_in = {0};
hd_videoproc_get(vprc_in_id, HD_VIDEOPROC_PARAM_IN, &vprc_in);
vprc_in.frc = HD_VIDEO_FRC_RATIO(1, 1);
hd_videoproc_set(vprc_in_id, HD_VIDEOPROC_PARAM_IN, &vprc_in);
hd_videoproc_start(vprc_in_id);
#endif
}
Set_AEMODE(1);
setet_preset_param();
ae_locked = TRUE;
}
if(frame.count >= stop_cnt){
stop = TRUE;
}
hd_videoproc_release_out_buf(alg_path, &frame);
} while(stop == FALSE);
vos_perf_mark(&g_alg_end_time);
}
if ((g_moviefast_power_off_tsk_id = vos_task_create(MovieFast_PowerOffTsk, 0, "MovieFastPwrTsk", PRI_MOVIEFAST_CMDTSK, STKSIZE_MOVIEFAST_CMDTSK)) == 0) {
DBG_ERR("MovieFast_PowerOffTsk create failed.\r\n");
} else {
vos_task_resume(g_moviefast_power_off_tsk_id);
}
if ((g_moviefast_tsk_id = vos_task_create(MovieFast_CmdTsk, 0, "MovieFastTsk", PRI_MOVIEFAST_CMDTSK, STKSIZE_MOVIEFAST_CMDTSK)) == 0) {
DBG_ERR("MovieFast_CmdTsk create failed.\r\n");
} else {
vos_task_resume(g_moviefast_tsk_id);
}
if ((g_moviefast_raw_tsk_id = vos_task_create(MovieFast_Manual_Raw_Task, 0, "MovieFastRawTsk", PRI_MOVIEFAST_CMDTSK, STKSIZE_MOVIEFAST_CMDTSK)) == 0) {
DBG_ERR("MovieFast_Manual_Raw_Task create failed.\r\n");
} else {
g_manual_raw_tsk_running = TRUE;
vos_task_resume(g_moviefast_raw_tsk_id);
}
vos_flag_set(MOVIEFAST_FLG_ID, FLGMOVIEFAST_RECSTART);
VOS_TICK t1, t2;
vos_perf_mark(&t1);
#if 1
FDT_INFO fdt_info;
UINT32 tmp_buf, tmp_buf_size;
UINT32 cnt = 0;
UIAPP_PHOTO_SENSOR_INFO *sensor_info = UIAppPhoto_get_SensorInfo(0);
UINT32 yuv_size = 0;
HD_PATH_ID alg_path = ImageApp_MovieMulti_GetAlgDataPort(_CFG_REC_ID_1, _CFG_ALG_PATH3);
UINT32 max_cnt , duration;
CHKPNT;
MovieFast_fdt_get_info(&fdt_info);
if(MovieFast_fdt_get_tmp_buf(&fdt_info, &tmp_buf, &tmp_buf_size) != E_OK){
DBG_ERR("get tmp buffer failed\n");
goto EXIT;
}
if(MovieFast_Mode2_Get_Cont_Shot(&max_cnt, &duration) != E_OK){
DBG_ERR("get cont shut failed\n");
goto EXIT;
}
CHKPNT;
yuv_size = VDO_YUV_BUFSIZE(sensor_info->sSize.w, sensor_info->sSize.h , HD_VIDEO_PXLFMT_YUV420);
CHKPNT;
do {
HD_VIDEO_FRAME frame = {0};
if((tmp_buf + yuv_size) > (tmp_buf + tmp_buf_size)){
DBG_ERR("tmp buffer overflow!!\n");
goto EXIT;
}
hd_videoproc_pull_out_buf(alg_path, &frame, -1);
DBG_DUMP("tmp_buf = %lx , frame.phy_addr[0] = %lx , copy size = %lx\n", tmp_buf, frame.phy_addr[0], yuv_size);
memcpy((void*)(tmp_buf), (void*)frame.phy_addr[0], yuv_size);
tmp_buf += yuv_size;
hd_videoproc_release_out_buf(alg_path, &frame);
if(++cnt >= max_cnt)
break;
vos_util_delay_ms(duration);
} while(1);
#endif
vos_perf_mark(&t2);
#if FIX_RECORD_NOISE == ENABLE
UINT32 elapse_time_ms = ((t2 - t1) / 1000);
CHKPNT;
if(elapse_time_ms < 300)
vos_util_delay_ms(300 - elapse_time_ms);
ImageApp_MovieMulti_SetParam(0, MOVIEMULTI_PARAM_AUD_MUTE_ENC, FALSE);
#endif
EXIT:
THREAD_RETURN(0);
}
static void MovieFast_Close(void)
{
if(g_moviefast_raw_tsk_id){
UINT32 delay_cnt;
delay_cnt = 10;
g_manual_raw_tsk_running = FALSE;
while (g_is_manual_raw_tsk_running && delay_cnt) {
vos_util_delay_us(10000);
delay_cnt --;
}
if(g_is_manual_raw_tsk_running){
vos_task_destroy(g_moviefast_raw_tsk_id);
g_is_manual_raw_tsk_running = FALSE;
}
g_moviefast_raw_tsk_id = 0;
}
MovieFast_OnRecStop();
MovieStamp_Disable();
MovieStamp_DestroyBuff();
// stop acap function
ImageApp_MovieMulti_AudCapStop(0);
ImageApp_MovieMulti_Close();
if(DrvGPIO_GetPhotoMovieModeFromMonitor() == DX_HUNTING_MODE_MOVIE2){
HD_PATH_ID alg_path = ImageApp_MovieMulti_GetAlgDataPort(_CFG_REC_ID_1, _CFG_ALG_PATH3);
UIAPP_PHOTO_SENSOR_INFO *sensor_info = UIAppPhoto_get_SensorInfo(0);
UINT32 buf_pa = 0;
void* buf_va = 0;
UINT32 max_cnt , duration;
UINT32 tmp_buf, tmp_buf_size;
FDT_INFO fdt_info;
UINT32 yuv_size = 0;
MovieFast_fdt_get_info(&fdt_info);
if(MovieFast_fdt_get_tmp_buf(&fdt_info, &tmp_buf, &tmp_buf_size) != E_OK){
DBG_ERR("get tmp buffer failed\n");
goto EXIT;
}
if(MovieFast_Mode2_Get_Cont_Shot(&max_cnt, &duration) != E_OK){
DBG_ERR("get cont shut failed\n");
goto EXIT;
}
yuv_size = VDO_YUV_BUFSIZE(sensor_info->sSize.w, sensor_info->sSize.h , HD_VIDEO_PXLFMT_YUV420);
PhotoFast_Movie_Init();
PhotoFast_SliceEncode_Open(alg_path);
PhotoFast_SliceEncode2_Open(alg_path, max_cnt);
for(UINT32 i = 0 ; i < max_cnt ; i++)
{
HD_VIDEO_FRAME frame = {0};
UINT32 addr_dst[HD_VIDEO_MAX_PLANE] = {0};
UINT32 loff_dst[HD_VIDEO_MAX_PLANE] = {0};
HD_COMMON_MEM_VB_BLK blk = 0;
blk = hd_common_mem_get_block(HD_COMMON_MEM_COMMON_POOL, yuv_size, DDR_ID0); // Get block from mem pool
if (blk == HD_COMMON_MEM_VB_INVALID_BLK) {
DBG_ERR("hd_common_mem_get_block failed!(size=%lx)\n", yuv_size);
}
buf_pa = hd_common_mem_blk2pa(blk);
if (buf_pa == 0) {
DBG_ERR("hd_common_mem_blk2pa failed!(blk=0x%x)\n", blk);
}
buf_va = (void*)hd_common_mem_mmap(HD_COMMON_MEM_MEM_TYPE_CACHE, buf_pa, yuv_size);
if (buf_va == 0) {
DBG_ERR("hd_common_mem_mmap failed!\r\n");
}
if(buf_pa){
/* dst img */
addr_dst[0] = buf_pa;
loff_dst[0] = sensor_info->sSize.w;
addr_dst[1] = addr_dst[0] + loff_dst[0] * sensor_info->sSize.h;
loff_dst[1] = sensor_info->sSize.w;
vf_init_ex(&frame, sensor_info->sSize.w, sensor_info->sSize.h, HD_VIDEO_PXLFMT_YUV420, loff_dst, addr_dst);
memcpy((void*)buf_pa, (void*)(tmp_buf), yuv_size);
tmp_buf += yuv_size;
DBG_DUMP("enq %lu\n", i);
while(1)
{
if(PhotoFast_Sliceencode2_Enq_Frame(&frame) == E_OK){
break;
}
else{
vos_util_delay_ms(1);
}
}
}
else{
DBG_ERR("allocate %lx failed!\n", yuv_size);
}
}
fastboot_set_done(BOOT_FLOW_MOVIE2);
PhotoFast_SliceEncode2_Close();
}
EXIT:
DCF_Close(g_dcf_hdl);
DCF_UnInstallID();
vos_flag_destroy(MOVIEFAST_FLG_ID);
}