MWCapture SDK Mac  3.3.1.16905
Typedefs | Functions
Hardware Encoder Module Functions

Typedefs

typedef void(* MW_ENCODER_CALLBACK) (void *user_ptr, const uint8_t *p_frame, uint32_t frame_len, mw_venc_frame_info_t *p_frame_info)
 Callback functions. More...
 

Functions

mw_venc_status_t mw_venc_get_default_param (mw_venc_param_t *p_param)
 Gets the default value of encoding parameters. More...
 
mw_venc_handle_t mw_venc_create (mw_venc_param_t *p_param, MW_ENCODER_CALLBACK callback, MW_ENCODER_CALLBACK_NALU callback_nalu, void *user_ptr)
 Creates an encoder. More...
 
mw_venc_status_t mw_venc_put_imagebuffer (mw_venc_handle_t handle, CVImageBufferRef image_buffer, int64_t pts)
 Imports data to encoders. More...
 
mw_venc_status_t mw_venc_put_frame (mw_venc_handle_t handle, uint8_t *p_frame, int64_t pts)
 Imports data to encoders. More...
 
mw_venc_status_t mw_venc_destory (mw_venc_handle_t handle)
 Destroys encoders. More...
 
mw_venc_status_t mw_venc_get_property (mw_venc_handle_t handle, mw_venc_property_t param, void *args)
 Gets encoder parameters. More...
 
mw_venc_status_t mw_venc_set_property (mw_venc_handle_t handle, mw_venc_property_t param, void *args)
 Sets encoder parameters. More...
 

Detailed Description

Typedef Documentation

◆ MW_ENCODER_CALLBACK

typedef void(* MW_ENCODER_CALLBACK) (void *user_ptr, const uint8_t *p_frame, uint32_t frame_len, mw_venc_frame_info_t *p_frame_info)

Callback functions.

out code date.
Related function(s):
mw_venc_create
mw_venc_create_ex

Function Documentation

◆ mw_venc_create()

mw_venc_handle_t mw_venc_create ( mw_venc_param_t p_param,
MW_ENCODER_CALLBACK  callback,
MW_ENCODER_CALLBACK_NALU  callback_nalu,
void *  user_ptr 
)

Creates an encoder.

Parameters
[in]platformHardware encoding platform
[in]p_paramEncoder parameters
[in]frame_callbackEncoder callback function
[in]user_ptrCallback parameter
Returns
Returns the encoder handle if succeeded, otherwise returns NULL.

Usage:
The recommended way to call the function is as follows.

....
// Callback function
void encode_callback(
void * user_ptr,
const uint8_t * p_frame,
uint32_t frame_len,
mw_venc_frame_info_t *p_frame_info)
{
// Processes data
}
...
mw_venc_init();
...
mw_venc_handle_t t_handle = NULL;
mw_venc_param_t t_venc_param;
t_venc_param.fourcc = MW_VENC_FOURCC_NV12;
t_venc_param.rate_control.target_bitrate = 4096;
t_venc_param.width = 1920;
t_venc_param.height = 1080;
...
// Creates an encoder
t_handle = mw_venc_create(0,&t_venc_param,encode_callback,NULL);
...
// Inputs data char* t_p_data;
t_venc_stat = mw_venc_put_frame(t_handle,t_p_data);
...
// Gets parameters of encoder
mw_venc_property_t t_property = MW_VENC_PROPERTY_FPS;
t_venc_stat = mw_venc_get_property(t_handle,t_property,&t_fps);
...
//Modifies parameters of encoder
t_fps.num = 30;
t_fps.den = 1;
t_venc_stat = mw_venc_set_property(t_handle,t_property,&t_fps);
...
// Destroys the encoder
t_venc_stat = mw_venc_destory(t_handle);
t_handle = NULL;
...
mw_venc_deinit();
...

◆ mw_venc_destory()

mw_venc_status_t mw_venc_destory ( mw_venc_handle_t  handle)

Destroys encoders.

Parameters
[in]handleEncoder handle
Returns
The possible return values of mw_venc_status_t are as follows.
MW_VENC_STATUS_SUCCESS Function call succeeded.
MW_VENC_STATUS_INVALID_PARAM Input invalid value(s).

Usage:
The usage refers to mw_venc_create mw_venc_create_by_index

◆ mw_venc_get_default_param()

mw_venc_status_t mw_venc_get_default_param ( mw_venc_param_t p_param)

Gets the default value of encoding parameters.

Parameters
[out]p_paramencoding parameters
Returns
The values of returned mw_venc_status_t are as follows.
MW_VENC_STATUS_SUCCESS Function call succeeded.
MW_VENC_STATUS_INVALID_PARAM Input invalid value(s).

Related type(s):
mw_venc_param_t
Sets the default value of the parameters.

p_param->code_type = MW_VENC_CODE_TYPE_UNKNOWN;
p_param->fourcc = MW_VENC_FOURCC_UNKNOWN;
p_param->targetusage = MW_VENC_TARGETUSAGE_BALANCED;
p_param->rate_control.mode = MW_VENC_RATECONTROL_UNKNOWN;
p_param->rate_control.target_bitrate = 0;
p_param->rate_control.max_bitrate = 0;
p_param->width = 0;
p_param->height = 0;
p_param->fps.num = 60;
p_param->fps.den = 1;
p_param->slice_num = 1;
p_param->gop_pic_size = 60;
p_param->gop_ref_size = 1;
p_param->profile = MW_VENC_PROFILE_UNKNOWN;
p_param->level = MW_VENC_LEVEL_5_1;
p_param->amd_mem_reserved = MW_VENC_AMD_MEM_DX;

◆ mw_venc_get_property()

mw_venc_status_t mw_venc_get_property ( mw_venc_handle_t  handle,
mw_venc_property_t  param,
void *  args 
)

Gets encoder parameters.

Parameters
[in]handleEncoder handle
[in]paramParameter type
[out]argsParameter values
Returns
The possible return values of mw_venc_status_t are as follows.
MW_VENC_STATUS_SUCCESS Function call succeeded.
MW_VENC_STATUS_INVALID_PARAM Input invalid value(s).
MW_VENC_STATUS_FAIL Failed to get encoder parameters.
MW_VENC_STATUS_UNSUPPORT Unsupported parameter type.
MW_VENC_STATUS_UNKNOWN_ERROR Failed to get encoder parameters with unknown error.

Usage:
The usage refers to mw_venc_create mw_venc_create_by_index

◆ mw_venc_put_frame()

mw_venc_status_t mw_venc_put_frame ( mw_venc_handle_t  handle,
uint8_t *  p_frame,
int64_t  pts 
)

Imports data to encoders.

Parameters
[in]handleEncoder handle
[in]p_frameFrame data
[in]ptsTime stamp
Returns
The possible return values of mw_venc_status_t are as follows.
MW_VENC_STATUS_SUCCESS Function call succeeded.
MW_VENC_STATUS_INVALID_PARAM Input invalid value(s).
MW_VENC_STATUS_FAIL Function call failed.
MW_VENC_STATUS_UNKNOWN_ERROR Function call failed with unknown errors.

Usage:
The usage refers to mw_venc_create
mw_venc_create_by_index

◆ mw_venc_put_imagebuffer()

mw_venc_status_t mw_venc_put_imagebuffer ( mw_venc_handle_t  handle,
CVImageBufferRef  image_buffer,
int64_t  pts 
)

Imports data to encoders.

Parameters
[in]handleEncoder handle
[in]p_frameFrame data
Returns
The possible return values of mw_venc_status_t are as follows.
MW_VENC_STATUS_SUCCESS Function call succeeded.
MW_VENC_STATUS_INVALID_PARAM Input invalid value(s).
MW_VENC_STATUS_FAIL Function call failed.
MW_VENC_STATUS_UNKNOWN_ERROR Function call failed with unknown errors.

Usage:
The usage refers to mw_venc_create
mw_venc_create_by_index

◆ mw_venc_set_property()

mw_venc_status_t mw_venc_set_property ( mw_venc_handle_t  handle,
mw_venc_property_t  param,
void *  args 
)

Sets encoder parameters.

Parameters
[in]handleEncoder handle @parma[in] param Parameter type
[in]argsParameter values
Returns
The possible return values of mw_venc_status_t are as follows.
MW_VENC_STATUS_SUCCESS Function call succeeded.
MW_VENC_STATUS_INVALID_PARAM Input invalid value(s).
MW_VENC_STATUS_FAIL Function call failed.
MW_VENC_STATUS_UNSUPPORT Unsupported parameter type.

Usage:
The usage refers to mw_venc_create mw_venc_create_by_index

MW_VENC_PROFILE_H264_MAIN
H264 main.
Definition: mw_venc_common.h:156
mw_venc_put_frame
mw_venc_status_t mw_venc_put_frame(mw_venc_handle_t handle, uint8_t *p_frame, int64_t pts)
Imports data to encoders.
MW_VENC_PROPERTY_FPS
Frame rate: mw_venc_fps_t default 60/1.
Definition: mw_venc_common.h:290
mw_venc_param::height
int32_t height
Height of input video.
Definition: mw_venc_common.h:426
MW_VENC_FOURCC_NV12
NV12 equals MWFOURCC_NV12.
Definition: mw_venc_common.h:200
mw_venc_frame_info
mw_venc_frame_info_t @detials Defines the types infomation of frame to be encoded....
Definition: mw_venc_common.h:59
mw_venc_param::profile
mw_venc_profile_t profile
Profile.
Definition: mw_venc_common.h:431
mw_venc_param::targetusage
mw_venc_targetusage_t targetusage
Preset.
Definition: mw_venc_common.h:423
MW_VENC_LEVEL_5_1
Level 5.1.
Definition: mw_venc_common.h:179
mw_venc_param::code_type
mw_venc_code_type_t code_type
Code type, H264 or H265.
Definition: mw_venc_common.h:421
mw_venc_destory
mw_venc_status_t mw_venc_destory(mw_venc_handle_t handle)
Destroys encoders.
mw_venc_param::width
int32_t width
width of input video
Definition: mw_venc_common.h:425
mw_venc_create
mw_venc_handle_t mw_venc_create(mw_venc_param_t *p_param, MW_ENCODER_CALLBACK callback, MW_ENCODER_CALLBACK_NALU callback_nalu, void *user_ptr)
Creates an encoder.
mw_venc_param
mw_venc_param_t
Definition: mw_venc_common.h:420
mw_venc_rate_control::mode
mw_venc_rate_control_mode_t mode
Bitrate controlling methods.
Definition: mw_venc_common.h:229
mw_venc_fps::den
int32_t den
Denominator of frames.
Definition: mw_venc_common.h:259
mw_venc_status_t
enum mw_venc_status mw_venc_status_t
mw_venc_status_t
mw_venc_get_property
mw_venc_status_t mw_venc_get_property(mw_venc_handle_t handle, mw_venc_property_t param, void *args)
Gets encoder parameters.
mw_venc_set_property
mw_venc_status_t mw_venc_set_property(mw_venc_handle_t handle, mw_venc_property_t param, void *args)
Sets encoder parameters.
mw_venc_param::rate_control
mw_venc_rate_control_t rate_control
Frame control.
Definition: mw_venc_common.h:424
mw_venc_rate_control::target_bitrate
uint32_t target_bitrate
Target bitrate(kbit/s): only valid when the bitrate is variable or constant.
Definition: mw_venc_common.h:232
mw_venc_param::fourcc
mw_venc_fourcc_t fourcc
Color format of input data.
Definition: mw_venc_common.h:422
MW_VENC_TARGETUSAGE_BALANCED
Balance the coding quality and speed.
Definition: mw_venc_common.h:114
MW_VENC_CODE_TYPE_H264
H264.
Definition: mw_venc_common.h:94
mw_venc_get_default_param
mw_venc_status_t mw_venc_get_default_param(mw_venc_param_t *p_param)
Gets the default value of encoding parameters.
MW_VENC_PROFILE_UNKNOWN
Unknown.
Definition: mw_venc_common.h:154
MW_VENC_RATECONTROL_CBR
Constant Bit Rate.
Definition: mw_venc_common.h:135
MW_VENC_FOURCC_UNKNOWN
Unknown.
Definition: mw_venc_common.h:199
MW_VENC_CODE_TYPE_UNKNOWN
Unknown.
Definition: mw_venc_common.h:91
MW_VENC_RATECONTROL_UNKNOWN
Unknown.
Definition: mw_venc_common.h:134
mw_venc_fps
mw_venc_fps_t
Definition: mw_venc_common.h:257
MW_VENC_STATUS_SUCCESS
Success.
Definition: mw_venc_common.h:306