MWCapture SDK Mac 3.4.62314

- Home
- Development Library
- Release Notes

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.

## Functions
mw_venc_status_t | mw_venc_get_default_param (mw_venc_param_t *p_param)
| Gets the default value of encoding parameters.
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_status_t | mw_venc_put_imagebuffer (mw_venc_handle_t handle, CVImageBufferRef image_buffer, int64_t pts)
| Imports data to encoders.
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_status_t | mw_venc_destory (mw_venc_handle_t handle)
| Destroys encoders.
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_status_t | mw_venc_set_property (mw_venc_handle_t handle, mw_venc_property_t param, void *args)
| Sets encoder parameters.

## 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] | platform | Hardware encoding platform
  [in] | p_param | Encoder parameters
  [in] | frame_callback | Encoder callback function
  [in] | user_ptr | Callback 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;
mw_venc_status_t t_venc_stat = MW_VENC_STATUS_SUCCESS;
mw_venc_get_default_param(&t_venc_param);
t_venc_param.code_type = MW_VENC_CODE_TYPE_H264;
t_venc_param.fourcc = MW_VENC_FOURCC_NV12;
t_venc_param.targetusage = MW_VENC_TARGETUSAGE_BALANCED;
t_venc_param.rate_control.mode = MW_VENC_RATECONTROL_CBR;
t_venc_param.rate_control.target_bitrate = 4096;
t_venc_param.width = 1920;
t_venc_param.height = 1080;
t_venc_param.profile = MW_VENC_PROFILE_H264_MAIN;
...
// 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;
mw_venc_fps_t t_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_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_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_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_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_destory
mw_venc_status_t mw_venc_destory(mw_venc_handle_t handle)
Destroys encoders.
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_status_t
enum mw_venc_status mw_venc_status_t
mw_venc_status_t
MW_VENC_FOURCC_NV12
@ MW_VENC_FOURCC_NV12
NV12 equals MWFOURCC_NV12.
Definition: mw_venc_common.h:200
MW_VENC_CODE_TYPE_H264
@ MW_VENC_CODE_TYPE_H264
H264.
Definition: mw_venc_common.h:94
MW_VENC_STATUS_SUCCESS
@ MW_VENC_STATUS_SUCCESS
Success.
Definition: mw_venc_common.h:306
MW_VENC_TARGETUSAGE_BALANCED
@ MW_VENC_TARGETUSAGE_BALANCED
Balance the coding quality and speed.
Definition: mw_venc_common.h:114
MW_VENC_PROFILE_H264_MAIN
@ MW_VENC_PROFILE_H264_MAIN
H264 main.
Definition: mw_venc_common.h:156
MW_VENC_RATECONTROL_CBR
@ MW_VENC_RATECONTROL_CBR
Constant Bit Rate.
Definition: mw_venc_common.h:135
MW_VENC_PROPERTY_FPS
@ MW_VENC_PROPERTY_FPS
Frame rate: mw_venc_fps_t default 60/1.
Definition: mw_venc_common.h:290
mw_venc_fps
mw_venc_fps_t
Definition: mw_venc_common.h:257
mw_venc_fps::den
int32_t den
Denominator of frames.
Definition: mw_venc_common.h:259
mw_venc_frame_info
mw_venc_frame_info_t @detials Defines the types infomation of frame to be encoded....
Definition: mw_venc_common.h:60
mw_venc_param
mw_venc_param_t
Definition: mw_venc_common.h:420
mw_venc_param::targetusage
mw_venc_targetusage_t targetusage
Preset.
Definition: mw_venc_common.h:423
mw_venc_param::height
int32_t height
Height of input video.
Definition: mw_venc_common.h:426
mw_venc_param::rate_control
mw_venc_rate_control_t rate_control
Frame control.
Definition: mw_venc_common.h:424
mw_venc_param::profile
mw_venc_profile_t profile
Profile.
Definition: mw_venc_common.h:431
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_param::width
int32_t width
width of input video
Definition: mw_venc_common.h:425
mw_venc_param::fourcc
mw_venc_fourcc_t fourcc
Color format of input data.
Definition: mw_venc_common.h:422
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_rate_control::mode
mw_venc_rate_control_mode_t mode
Bitrate controlling methods.
Definition: mw_venc_common.h:229

## ◆ mw_venc_destory()

mw_venc_status_t mw_venc_destory | ( | mw_venc_handle_t | handle | ) |

Destroys encoders.

Parameters

  [in] | handle | Encoder 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_param | encoding 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_FOURCC_UNKNOWN
@ MW_VENC_FOURCC_UNKNOWN
Unknown.
Definition: mw_venc_common.h:199
MW_VENC_CODE_TYPE_UNKNOWN
@ MW_VENC_CODE_TYPE_UNKNOWN
Unknown.
Definition: mw_venc_common.h:91
MW_VENC_LEVEL_5_1
@ MW_VENC_LEVEL_5_1
Level 5.1.
Definition: mw_venc_common.h:179
MW_VENC_PROFILE_UNKNOWN
@ MW_VENC_PROFILE_UNKNOWN
Unknown.
Definition: mw_venc_common.h:154
MW_VENC_RATECONTROL_UNKNOWN
@ MW_VENC_RATECONTROL_UNKNOWN
Unknown.
Definition: mw_venc_common.h:134

## ◆ 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] | handle | Encoder handle
  [in] | param | Parameter type
  [out] | args | Parameter 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] | handle | Encoder handle
  [in] | p_frame | Frame data
  [in] | pts | Time 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] | handle | Encoder handle
  [in] | p_frame | Frame 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] | handle | Encoder handle @parma[in] param Parameter type
  [in] | args | Parameter 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