📄 video_enc_glb.h
字号:
m4v_enc_im im;
/// VOS information
///
MP4VIDEO_VOS_STRUCT VOS;
/// safty check for imgdma isr reentry count.
///
kal_uint8 safty_check_count;
/// Current recode time duration
///
kal_uint64 current_time_duration;
/// Previous time stamp, this value is used to caluate the current_time_duration.
///
kal_uint32 prev_time_stamp;
/// this variable will stop the software encode process. But HW is not stop.
///
kal_bool encode_stop;
/// total lost frames from camera
///
kal_uint32 lost_frames;
/// This variable will force to drop the bitstream from video buffer.
///
kal_bool drop_bitstream;
/// This variable can force the mpeg4 software engine to encode as I frame.
///
kal_bool force_I_frame;
/// Large quant count
///
kal_bool large_quant_count;
/// This variable is used for error recovery, when mcu loading is not enough.
/// Then, Driver will always check the buffer status, and run the recovery action.
kal_bool is_need_to_check_buffer;
/// Maximum check count when buffer status should be checked.
/// Before this check count, our system must recover.
/// Otherwise, driver will threat it as crach.
kal_uint8 chk_buffer_status_count;
/// switch buffer callback function. for error recovery.
///
void (*switch_buffer_callback)(void);
/// audio recode callback function from MED task, and register to audio driver.
///
void (*audio_record_callback)(Media_Event event);
/// video encode callback function from MED task. Driver can notify MED its
/// events through this function.
void (*video_enc_callback)(kal_uint8 event);
/// This variabe indicated if task is preparing bitstream data to driver.
///
kal_bool is_task_prepare_video_data;
/// This variabe indicated if task is preparing meta data to driver.
///
kal_bool is_task_prepare_meta_data;
/// How many frames to skip
///
kal_uint8 skip_frame_count;
/// video encode function stage
///
VIDEO_ENC_STAGE stage;
/// Store the current bitstream addr in buffer.
///
kal_uint32 current_bitstream_addr;
/// Total file size
///
kal_uint32 total_file_size;
/// ISR(ImgDMA) encode total frames
///
kal_uint32 total_frames;
/// HISR executed total frames
///
kal_uint32 hisr_total_frames;
}VIDEO_ENC_STRUCT;
typedef struct {
/// Encoder is running or not
///
kal_bool running;
/// video scenario
///
VIDEO_SCENARIO_ENUM scenario;
/// Video encode status
///
VIDEO_ENC_STATUS VIDEO_STATUS;
/// The status of file system
///
kal_int32 FS_STATUS;
/// Store the file that result FSAL_Status
///
STFSAL *FSAL_ERROR_FILE;
/// The status of file system abstration layer
///
FSAL_Status FSAL_STATUS;
}VIDEO_ENC_STATUS_STRUCT;
typedef struct {
RC_STRUCT rc_data;
m4v_enc_im im;
kal_bool pause_already;
kal_uint32 total_frames;
kal_uint32 hisr_total_frames;
kal_uint32 bit_rate;
kal_uint32 current_time_duration;
kal_uint32 prev_time_stamp;
kal_uint16 FRAME_RATE;
kal_uint32 time_scale;
Media_Format video_enc_audio_format;
kal_uint32 total_file_size;
} VIDEO_ENC_PAUSE_INFO;
#ifdef __VIDEO_GET_YUV_DATA__
#define VIDEO_YUV_MAX_BUFFER 16
typedef struct {
union{
kal_uint32 yuvCIF[VIDEO_YUV_MAX_BUFFER][352*288*3/8];
kal_uint32 yuvQCIF[VIDEO_YUV_MAX_BUFFER*4][176*144*3/8];
}yuvdata;
kal_uint32 read_index;
kal_uint32 write_index;
STFSAL MEDIA_YUV_FILE;
kal_bool send_ilm;
kal_bool enable_log;
kal_uint32 yuv_max_buffer_count;
kal_bool cif_size;
} VIDEO_YUV_DATA_STRUCT;
extern VIDEO_YUV_DATA_STRUCT video_yuv;
#endif /*__VIDEO_GET_YUV_DATA__*/
typedef struct
{
kal_uint8 *frame_buffer_addr;
kal_uint8 *working_memory;
} MPEG4_ENCODE_STRUCT;
/*Input struct: Jensen ==Start*/
typedef struct {
kal_bool short_header;
kal_uint32 bit_rate;
kal_uint16 frame_width;
kal_uint16 frame_height;
void (*call_back)(kal_uint8 event);
} MP4ENC_SETUP_STRUCT;
typedef struct {
kal_uint32 frame;
kal_uint8 *input_yuv_data;
kal_uint8 *bitstreams_ptr;
kal_uint32 buffer_length;
m4v_enc_im *im;
} MP4ENC_PROC_STRUCT;
/*Input struct: Jensen, for function input ==END*/
extern void (*audio_record_callback)(Media_Event event);
extern Media_Format video_enc_audio_format;
extern kal_uint32 video_enc_get_bitstream_file_size(void);
/*encode*/
/**
* This function will store the audio callback function to "audio_record_callback" variable,
* and register it to audio driver at the proper time.
* @param audio_rec_callback audio callback function
* @return None
*
*/
extern void video_enc_audiocallback(void (*audio_rec_callback)(Media_Event event));
/**
* This function will store the video bitstream from bistream buffer to bitstream file.
* This function only used when encode complete.
* @param max_size This variable threated as the max size that med task can offer.
* @param real_store_size The real size to store to FS.
* When driver store its bitstream, driver can't exceed this value.
* Besides, driver will notify the med task the space driver have used through this variable, too.
* @return Media status, which is based MEDIA_STATUS_CODE structure.
*
*/
extern MEDIA_STATUS_CODE video_enc_buffer_dump_to_file(kal_uint32 max_size, kal_uint32 *real_store_size);
/**
* This function will store the meta information from meta buffer to meta file.
*
* @param max_size This variable threated as the max size that med task can offer.
* @param real_store_size The real size to store to FS.
* When driver store its bitstream, driver can't exceed this value.
* Besides, driver will notify the med task the space driver have used through this variable, too.
* @return Media status, which is based MEDIA_STATUS_CODE structure.
*
*/
extern MEDIA_STATUS_CODE meta_enc_buffer_store_file(kal_uint32 org_max_size, kal_uint32 *real_store_size);
/**
* This function will store the video bitstream from bistream buffer to bitstream file.
* This function only used when driver notify med task "buffer is available".
* @param max_size This variable threated as the max size that med task can offer.
* @param real_store_size The real size to store to FS.
* When driver store its bitstream, driver can't exceed this value.
* Besides, driver will notify the med task the space driver have used through this variable, too.
* @return Media status, which is based MEDIA_STATUS_CODE structure.
*
*/
extern MEDIA_STATUS_CODE video_enc_buffer_store_file(kal_uint32 max_size, kal_uint32 *real_store_size);
/**
* This function will initialize the VIDEO_ENC_STRUCT as default value.
* @param enc_struct VIDEO_ENC_STRUCT structure.
* @param file_type Media file type, based on MMFILE_TYPE structure.
* @param frame_count initial frame count. This value is always 0, except video editor scenario.
* @return Media status, which is based MEDIA_STATUS_CODE structure.
*
*/
extern MEDIA_STATUS_CODE mp4_enc_struct_init(VIDEO_ENC_STRUCT *enc_struct, MMFILE_TYPE file_type, kal_uint32 frame_count);
/**
* This function will obtain the current bitstream address from bitstream buffer.
* @param enc_struct VIDEO_ENC_STRUCT structure.
* @return current bitstream address.
*
*/
extern kal_uint32 video_enc_buffer_get_memaddr(VIDEO_ENC_STRUCT *enc_struct);
/**
* This function will obtain the room left value from bitstream buffer.
* @param enc_struct VIDEO_ENC_STRUCT structure.
* @return the room left value of bitstream buffer.
*
*/
extern kal_uint32 video_enc_buffer_get_roomleft(VIDEO_ENC_STRUCT *enc_struct);
/**
* This function will execute and trigger HW to run the encode process.
* @param frame frame number.
* @param input_yuv_data input image yuv420 source.
* @param bitstreams_ptr current bistream address in bitstream buffer.
* @param buffer_length the room left in bitstream buffer
* @param im mpeg4 bitstream information.
* @return Media status, which is based MEDIA_STATUS_CODE structure.
*
*/
extern MEDIA_STATUS_CODE video_enc_proc(MP4ENC_PROC_STRUCT *proc_data);
/**
* This function update the bistream length to bistream buffer structure.
* @param length bitstream length
* @return None
*
*/
extern void video_enc_buffer_update_offset(kal_uint32 length);
/**
* This function obtain intra marco block number from current encode done frame.
* @return intra macro block number.
*
*/
extern kal_uint16 video_enc_get_intra_mb_num(void);
/**
* This function update time_stamp and length of frame to meta buffer.
* @param time_stamp time stamp of the frame.
* @param length encoded frame bitstream length
* @return Media status, which is based MEDIA_STATUS_CODE structure.
*
*/
extern MEDIA_STATUS_CODE mp4_video_enc_push_tableinfo_to_buffer(kal_uint32 time_stamp, kal_uint32 length);
#ifdef __L1_STANDALONE__
/**
* This function send the ilm to notify med task "Encode process is done".
* @param enc_struct VIDEO_ENC_STRUCT structure.
* @return None
*
*/
extern void video_enc_done_send_ilm(VIDEO_ENC_STRUCT *enc_struct);
#endif /*__L1_STANDALONE__*/
/**
* This function send the ilm to notify med task to read out the bistream buffer.
* @param enc_struct VIDEO_ENC_STRUCT structure.
* @return None
*
*/
extern void video_enc_buffer_send_ilm(VIDEO_ENC_STRUCT *enc_struct);
/**
* This function will open the video encode process.
* When calling "video_encode_setup" function, this function is also called.
*
* @param frame_width frame width
* @param frame_height frame height.
* @param frame_count frame initial count! always is 0, execpt video editor scenario.
*
* @return Media status, which is based MEDIA_STATUS_CODE structure.
*
*/
extern MEDIA_STATUS_CODE video_enc_open(kal_uint32 frame_width,
kal_uint32 frame_height,
kal_uint32 frame_count,
kal_bool resume);
/**
* This function will close the video encode process.
*
* @return None
*
*/
extern void video_enc_close(void);
/**
* This function will initialize the VIDEO_ENC_STRUCT structure as default value.
* When calling "video_encode_setup" function, this function is also called.
*
* @param short_header short header mode(H.263) or not(mpeg4).
* @param bit_rate average bitrate
* @param frame_rate average frame rate
* @param frame_width the width of frame
* @param frame_height the height of frame
* @param resume_enable resume feature or not.
* @return Media status, which is based MEDIA_STATUS_CODE structure.
*
*/
extern MEDIA_STATUS_CODE video_enc_init(MP4ENC_SETUP_STRUCT *setup_input, kal_bool resume_enable);
/**
* This function will initialize the encode process for normal case.
*
* @param short_header short header mode(H.263) or not(mpeg4).
* @param bit_rate average bitrate
* @param frame_rate average frame rate
* @param frame_width the width of frame
* @param frame_height the height of frame
* @param skip_frame_count the skip frame count for recode.
* @param call_back video encode callback function which is used when driver want to notify med its status.
* @return Media status, which is based MEDIA_STATUS_CODE structure.
*
*/
extern MEDIA_STATUS_CODE video_encode_setup(MP4ENC_SETUP_STRUCT *setup_input);
/**
* This function will initialize the encode process for resume function.
*
* @param short_header short header mode(H.263) or not(mpeg4).
* @param bit_rate average bitrate
* @param frame_rate average frame rate
* @param frame_width the width of frame
* @param frame_height the height of frame
* @param skip_frame_count the skip frame count for recode.
* @param call_back video encode callback function which is used when driver want to notify med its status.
* @return Media status, which is based MEDIA_STATUS_CODE structure.
*
*/
extern MEDIA_STATUS_CODE video_encode_resume_setup(MP4ENC_SETUP_STRUCT *setup_input);
/**
* This function will notify driver the audio format.
*
* @param audio_format audio format based on Media_Format
* @return None.
*
*/
extern void video_enc_set_audioformat(Media_Format audio_format);
extern void video_enc_resource_init(kal_uint16 frame_width, kal_uint16 frame_height);
/**
* This function will initialize the VIDEO_ENC_STRUCT structure as default value.
* When calling "video_enc_init" function, this function is also called.
*
* @param is_short_header_mode short header mode(H.263) or not(mpeg4).
* @param work_memory the working memeory for mpeg4 encode HW engine.
* @param frame_buffer_memory frame buffer memory. (MT6228/29 should set this memory. Other chip can set NULL)
* @param bitrate average bitrate
* @param im bistream information structure.
* @param frame_width the width of frame
* @param frame_height the height of frame
* @return Media status, which is based MEDIA_STATUS_CODE structure.
*
*/
extern MEDIA_STATUS_CODE video_enc_initialize(MP4ENC_SETUP_STRUCT *setup_inpt, m4v_enc_im *im);
/**
* This function will initialize the VIDEO_ENC_STRUCT structure as default value. Only for resume function.
* When calling "video_enc_init" function, this function is also called.
*
* @param is_short_header_mode short header mode(H.263) or not(mpeg4).
* @param work_memory the working memeory for mpeg4 encode HW engine.
* @param frame_buffer_memory frame buffer memory. (MT6228/29 should set this memory. Other chip can set NULL)
* @param bitrate average bitrate
* @param im bistream information structure.
* @param frame_width the width of frame
* @param frame_height the height of frame
* @return Media status, which is based MEDIA_STATUS_CODE structure.
*
*/
extern MEDIA_STATUS_CODE video_enc_resume_init(MP4ENC_SETUP_STRUCT *setup_inpt, m4v_enc_im *im);
/**
* This function will switch the encode bitstream buffer to available(empty) buffer.(Driver internal use)
*
* @param enc_struct VIDEO_ENC_STRUCT structure.
* @return KAL_TURE: swicth successul.
* KAL_FALSE: No available buffer now.
*
*/
extern kal_bool video_enc_switch_buffer(VIDEO_ENC_STRUCT *enc_struct);
/**
* This function will obtain the status of encode bitstream buffer. (Driver internal use)
*
* @param enc_struct VIDEO_ENC_STRUCT structure.
* @return KAL_TURE: at least one available buffer can be used.
* KAL_FALSE: No available buffer now.
*
*/
extern kal_bool video_enc_get_buffer_status(VIDEO_ENC_STRUCT *enc_struct);
/**
* This function will save the driver necessary information when resume.
*
* @return None
*
*/
extern void video_encode_pause(void);
/**
* This function will stop recoding process, but HW is not stop.
*
* @return None
*
*/
extern void video_enc_stop_record(void);
/**
* This function will evaluate the size of the video header file.
*
* @param short_header_mode short header mode(H.263) or not(mpeg4).
* @return the size of the video header file.
*
*/
extern kal_uint32 video_evaluate_real_meta_file_size(kal_bool short_header_mode);
/**
* This function will obtain the current time when encoding.
*
* @return the current time(Unit:ms)
*
*/
extern kal_uint64 video_enc_get_current_time(void);
/**
* This function will store the necessary information when pause.
*
* @return NULL
*
*/
extern void video_encode_drv_pause(void);
/**
* This function will restore the pause information.
*
* @return NULL
*
*/
extern void video_encode_drv_pause_info_restore(void);
/**
* This function will obtain the previous time stamp (when paused).
*
* @return paused time stamp
*
*/
extern kal_uint32 video_enc_get_prev_time_stamp(void);
#endif /*VIDEO_ENC_GLB_H*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -