K230 video codec API reference#
Overview#
Overview#
The video codec module has powerful functions and can support H.264, H.265 and JPEG codecs. Among them, the VENC module is responsible for implementing 2D calculation and encoding functions. These two functions can be enabled at the same time or can be calculated separately. The VDEC module focuses on implementing decoding functions. It should be noted that VENC, VENC + 2D and VDEC support system binding, but when 2D is operated alone, system binding is not supported.
Functional Description#
Video encoding module#

A typical video encoding process includes multiple key steps, such as the reception of input images, occlusion and coverage processing of image content, image encoding, and final code stream output.
The encoding module is mainly composed of VENC receiving channel, encoding channel, 2D receiving channel and 2D operation module. The specific coding capabilities and 2D computing capabilities are detailed in the table below.
In the encoding data flow diagram, the path indicated by the green arrow is the process of performing 2D operations alone; the path indicated by the blue arrow is the process of performing encoding operations alone; and the path indicated by the purple arrow is the process of performing 2D operations first and then encoding.
H264 |
HEVC |
JPEG |
|
|---|---|---|---|
Input format |
YUV420 NV12 8bit, ARGB8888, BGRA8888 |
YUV420 NV12 8bit, ARGB8888, BGRA8888 |
YUV420 NV12 8bit, YUV422 UYVY 8bit, ARGB8888, BGRA8888 |
Output format |
YUV420 H.264 Baseline Profile(BP) ; H.264 Main Profile(MP) ; H.264 High Profile(HP); H.264 High 10 Profile(HP) |
YUV420 HEVC (H.265) Main ; HEVC (H.265) Main 10 Profile |
YUV420 and YUV422 JPEG baseline sequential |
maximum resolution |
3840x2160 |
3840x2160 |
8192x8192 |
minimum resolution |
128x64 |
128x64 |
128x64 |
rate control mode |
CBR/VBR/FIXQP |
CBR/VBR/FIXQP |
FIXQP |
GOP |
I/P frame |
I/P frame |
- |
encoding channel |
4 way |
4 way |
4 way |
Note: H264/HEVC/JPEG share 4 channels.
video input format |
video output format |
Overlay data format |
maximum resolution |
|---|---|---|---|
I420/NV12/ARGB8888/BGRA8888 |
Same input format |
ARGB8888/ARGB4444/ARGB1555 |
3840x2160 |
encoding channel#
As a basic container, the encoding channel is used to save various user settings of the encoding channel and manage various internal resources of the encoding channel. It mainly completes the functions of image overlay and encoding. Among them, the 2D module is responsible for implementing image superposition operations, and the encoder module is responsible for implementing image encoding. These two modules can be used individually or together.

rate control#
The main function of the rate controller is to accurately control the encoding rate.
From an informatics perspective, the image compression ratio is inversely proportional to the quality of the compressed image, that is, the lower the image compression ratio, the higher the quality of the compressed image; conversely, the higher the image compression ratio, the lower the quality of the compressed image. When the scene changes, if you pursue the stability of image quality, the encoding bit rate will fluctuate greatly; and if you pursue the stability of the encoding bit rate, the image quality will fluctuate greatly. H264/H265 encoding supports three rate control modes: CBR, VBR and FIXQP, while MJPEG only supports FIXQP mode.
CBR: (Constant Bit Rate) fixed bit rate. That is, the encoding code rate is guaranteed to be stable within the code rate statistics time.
VBR: (Variable Bit Rate) variable bit rate, which allows the encoding bit rate to fluctuate within the bit rate statistical time, thereby ensuring stable encoding image quality.
FIXQP: Fixed QP value. Within the code rate statistics time, the QP values of all macroblocks of the encoded image are the same, and the image QP value set by the user is used.
GOP structure#
This module only supports I frames and P frames
2D operations#
The 2D operation module can realize OSD superposition of image data. The OSD mode can realize 8 region image superposition, and each region does not overlap. Supported OSD formats are: ARGB4444/ARGB1555/ARGB8888.
Calculation of 2D conversion coefficients#
During the OSD overlay operation, if the format of the input video is YUV, the OSD layer needs to be converted from RGB to YUV. There is a set of default conversion coefficients in the kernel state. If the user needs to customize a set of 12-bit conversion coefficients, they can obtain it through the RGB to YUV conversion formula.
The known RGB to YUV conversion formula is as follows:

The specific calculation method is: multiply the coefficients in the 3*3 matrix by 256 and then round to an integer to get the corresponding conversion coefficient. The value in the 3*1 matrix is the corresponding conversion coefficient.
Taking BT709 LIMITED as an example, the RGB->YUV conversion formula is:
Y = 0.1826*R + 0.6142*G + 0.0620*B + 16
U = -0.1007*R - 0.3385*G + 0.4392*B + 128
V = 0.4392*R - 0.3990*G - 0.0402*B + 128
From this, the conversion coefficient is: {47, 157, 16, 16, -26, -86, 112, 128, 112, -102, -10, 128 }
Configuration of 2D conversion coefficients#
The 2D conversion coefficient can be configured through the user-defined coefficient interface kd_mpi_venc_set_2d_custom_coef and the color gamut configuration interface kd_mpi_venc_set_2d_color_gamut. The user only needs to select one of the interfaces for configuration. If neither of these interfaces is called before starting the operation, the default coefficients will be used for gamut conversion. Just choose one of the two interfaces to configure. If neither interface is called before starting the operation, the default coefficients will be used for color gamut conversion.
Restrictions#
Encoding operations have the following limitations:
If the input data format is YUV420, the physical starting address of the image data of each component of Y, U, and V needs to be 4k aligned.
If the input data format is NV12, the physical starting address of the image data of Y and UV data needs to ensure 4k alignment.
2D operations have the following limitations:
The source image and the destination image must ensure 8byte align at the physical starting address of ddr.
Supports even-numbered image, osd, and frame sizes.
The src and dst addresses of video data in overlay and frame operations must be the same.
There is a limitation in the decoding operation: the physical starting address of each frame of input data needs to be 4k aligned.
Typical application examples of coding#

Video decoding module#
H264 |
HEVC |
JPEG |
|
|---|---|---|---|
Input format |
H.264 Baseline;H.264 Main;H.264 High;H.264 High10;Support interlaced stream |
HEVC (H.265) Main/Main10 |
JPEG, baseline sequential |
Output format |
YUV420 NV12 |
YUV420 NV12 |
YUV422 UYVY, YUV420 NV12 |
decoding channel |
4 way |
4 way |
4 way |
Note: H264/HEVC/JPEG share 4 channels.
VDEC supports streaming sending:
Streaming sending (K_VDEC_SEND_MODE_STREAM): The user can send a code stream of any length to the decoder each time, and the decoder will internally complete the identification process of one frame of code stream. It should be noted that for H.264/H.265, the end of the current frame code stream cannot be recognized until the next frame code stream is received. Therefore, in this transmission mode, if you input a frame of H.264/H.265 code stream, you cannot expect to start decoding the image immediately.
Decoding typical application examples#

API Reference#
video encoding#
This function module provides the following APIs:
kd_mpi_venc_request_chn: Apply for encoding channel.
kd_mpi_venc_release_chn: Release encoding channel.
kd_mpi_venc_attach_vb_pool: Bind the VB pool to the encoding channel.
kd_mpi_venc_detach_vb_pool: Unbind the VB pool of the encoding channel.
kd_mpi_venc_create_chn: Create encoding channel.
kd_mpi_venc_destroy_chn: Destroy encoding channel.
kd_mpi_venc_start_chn: Open the encoding channel to receive input images.
kd_mpi_venc_stop_chn: Stop the encoding channel from receiving input images.
kd_mpi_venc_query_status: Query the encoding channel status.
kd_mpi_venc_get_stream: Get the encoded code stream.
kd_mpi_venc_release_stream: Release the code stream cache.
kd_mpi_venc_send_frame: Supports users to send raw images for encoding.
kd_mpi_venc_set_rotation: Set the encoding image rotation angle.
kd_mpi_venc_get_rotation: Get the rotation angle of the encoded image.
kd_mpi_venc_set_mirror: Set the encoding image rotation angle.
kd_mpi_venc_get_mirror: Get the encoding image flip mode.
kd_mpi_venc_enable_idr: Enable IDR frames and generate IDR frames according to the GOP interval.
kd_mpi_venc_set_2d_mode: Set the 2D operation mode.
kd_mpi_venc_get_2d_mode: Get the 2D operation mode.
kd_mpi_venc_set_2d_osd_param: Set the area attributes of OSD in 2D operations.
kd_mpi_venc_get_2d_osd_param: Get the area attributes of the OSD at the specified index in the 2D operation.
kd_mpi_venc_set_2d_border_param: Set the frame properties in 2D operations.
kd_mpi_venc_get_2d_border_param: Get the frame attributes in 2D operations.
kd_mpi_venc_set_2d_custom_coef: Set the image format conversion coefficient in 2D operations.
kd_mpi_venc_get_2d_custom_coef: Get the image format conversion coefficient in 2D operation.
kd_mpi_venc_set_2d_color_gamut: Set the color gamut for 2D operations.
kd_mpi_venc_get_2d_color_gamut: Get the color gamut of 2D operation
kd_mpi_venc_attach_2d: Associate 2D operations with venc.
kd_mpi_venc_detach_2d: Separate 2D operations from venc.
kd_mpi_venc_send_2d_frame: Send one frame of data to the 2D module.
kd_mpi_venc_get_2d_frame: Get the 2D operation result.
kd_mpi_venc_start_2d_chn: Start the 2D channel to receive the input image.
kd_mpi_venc_stop_2d_chn: Stop the 2D channel from receiving input images.
kd_mpi_venc_request_idr: Requests an IDR frame and generates an IDR frame immediately after the call.
kd_mpi_venc_set_h265_sao: Set the Sao attribute of the H.265 channel.
kd_mpi_venc_get_h265_sao: Get the Sao attribute of the H.265 channel.
kd_mpi_venc_set_dblk: Set the deblocking enable of the protocol encoding channel.
kd_mpi_venc_get_dblk: Get the Deblocking status of the protocol encoding channel.
kd_mpi_venc_set_intbuf_size: Set the VENC internal buffer size.
kd_mpi_venc_get_2d_csc_param: Get 2D CSC parameters.
kd_mpi_venc_set_h264_entropy: Set the entropy encoding mode of the H.264 protocol encoding channel.
kd_mpi_venc_get_h264_entropy: Get the entropy encoding mode of the H.264 protocol encoding channel.
kd_mpi_venc_set_h265_entropy: Set the entropy encoding mode of the H.265 protocol encoding channel.
kd_mpi_venc_get_h265_entropy: Get the entropy encoding mode of the H.265 protocol encoding channel.
kd_mpi_venc_request_chn#
Description
Apply for a coding channel.
Syntax
k_s32 kd_mpi_venc_request_chn(k_u32* chn_num);
Parameters
Parameter Name |
Description |
Input/Output |
|---|---|---|
chn_num |
Output the applied encoding channel number, value range: [0,VENC_MAX_CHN_NUMS). |
Output |
Return Value
Return Value |
Description |
|---|---|
0 |
success. |
non-0 |
Failure, see error code. |
Chip differences
None.
Requirements
Header File: mpi_venc_api.h,k_type.h,k_module.h,k_sys_comm.h,k_venc_comm.h
Library File: libvenc.a
Example
None.
Related Topics
None.
kd_mpi_venc_release_chn#
Description
Release encoding channel.
Syntax
k_s32 kd_mpi_venc_release_chn(k_u32 chn_num);
Parameters
Parameter Name |
Description |
Input/Output |
|---|---|---|
chn_num |
Encoding channel number. Value range: [0,VENC_MAX_CHN_NUMS). |
Input |
Return Value
Return Value |
Description |
|---|---|
0 |
success. |
non-0 |
Failure, see error code. |
Chip differences
None.
Requirements
Header File: mpi_venc_api.h,k_type.h,k_module.h,k_sys_comm.h,k_venc_comm.h
Library File: libvenc.a
Notes
You must stop receiving images and destroy channel-related resources before releasing, otherwise failure will be returned.
Example
None.
Related Topics
kd_mpi_venc_attach_vb_pool#
Description
Bind the VB pool to the encoding channel.
Syntax
k_s32 kd_mpi_venc_attach_vb_pool(k_u32 chn_num, k_u32 pool_id) { return kd_mpi_venc_attach_vb_pool_ex(chn_num, pool_id, 0); }
Parameters
Parameter Name |
Description |
Input/Output |
|---|---|---|
chn_num |
Encoding channel number. Value range: [0,VENC_MAX_CHN_NUMS). |
Input |
pool_id |
VB pool ID. |
Input |
Return Value
Return Value |
Description |
|---|---|
0 |
success. |
non-0 |
Failure, see error code. |
Chip differences
None.
Requirements
Header File: mpi_venc_api.h,k_type.h,k_module.h,k_sys_comm.h,k_venc_comm.h
Library File: libvenc.a
Example
None.
Related Topics
kd_mpi_venc_detach_vb_pool#
Description
Unbind the encoding channel from the VB pool.
Syntax
k_s32 kd_mpi_venc_detach_vb_pool(k_u32 chn_num);
Parameters
Parameter Name |
Description |
Input/Output |
|---|---|---|
chn_num |
Encoding channel number. Value range: [0,VENC_MAX_CHN_NUMS). |
Input |
Return Value
Return Value |
Description |
|---|---|
0 |
success. |
non-0 |
Failure, see error code. |
Chip differences
None.
Requirements
Header File: mpi_venc_api.h,k_type.h,k_module.h,k_sys_comm.h,k_venc_comm.h
Library File: libvenc.a
Example
None.
Related Topics
kd_mpi_venc_create_chn#
Description
Create an encoding channel.
Syntax
k_s32 kd_mpi_venc_create_chn(k_u32 chn_num, const k_venc_chn_attr *attr);
Parameters
Parameter Name |
Description |
Input/Output |
|---|---|---|
chn_num |
Encode channel information. Value range: [0,VENC_MAX_CHN_NUMS). |
Input |
attr |
Encoding channel attribute pointer. |
Input |
Return Value
Return Value |
Description |
|---|---|
0 |
success. |
non-0 |
Failure, see error code. |
Chip differences
None.
Requirements
Header File: mpi_venc_api.h,k_type.h,k_module.h,k_sys_comm.h,k_venc_comm.h
Library File: libvenc.a
Example
None.
Related Topics
None.
kd_mpi_venc_destroy_chn#
Description
Destroy the encoding channel.
Syntax
k_s32 kd_mpi_venc_destroy_chn(k_u32 chn_num);
Parameters
Parameter Name |
Description |
Input/Output |
|---|---|---|
chn_num |
Encoding channel number. Value range: [0,VENC_MAX_CHN_NUMS). |
Input |
Return Value
Return Value |
Description |
|---|---|
0 |
success. |
non-0 |
Failure, see error code. |
Chip differences
None.
Requirements
Header File: mpi_venc_api.h,k_type.h,k_module.h,k_sys_comm.h,k_venc_comm.h
Library File: libvenc.a
Notes
You must stop receiving images before destruction, otherwise failure will be returned.
Example
None.
Related Topics
kd_mpi_venc_start_chn#
Description
Open the encoding channel to receive input images.
Syntax
k_s32 kd_mpi_venc_start_chn(k_u32 chn_num);
Parameters
Parameter Name |
Description |
Input/Output |
|---|---|---|
chn_num |
Encoding channel number. Value range: [0,VENC_MAX_CHN_NUMS). |
Input |
Return Value
Return Value |
Description |
|---|---|
0 |
success. |
non-0 |
Failure, see error code. |
Chip differences
None.
Requirements
Header File: mpi_venc_api.h,k_type.h,k_module.h,k_sys_comm.h,k_venc_comm.h
Library File: libvenc.a
Notes
If the channel is not created, failure K_ERR_VENC_UNEXIST is returned.
If the channel has started to receive images and calls this interface again to specify the number of frames to receive before stopping receiving images, the return operation is not allowed.
The encoder starts receiving image encoding only after the reception is turned on.
Example
None.
Related Topics
kd_mpi_venc_stop_chn#
Description
Stops the encoding channel from receiving input images.
Syntax
k_s32 kd_mpi_venc_stop_chn(k_u32 chn_num);
Parameters
Parameter Name |
Description |
Input/Output |
|---|---|---|
chn_num |
Encoding channel number. Value range: [0,VENC_MAX_CHN_NUMS). |
Input |
Return Value
Return Value |
Description |
|---|---|
0 |
success. |
non-0 |
Failure, see error code. |
Chip differences
None.
Requirements
Header File: mpi_venc_api.h,k_type.h,k_module.h,k_sys_comm.h,k_venc_comm.h
Library File: libvenc.a
Notes
If the channel is not created, failure is returned.
This interface does not determine whether to stop receiving currently, that is, it allows repeated stopping of reception without returning an error.
This interface is used for the encoding channel to stop receiving images for encoding. It must stop receiving images before the encoding channel is destroyed or reset.
Calling this interface only stops receiving original data encoding, and the code stream buffer will not be cleared.
Example
None.
Related Topics
kd_mpi_venc_query_status#
Description
Query the encoding channel status.
Syntax
k_s32 kd_mpi_venc_query_status(k_u32 chn_num, k_venc_chn_status *status);
Parameters
Parameter Name |
Description |
Input/Output |
|---|---|---|
chn_num |
Encoding channel number. Value range: [0,VENC_MAX_CHN_NUMS). |
Input |
status |
Status pointer for the encoding channel. |
Output |
Return Value
Return Value |
Description |
|---|---|
0 |
success. |
non-0 |
Failure, see error code. |
Chip differences
None.
Requirements
Header File: mpi_venc_api.h,k_type.h,k_module.h,k_sys_comm.h,k_venc_comm.h
Library File: libvenc.a
Notes
If the channel is not created, failure is returned.
Example
None.
Related Topics
kd_mpi_venc_get_stream#
Description
Get the encoded code stream.
Syntax
k_s32 kd_mpi_venc_get_stream(k_u32 chn_num, k_venc_stream *stream, k_s32 milli_sec);
Parameters
Parameter Name |
Description |
Input/Output |
|---|---|---|
chn_num |
Encoding channel number. Value range: [0,VENC_MAX_CHN_NUMS). |
Input |
stream |
Code stream structure pointer. |
Output |
milli_sec |
Get the code stream timeout. Value range: [-1, +∞ ) -1: blocking. 0: Non-blocking. Greater than 0: timeout period |
Input |
Return Value
Return Value |
Description |
|---|---|
0 |
success. |
non-0 |
Failure, see error code. |
Chip differences
None.
Requirements
Header File: mpi_venc_api.h,k_type.h,k_module.h,k_sys_comm.h,k_venc_comm.h
Library File: libvenc.a
Notes
If the channel is not created, failure is returned.
If stream is empty, return K_ERR_VENC_NULL_PTR.
If milli_sec is less than -1, return K_ERR_VENC_ILLEGAL_PARAM.
Example
None.
Related Topics
kd_mpi_venc_release_stream#
Description
Release the code stream cache.
Syntax
k_s32 kd_mpi_venc_release_stream(k_u32 chn_num, k_venc_stream *stream);
Parameters
Parameter Name |
Description |
Input/Output |
|---|---|---|
chn_num |
Encoding channel number. Value range: [0,VENC_MAX_CHN_NUMS). |
Input |
stream |
Code stream structure pointer. |
Output |
Return Value
Return Value |
Description |
|---|---|
0 |
success. |
non-0 |
Failure, see error code. |
Chip differences
None.
Requirements
Header File: mpi_venc_api.h,k_type.h,k_module.h,k_sys_comm.h,k_venc_comm.h
Library File: libvenc.a
Notes
If the channel is not created, error code K_ERR_VENC_UNEXIST is returned.
If the stream is empty, error code K_ERR_VENC_NULL_PTR is returned.
Example
None.
Related Topics
kd_mpi_venc_send_frame#
Description
Supports users to send raw images for encoding.
Syntax
k_s32 kd_mpi_venc_send_frame(k_u32 chn_num, k_video_frame_info *frame, k_s32 milli_sec);
Parameters
Parameter Name |
Description |
Input/Output |
|---|---|---|
chn_num |
Encoding channel number. Value range: [0,VENC_MAX_CHN_NUMS). |
Input |
frame |
For the original image information structure pointer, refer to “K230 System Control API Reference”. |
Input |
milli_sec |
Timeout for sending images. Value range: [-1,+∞ ) -1: blocking. 0: Non-blocking. > 0: timeout period. |
Input |
Return Value
Return Value |
Description |
|---|---|
0 |
success. |
non-0 |
Failure, see error code. |
Chip differences
None.
Requirements
Header File: mpi_venc_api.h,k_type.h,k_module.h,k_sys_comm.h,k_venc_comm.h
Library File: libvenc.a
Notes
This interface enables users to send images to encoding channels.
If milli_sec is less than -1, return K_ERR_VENC_ILLEGAL_PARAM.
To call this interface to send images, the user needs to ensure that the encoding channel has been created and enabled to receive input images.
Example
None.
Related Topics
kd_mpi_venc_set_rotation#
Description
Set the encoding image rotation angle.
Syntax
k_s32 kd_mpi_venc_set_rotation(k_u32 chn_num, const k_rotation rotation);
Parameters
Parameter Name |
Description |
Input/Output |
|---|---|---|
chn_num |
Channel number. Value range: [0,VENC_MAX_CHN_NUMS). |
Input |
rotation |
Rotation angle enumeration. |
Input |
Return Value
Return Value |
Description |
|---|---|
0 |
success. |
non-0 |
Failure, returns error code. |
Chip differences
None.
Requirements
Header File: mpi_venc_api.h,k_type.h,k_module.h,k_sys_comm.h,k_venc_comm.h
Library File: libvenc.a
Notes
None.
Example
None.
Related Topics
None.
kd_mpi_venc_get_rotation#
Description
Get the encoded image rotation angle.
Syntax
k_s32 kd_mpi_venc_get_rotation(k_u32 chn_num, k_rotation *rotation);
Parameters
Parameter Name |
Description |
Input/Output |
|---|---|---|
chn_num |
Channel number. Value range: [0,VENC_MAX_CHN_NUMS). |
Input |
rotation |
Rotation angle enumeration pointer. |
Output |
Return Value
Return Value |
Description |
|---|---|
0 |
success. |
non-0 |
Failure, returns error code. |
Chip differences
None.
Requirements
Header File: mpi_venc_api.h,k_type.h,k_module.h,k_sys_comm.h,k_venc_comm.h
Library File: libvenc.a
Notes
None.
Example
None.
Related Topics
None.
kd_mpi_venc_set_mirror#
Description
Set the encoding image mirroring mode.
Syntax
k_s32 kd_mpi_venc_set_mirror(k_u32 chn_num, const k_venc_mirror mirror);
Parameters
Parameter Name |
Description |
Input/Output |
|---|---|---|
chn_num |
Channel number. Value range: [0,VENC_MAX_CHN_NUMS). |
Input |
mirror |
Flip mode enumeration. |
Input |
Return Value
Return Value |
Description |
|---|---|
0 |
success. |
non-0 |
Failure, returns error code. |
Chip differences
None. Requirements
Header File: mpi_venc_api.h,k_type.h,k_module.h,k_sys_comm.h,k_venc_comm.h
Library File: libvenc.a
Notes
None. Example
None. Related Topics
None.
kd_mpi_venc_get_mirror#
Description
Set the encoding image mirroring mode. Syntax
| k_s32 kd_mpi_venc_get_mirror(k_u32 chn_num, k_venc_mirror mirror); |
Parameters
Parameter Name |
Description |
Input/Output |
|---|---|---|
chn_num |
Channel number. Value range: [0,VENC_MAX_CHN_NUMS). |
Input |
mirror |
Flip mode enumeration. |
Output |
Return Value
Return Value |
Description |
|---|---|
0 |
success. |
non-0 |
Failure, returns error code. |
Chip differences
None. Requirements
Header File: mpi_venc_api.h,k_type.h,k_module.h,k_sys_comm.h,k_venc_comm.h
Library File: libvenc.a
Notes
None. Example
None. Related Topics
None.
kd_mpi_venc_enable_idr#
Description
Set IDR frame enable.
Syntax
k_s32 kd_mpi_venc_enable_idr(k_u32 chn_num, k_bool idr_enable);
Parameters
Parameter Name |
Description |
Input/Output |
|---|---|---|
chn_num |
Channel number. Value range: [0,VENC_MAX_CHN_NUMS). |
Input |
idr_enable |
Whether to enable IDR frames. 0: Disabled. 1: Enabled. |
Input |
Return Value
Return Value |
Description |
|---|---|
0 |
success. |
non-0 |
Failure, returns error code. |
Chip differences
None.
Requirements
Header File: mpi_venc_api.h,k_type.h,k_module.h,k_sys_comm.h,k_venc_comm.h
Library File: libvenc.a
Notes
This interface needs to be called after creating the encoding channel and before starting the encoding channel.
Example
None.
Related Topics
None.
kd_mpi_venc_set_2d_mode#
Description
Set the 2D operation mode.
Syntax
k_s32 kd_mpi_venc_set_2d_mode(k_u32 chn_num, k_venc_2d_calc_mode mode);
Parameters
Parameter Name |
Description |
Input/Output |
|---|---|---|
chn_num |
Channel number. Value range: [0,VENC_MAX_CHN_NUMS). |
Input |
mode |
2D operation mode enumeration. |
Input |
Return Value
Return Value |
Description |
|---|---|
0 |
success. |
non-0 |
Failure, returns error code. |
Chip differences
None.
Requirements
Header File: mpi_venc_api.h,k_type.h,k_module.h,k_sys_comm.h,k_venc_comm.h
Library File: libvenc.a
Notes
The current operation mode does not support the K_VENC_2D_CALC_MODE_CSC mode.
Example
None.
Related Topics
None.
kd_mpi_venc_get_2d_mode#
Description
Get the 2D operation mode.
Syntax
k_s32 kd_mpi_venc_get_2d_mode(k_u32 chn_num, k_venc_2d_calc_mode *mode);
Parameters
Parameter Name |
Description |
Input/Output |
|---|---|---|
chn_num |
Channel number. Value range: [0,VENC_MAX_CHN_NUMS). |
Input |
mode |
2D operation mode enumeration pointer. |
Output |
Return Value
Return Value |
Description |
|---|---|
0 |
success. |
non-0 |
Failure, returns error code. |
Chip differences
None.
Requirements
Header File: mpi_venc_api.h,k_type.h,k_module.h,k_sys_comm.h,k_venc_comm.h
Library File: libvenc.a
Notes
The current operation mode does not support the K_VENC_2D_CALC_MODE_CSC mode.
Example
None.
Related Topics
None.
kd_mpi_venc_set_2d_osd_param#
Description
Set the area attributes of OSD in 2D operations.
Syntax
k_s32 kd_mpi_venc_set_2d_osd_param(k_u32 chn_num, k_u8 index, const k_venc_2d_osd_attr *attr);
Parameters
Parameter Name |
Description |
Input/Output |
|---|---|---|
chn_num |
Channel number. Value range: [0,VENC_MAX_CHN_NUMS). |
Input |
index |
OSD area index. Value range: [0,K_VENC_MAX_2D_OSD_REGION_NUM). |
Input |
attr |
OSD attribute pointer. |
Input |
Return Value
Return Value |
Description |
|---|---|
0 |
success. |
non-0 |
Failure, returns error code. |
Chip differences
None.
Requirements
Header File: mpi_venc_api.h,k_type.h,k_module.h,k_sys_comm.h,k_venc_comm.h
Library File: libvenc.a
Notes
If there are n overlay areas, the index values should be set to 0~n-1 respectively.
Example
None.
Related Topics
None.
kd_mpi_venc_get_2d_osd_param#
Description
Get the area attributes of the OSD at the specified index in the 2D operation.
Syntax
k_s32 kd_mpi_venc_get_2d_osd_param(k_u32 chn_num, k_u8 index, k_venc_2d_osd_attr *attr);
Parameters
Parameter Name |
Description |
Input/Output |
|---|---|---|
chn_num |
Channel number. Value range: [0,VENC_MAX_CHN_NUMS). |
Input |
index |
OSD area index. Value range: [0,K_VENC_MAX_2D_OSD_REGION_NUM). |
Input |
attr |
OSD attribute pointer. |
Output |
Return Value
Return Value |
Description |
|---|---|
0 |
success. |
non-0 |
Failure, returns error code. |
Chip differences
None.
Requirements
Header File: mpi_venc_api.h,k_type.h,k_module.h,k_sys_comm.h,k_venc_comm.h
Library File: libvenc.a
Notes
None.
Example
None.
Related Topics
None.
kd_mpi_venc_set_2d_border_param#
Description
Set the frame properties in 2D operations.
Syntax
k_s32 kd_mpi_venc_set_2d_border_param(k_u32 chn_num, k_u8 index, const k_venc_2d_border_attr *attr);
Parameters
Parameter Name |
Description |
Input/Output |
|---|---|---|
chn_num |
Channel number. Value range: [0,VENC_MAX_CHN_NUMS). |
Input |
index |
Frame index. Value range: [0,K_VENC_MAX_2D_BORDER_NUM). |
Input |
attr |
Frame attribute pointer. |
Input |
Return Value
Return Value |
Description |
|---|---|
0 |
success. |
non-0 |
Failure, returns error code. |
Chip differences
None.
Requirements
Header File: mpi_venc_api.h,k_type.h,k_module.h,k_sys_comm.h,k_venc_comm.h
Library File: libvenc.a
Notes
If there are n boxes, the index values should be set to 0~n-1 respectively.
Example
None.
Related Topics
None.
kd_mpi_venc_get_2d_border_param#
Description
Get the frame properties in 2D operations.
Syntax
k_s32 kd_mpi_venc_get_2d_border_param(k_u32 chn_num, k_u8 index, k_venc_2d_border_attr *attr);
Parameters
Parameter Name |
Description |
Input/Output |
|---|---|---|
chn_num |
Channel number. Value range: [0,VENC_MAX_CHN_NUMS). |
Input |
index |
Frame index. Value range: [0,K_VENC_MAX_2D_BORDER_NUM). |
Input |
attr |
Frame attribute pointer. |
Output |
Return Value
Return Value |
Description |
|---|---|
0 |
success. |
non-0 |
Failure, returns error code. |
Chip differences
None.
Requirements
Header File: mpi_venc_api.h,k_type.h,k_module.h,k_sys_comm.h,k_venc_comm.h
Library File: libvenc.a
Notes
None.
Example
None.
Related Topics
None.
kd_mpi_venc_set_2d_custom_coef#
Description
Set the image format conversion coefficient in 2D operations.
Syntax
k_s32 kd_mpi_venc_set_2d_custom_coef(k_u32 chn_num, const k_s16 *coef);
Parameters
Parameter Name |
Description |
Input/Output |
|---|---|---|
chn_num |
Channel number. Value range: [0,VENC_MAX_CHN_NUMS). |
Input |
coef |
Conversion coefficient pointer. ReferenceCalculation of 2D conversion coefficients |
Input |
Return Value
Return Value |
Description |
|---|---|
0 |
success. |
non-0 |
Failure, returns error code. |
Chip differences
None.
Requirements
Header File: mpi_venc_api.h,k_type.h,k_module.h,k_sys_comm.h,k_venc_comm.h
Library File: libvenc.a
Notes
The kernel state has a set of default conversion coefficients. If you need to customize the conversion coefficients, you can configure them through this interface.
This interface should be called after setting the operation mode.
For a description of the conversion coefficient, see Calculation of 2D conversion coefficients for details.
When the operation mode is K_VENC_2D_CALC_MODE_BORDER, the conversion coefficient is not applicable and an error will be reported when calling this interface.
Example
None.
Related Topics
kd_mpi_venc_get_2d_custom_coef#
Description
Get the image format conversion coefficient in 2D operations.
Syntax
k_s32 kd_mpi_venc_get_2d_custom_coef(k_u32 chn_num, k_s16 *coef);
Parameters
Parameter Name |
Description |
Input/Output |
|---|---|---|
chn_num |
Channel number. Value range: [0,VENC_MAX_CHN_NUMS). |
Input |
coef |
Conversion coefficient pointer. ReferenceCalculation of 2D conversion coefficients |
Output |
Return Value
Return Value |
Description |
|---|---|
0 |
success. |
non-0 |
Failure, returns error code. |
Chip differences
None.
Requirements
Header File: mpi_venc_api.h,k_type.h,k_module.h,k_sys_comm.h,k_venc_comm.h
Library File: libvenc.a
Notes
This interface should be called after setting the operation mode.
When the operation mode is K_VENC_2D_CALC_MODE_BORDER, the conversion coefficient is not applicable and an error will be reported when calling this interface.
Example
None.
Related Topics
None.
kd_mpi_venc_set_2d_color_gamut#
Description
Set the color gamut for 2D operations.
Syntax
k_s32 kd_mpi_venc_set_2d_color_gamut(k_u32 chn_num, const k_venc_2d_color_gamut color_gamut);
Parameters
Parameter Name |
Description |
Input/Output |
|---|---|---|
chn_num |
Channel number. Value range: [0,VENC_MAX_CHN_NUMS). |
Input |
color_gamut |
Color gamut enumeration. |
Input |
Return Value
Return Value |
Description |
|---|---|
0 |
success. |
non-0 |
Failure, returns error code. |
Chip differences
None.
Requirements
Header File: mpi_venc_api.h,k_type.h,k_module.h,k_sys_comm.h,k_venc_comm.h
Library File: libvenc.a
Notes
The kernel state has a set of default conversion coefficients. If you need to customize the conversion coefficients, you can configure them through this interface.
This interface should be called after setting the operation mode.
When the operation mode is K_VENC_2D_CALC_MODE_BORDER, the color gamut is not applicable and an error will be reported when calling this interface.
Example
None.
Related Topics
None.
kd_mpi_venc_get_2d_color_gamut#
Description
Get the color gamut of 2D operations.
Syntax
k_s32 kd_mpi_venc_get_2d_color_gamut(k_u32 chn_num, k_venc_2d_color_gamut *color_gamut);
Parameters
Parameter Name |
Description |
Input/Output |
|---|---|---|
chn_num |
Channel number. Value range: [0,VENC_MAX_CHN_NUMS). |
Input |
color_gamut |
Color gamut enumeration pointer. |
Output |
Return Value
Return Value |
Description |
|---|---|
0 |
success. |
non-0 |
Failure, returns error code. |
Chip differences
None.
Requirements
Header File: mpi_venc_api.h,k_type.h,k_module.h,k_sys_comm.h,k_venc_comm.h
Library File: libvenc.a
Notes
The kernel state has a set of default conversion coefficients. If you need to customize the conversion coefficients, you can configure them through this interface.
This interface should be called after setting the operation mode.
When the operation mode is K_VENC_2D_CALC_MODE_BORDER, the color gamut is not applicable and an error will be reported when calling this interface.
Example
None.
Related Topics
None.
kd_mpi_venc_attach_2d#
Description
Associate 2D operations with venc.
Syntax
k_s32 kd_mpi_venc_attach_2d(k_u32 chn_num);
Parameters
Parameter Name |
Description |
Input/Output |
|---|---|---|
chn_num |
Channel number. Value range: [0,VENC_MAX_CHN_NUMS). |
Input |
Return Value
Return Value |
Description |
|---|---|
0 |
success. |
non-0 |
Failure, returns error code. |
Chip differences
None.
Requirements
Header File: mpi_venc_api.h,k_type.h,k_module.h,k_sys_comm.h,k_venc_comm.h
Library File: libvenc.a
Notes
Currently, binding only supports the mode where the encoding channel number and the 2D operation channel number are the same. Only the first three encoding channels support attach 2D operations.
Example
None.
Related Topics
None.
kd_mpi_venc_detach_2d#
Description
Separate 2D operations from venc.
Syntax
k_s32 kd_mpi_venc_detach_2d(k_u32 chn_num);
Parameters
Parameter Name |
Description |
Input/Output |
|---|---|---|
chn_num |
2D operation channel number. Value range: [0,VENC_MAX_CHN_NUMS). |
Input |
Return Value
Return Value |
Description |
|---|---|
0 |
success. |
non-0 |
Failure, returns error code. |
Chip differences
None.
Requirements
Header File: mpi_venc_api.h,k_type.h,k_module.h,k_sys_comm.h,k_venc_comm.h
Library File: libvenc.a
Notes
To call this interface, the user needs to ensure that the encoding channel has been stopped.
Example
None.
Related Topics
kd_mpi_venc_send_2d_frame#
Description
Send a frame of data to the 2D module.
Syntax
| k_s32 kd_mpi_venc_send_2d_frame(k_u32 chn_num, k_video_frame_info *frame);
Parameters
Parameter Name |
Description |
Input/Output |
|---|---|---|
chn_num |
2D operation channel number, value range [0,VENC_MAX_CHN_NUMS). |
Input |
frame |
For the original image information structure pointer, refer to “K230 System Control API Reference”. |
Input |
Return Value
Return Value |
Description |
|---|---|
0 |
success. |
non-0 |
Failure, returns error code |
Chip differences
None.
Requirements
Header File: mpi_venc_api.h,k_type.h,k_module.h,k_sys_comm.h,k_venc_comm.h
Library File: libvenc.a
Notes
This interface is only used in the scenario of single 2D operation. In the scenario of encoding after 2D operation, you need to use the interface kd_mpi_venc_send_frame of venc to send graphics.
Example
None.
Related Topics
kd_mpi_venc_get_2d_frame#
Description
Get the 2D operation results.
Syntax
k_s32 kd_mpi_venc_get_2d_frame(k_u32 chn_num, k_video_frame_info *frame);
Parameters
Parameter Name |
Description |
Input/Output |
|---|---|---|
chn_num |
2D operation channel number, value range [0,VENC_MAX_CHN_NUMS). |
Input |
frame |
Output image information structure pointer, refer to “K230 System Control API Reference”. |
Input |
Return Value
Return Value |
Description |
|---|---|
0 |
success. |
non-0 |
Failure, returns error code. |
Chip differences
None.
Requirements
Header File: mpi_venc_api.h,k_type.h,k_module.h,k_sys_comm.h,k_venc_comm.h
Library File: libvenc.a
Notes
This interface is only used in single 2D operation scenarios. In scenarios where encoding is performed after 2D operation, you need to use kd_mpi_venc_get_stream to obtain the encoded code stream.
Example
None.
Related Topics
kd_mpi_venc_start_2d_chn#
Description
Start the 2D channel to receive the input image.
Syntax
k_s32 kd_mpi_venc_start_2d_chn(k_u32 chn_num);
Parameters
Parameter Name |
Description |
Input/Output |
|---|---|---|
chn_num |
2D operation channel number, value range [0,VENC_MAX_CHN_NUMS). |
Input |
Return Value
Return Value |
Description |
|---|---|
0 |
success. |
non-0 |
Failure, returns error code. |
Chip differences
None.
Requirements
Header File: mpi_venc_api.h,k_type.h,k_module.h,k_sys_comm.h,k_venc_comm.h
Notes
This interface is only used in single 2D operation scenarios. In VENC+2D scenarios, you need to call kd_mpi_venc_start_chn
Example
None.
Related Topics
kd_mpi_venc_stop_2d_chn#
Description
Stops the 2D channel from receiving input images.
Syntax
k_s32 kd_mpi_venc_stop_2d_chn(k_u32 chn_num);
Parameters
Parameter Name |
Description |
Input/Output |
|---|---|---|
chn_num |
2D operation channel number, value range [0,VENC_MAX_CHN_NUMS). |
Input |
Return Value
Return Value |
Description |
|---|---|
0 |
success. |
non-0 |
Failure, returns error code. |
Chip differences
None.
Requirements
Header File: mpi_venc_api.h,k_type.h,k_module.h,k_sys_comm.h,k_venc_comm.h
Library File: libvenc.a
Notes
None.
Example
None.
Related Topics
None.
kd_mpi_venc_request_idr#
Description
Requests an IDR frame. An IDR frame is generated immediately after the call.
Syntax
k_s32 kd_mpi_venc_request_idr(k_u32 chn_num);
Parameters
Parameter Name |
Description |
Input/Output |
|---|---|---|
chn_num |
Channel number. Value range: [0,VENC_MAX_CHN_NUMS). |
Input |
Return Value
Return Value |
Description |
|---|---|
0 |
success. |
non-0 |
Failure, returns error code. |
Chip differences
None.
Requirements
Header File: mpi_venc_api.h,k_type.h,k_module.h,k_sys_comm.h,k_venc_comm.h
Library File: libvenc.a
Notes
None.
Example
None.
Related Topics
None.
kd_mpi_venc_set_h265_sao#
Description
Set the Sao attribute of the H.265 channel.
Syntax
k_s32 kd_mpi_venc_set_h265_sao(k_u32 chn_num, const k_venc_h265_sao *h265_sao);
Parameters
Parameter Name |
Description |
Input/Output |
|---|---|---|
chn_num |
Channel number. Value range: [0,VENC_MAX_CHN_NUMS). |
Input |
h265_sao |
Sao configuration of H.265 protocol encoding channel. |
Input |
Return Value
Return Value |
Description |
|---|---|
0 |
success. |
non-0 |
Failure, returns error code. |
Chip differences
None.
Requirements
Header File: mpi_venc_api.h,k_type.h,k_module.h,k_sys_comm.h,k_venc_comm.h
Library File: libvenc.a
Notes
This interface needs to be called after creating the encoding channel and before starting the encoding channel.
Example
None.
Related Topics
None.
kd_mpi_venc_get_h265_sao#
Description
Get the Sao attribute of the H.265 channel.
Syntax
k_s32 kd_mpi_venc_get_h265_sao(k_u32 chn_num, k_venc_h265_sao *h265_sao);
Parameters
Parameter Name |
Description |
Input/Output |
|---|---|---|
chn_num |
Channel number. Value range: [0,VENC_MAX_CHN_NUMS). |
Input |
h265_sao |
Sao configuration of H.265 protocol encoding channel. |
Output |
Return Value
Return Value |
Description |
|---|---|
0 |
success. |
non-0 |
Failure, returns error code. |
Chip differences
None.
Requirements
Header File: mpi_venc_api.h,k_type.h,k_module.h,k_sys_comm.h,k_venc_comm.h
Library File: libvenc.a
Notes
None.
Example
None.
Related Topics
None.
kd_mpi_venc_set_dblk#
Description
Set the deblocking enablement of the H.264/H.265 protocol encoding channel.
Syntax
k_s32 kd_mpi_venc_set_dblk(k_u32 chn_num, const k_bool dblk_en);
Parameters
Parameter Name |
Description |
Input/Output |
|---|---|---|
chn_num |
Channel number. Value range: [0,VENC_MAX_CHN_NUMS). |
Input |
dblk_en |
Whether to enable deblocking. K_TRUE: enabled. K_FALSE: Disabled. Enabled by default. |
Input |
Return Value
Return Value |
Description |
|---|---|
0 |
success. |
non-0 |
Failure, returns error code. |
Chip differences
None.
Requirements
Header File: mpi_venc_api.h,k_type.h,k_module.h,k_sys_comm.h,k_venc_comm.h
Library File: libvenc.a
Notes
This interface needs to be called after creating the encoding channel and before starting the encoding channel.
Example
None.
Related Topics
None.
kd_mpi_venc_get_dblk#
Description
Get the Deblocking status of the H.264/H.265 protocol encoding channel.
Syntax
k_s32 kd_mpi_venc_get_dblk(k_u32 chn_num, k_bool *dblk_en);
Parameters
Parameter Name |
Description |
Input/Output |
|---|---|---|
chn_num |
Channel number. Value range: [0,VENC_MAX_CHN_NUMS). |
Input |
dblk_en |
Whether to enable deblocking. K_TRUE: enabled. K_FALSE: Disabled. Enabled by default. |
Output |
Return Value
Return Value |
Description |
|---|---|
0 |
success. |
non-0 |
Failure, returns error code. |
Chip differences
None.
Requirements
Header File: mpi_venc_api.h,k_type.h,k_module.h,k_sys_comm.h,k_venc_comm.h
Library File: libvenc.a
Notes
None.
Example
None.
Related Topics
None.
kd_mpi_venc_set_intbuf_size#
Description
Set the VENC buffer size.
Syntax
k_s32 kd_mpi_venc_set_intbuf_size(k_u32 chn_num, k_u32 size)
Parameters
Parameter Name |
Description |
Input/Output |
|---|---|---|
chn_num |
Channel number. Value range: [0,VENC_MAX_CHN_NUMS). |
Input |
size |
buffer size。 |
Input |
Return Value
Return Value |
Description |
|---|---|
0 |
success. |
non-0 |
Failure, returns error code. |
Chip differences
None.
Requirements
Header File: mpi_venc_api.h,k_type.h,k_module.h,k_sys_comm.h,k_venc_comm.h
Library File: libvenc.a
Notes
This interface needs to be called before creating an encoding channel.
Example
None.
Related Topics
None.
kd_mpi_venc_get_2d_csc_param#
Description
Get the 2D CSC properties of the VENC channel.
Syntax
k_s32 kd_mpi_venc_get_2d_csc_param(k_u32 chn_num, k_venc_2d_csc_attr *attr);
Parameters
Parameter Name |
Description |
Input/Output |
|---|---|---|
chn_num |
Channel number. Value range: [0,VENC_MAX_CHN_NUMS). |
Input |
attr |
2D CSC parameters. |
Output |
Return Value
Return Value |
Description |
|---|---|
0 |
success. |
non-0 |
Failure, returns error code. |
Chip differences
None.
Requirements
Header File: mpi_venc_api.h,k_type.h,k_module.h,k_sys_comm.h,k_venc_comm.h
Library File: libvenc.a
Notes
None.
Example
None.
Related Topics
None.
kd_mpi_venc_set_h264_entropy#
Description
Set the entropy encoding mode of the H.264 protocol encoding channel.
Syntax
k_s32 kd_mpi_venc_set_h264_entropy(k_u32 chn_num, const k_venc_h264_entropy *h264_entropy);
Parameters
Parameter Name |
Description |
Input/Output |
|---|---|---|
chn_num |
Channel number. Value range: [0,VENC_MAX_CHN_NUMS). |
Input |
h264_entropy |
Entropy coding mode of the H.264 protocol encoding channel. |
Input |
Return Value
Return Value |
Description |
|---|---|
0 |
success. |
non-0 |
Failure, returns error code. |
Chip differences
None.
Requirements
Header File: mpi_venc_api.h,k_type.h,k_module.h,k_sys_comm.h,k_venc_comm.h
Library File: libvenc.a
Notes
This interface needs to be called after creating the encoding channel and before starting the encoding channel.
Example
None.
Related Topics
None.
kd_mpi_venc_get_h264_entropy#
Description
Get the entropy encoding mode of the H.264 protocol encoding channel.
Syntax
k_s32 kd_mpi_venc_get_h264_entropy(k_u32 chn_num, k_venc_h264_entropy *h264_entropy);
Parameters
Parameter Name |
Description |
Input/Output |
|---|---|---|
chn_num |
Channel number. Value range: [0,VENC_MAX_CHN_NUMS). |
Input |
h264_entropy |
Entropy coding mode of the H.264 protocol encoding channel. |
Output |
Return Value
Return Value |
Description |
|---|---|
0 |
success. |
non-0 |
Failure, returns error code. |
Chip differences
None.
Requirements
Header File: mpi_venc_api.h,k_type.h,k_module.h,k_sys_comm.h,k_venc_comm.h
Library File: libvenc.a
Notes
None.
Example
None.
Related Topics
None.
kd_mpi_venc_set_h265_entropy#
Description
Set the entropy encoding mode of the H.265 protocol encoding channel.
Syntax
k_s32 kd_mpi_venc_set_h265_entropy(k_u32 chn_num, const k_venc_h265_entropy *h265_entropy);
Parameters
Parameter Name |
Description |
Input/Output |
|---|---|---|
chn_num |
Channel number. Value range: [0,VENC_MAX_CHN_NUMS). |
Input |
h265_entropy |
Entropy coding mode of the H.265 protocol encoding channel. |
Input |
Return Value
Return Value |
Description |
|---|---|
0 |
success. |
non-0 |
Failure, returns error code. |
Chip differences
None.
Requirements
Header File: mpi_venc_api.h,k_type.h,k_module.h,k_sys_comm.h,k_venc_comm.h
Library File: libvenc.a
Notes
This interface needs to be called after creating the encoding channel and before starting the encoding channel.
Example
None.
Related Topics
None.
kd_mpi_venc_get_h265_entropy#
Description
Get the entropy encoding mode of the H.265 protocol encoding channel.
Syntax
k_s32 kd_mpi_venc_get_h265_entropy(k_u32 chn_num, k_venc_h265_entropy *h265_entropy);
Parameters
Parameter Name |
Description |
Input/Output |
|---|---|---|
chn_num |
Channel number. Value range: [0,VENC_MAX_CHN_NUMS). |
Input |
h265_entropy |
Entropy coding mode of the H.265 protocol encoding channel. |
Output |
Return Value
Return Value |
Description |
|---|---|
0 |
success. |
non-0 |
Failure, returns error code. |
Chip differences
None.
Requirements
Header File: mpi_venc_api.h,k_type.h,k_module.h,k_sys_comm.h,k_venc_comm.h
Library File: libvenc.a
Notes
None.
Example
None.
Related Topics
None.
video decoding#
This function module provides the following APIs:
kd_mpi_vdec_request_chn: Apply for decoding channel.
kd_mpi_vdec_release_chn: Release the decoding channel.
kd_mpi_vdec_attach_vb_pool: Bind the VB pool to the decoding channel.
kd_mpi_vdec_detach_vb_pool: Unbind the VB pool of the decoding channel.
kd_mpi_vdec_create_chn: Create video decoding channel.
kd_mpi_vdec_destroy_chn: Destroy the video decoding channel.
kd_mpi_vdec_start_chn: Enable video decoding channel.
kd_mpi_vdec_stop_chn: Stop video decoding channel.
kd_mpi_vdec_query_status: The decoder stops receiving the code stream sent by the user.
kd_mpi_vdec_send_stream: Send code stream data to the video decoding channel.
kd_mpi_vdec_get_frame: Get the decoded image of the video decoding channel.
kd_mpi_vdec_release_frame: Get the decoded image of the video decoding channel.
kd_mpi_vdec_set_downscale: Set the decoded output reduced image (specify the length and width or proportionally).
kd_mpi_vdec_set_rotation: Set the decoding rotation angle.
kd_mpi_vdec_close_fd: Turn off VDEC device
kd_mpi_vdec_request_chn#
Description
Apply for a decoding channel.
Syntax
k_s32 kd_mpi_vdec_request_chn(k_u32* chn_num);
Parameters
Parameter Name |
Description |
Input/Output |
|---|---|---|
chn_num |
Output the requested decoding channel number, value range: [0,VDEC_MAX_CHN_NUMS] |
Output |
Return Value
Return Value |
Description |
|---|---|
0 |
success. |
non-0 |
Failure, see error code. |
Chip differences
None.
Requirements
Header File: mpi_vdec_api.h,k_type.h,k_module.h,k_sys_comm.h,k_vdec_comm.h
Library File: libvdec.a
Example
None.
Related Topics
None.
kd_mpi_vdec_release_chn#
Description
Release the decoding channel.
Syntax
k_s32 kd_mpi_vdec_release_chn(k_u32 chn_num);
Parameters
Parameter Name |
Description |
Input/Output |
|---|---|---|
chn_num |
Decode channel number. Value range: [0,VDEC_MAX_CHN_NUMS] |
Input |
Return Value
Return Value |
Description |
|---|---|
0 |
success. |
non-0 |
Failure, see error code. |
Chip differences
None.
Requirements
Header File: mpi_vdec_api.h,k_type.h,k_module.h,k_sys_comm.h,k_vdec_comm.h
Library File: libvdec.a
Notes
Decoding channel related operations must be stopped before releasing, otherwise failure will be returned.
Example
None.
Related Topics
None.
kd_mpi_vdec_attach_vb_pool#
Description
Bind the VB pool to the decoding channel.
Syntax
k_s32 kd_mpi_vdec_attach_vb_pool(k_u32 chn_num, k_u32 pool_id);
Parameters
Parameter Name |
Description |
Input/Output |
|---|---|---|
chn_num |
Decode channel number. Value range: [0,VDEC_MAX_CHN_NUMS] |
Input |
pool_id |
VB pool ID. |
Input |
Return Value
Return Value |
Description |
|---|---|
0 |
success. |
non-0 |
Failure, see error code. |
Chip differences
None.
Requirements
Header File: mpi_vdec_api.h,k_type.h,k_module.h,k_sys_comm.h,k_vdec_comm.h
Library File: libvdec.a
Example
None.
Related Topics
kd_mpi_vdec_detach_vb_pool#
Description
Unbind the VB pool of the decoding channel.
Syntax
k_s32 kd_mpi_vdec_detach_vb_pool(k_u32 chn_num);
Parameters
Parameter Name |
Description |
Input/Output |
|---|---|---|
chn_num |
Decode channel number. Value range: [0,VDEC_MAX_CHN_NUMS] |
Input |
Return Value
Return Value |
Description |
|---|---|
0 |
success. |
non-0 |
Failure, see error code. |
Chip differences
None.
Requirements
Header File: mpi_vdec_api.h,k_type.h,k_module.h,k_sys_comm.h,k_vdec_comm.h
Library File: libvdec.a
Example
None.
Related Topics
kd_mpi_vdec_create_chn#
Description
Create a video decoding channel.
Syntax
k_s32 kd_mpi_vdec_create_chn(k_u32 chn_num, k_vdec_chn_attr *attr);
Parameters
Parameter Name |
Description |
Input/Output |
|---|---|---|
chn_num |
Encode channel information. Value range: [0,VENC_MAX_CHN_NUMS). |
Input |
attr |
Decode channel attribute pointer. |
Input |
Return Value
Return Value |
Description |
|---|---|
0 |
success. |
non-0 |
Failure, see error code. |
Chip differences
None.
Requirements
Header File: mpi_vdec_api.h,k_type.h,k_module.h,k_sys_comm.h,k_vdec_comm.h
Library File: libvdec.a
Notes
None.
Example
None.
Related Topics
None.
kd_mpi_vdec_destroy_chn#
Description
Destroy the video decoding channel.
Syntax
k_s32 kd_mpi_vdec_destroy_chn(k_u32 chn_num);
Parameters
Parameter Name |
Description |
Input/Output |
|---|---|---|
chn_num |
Encode channel information. Value range: [0,VENC_MAX_CHN_NUMS). |
Input |
Return Value
Return Value |
Description |
|---|---|
0 |
success. |
non-0 |
Failure, see error code. |
Chip differences
None.
Requirements
Header File: mpi_vdec_api.h,k_type.h,k_module.h,k_sys_comm.h,k_vdec_comm.h
Library File: libvdec.a
Notes
None.
Example
None.
Related Topics
None.
kd_mpi_vdec_start_chn#
Description
Enable the video decoding channel.
Syntax
k_s32 kd_mpi_vdec_start_chn(k_u32 chn_num);
Parameters
Parameter Name |
Description |
Input/Output |
|---|---|---|
chn_num |
Encode channel information. Value range: [0,VENC_MAX_CHN_NUMS). |
Input |
Return Value
Return Value |
Description |
|---|---|
0 |
success. |
non-0 |
Failure, see error code. |
Chip differences
None.
Requirements
Header File: mpi_vdec_api.h,k_type.h,k_module.h,k_sys_comm.h,k_vdec_comm.h
Library File: libvdec.a
Notes
None.
Example
None.
Related Topics
None.
kd_mpi_vdec_stop_chn#
Description
Stop the video decoding channel.
Syntax
k_s32 kd_mpi_vdec_stop_chn(k_u32 chn_num);
Parameters
Parameter Name |
Description |
Input/Output |
|---|---|---|
chn_num |
Encode channel information. Value range: [0,VENC_MAX_CHN_NUMS). |
Input |
Return Value
Return Value |
Description |
|---|---|
0 |
success. |
non-0 |
Failure, see error code. |
Chip differences
None.
Requirements
Header File: mpi_vdec_api.h,k_type.h,k_module.h,k_sys_comm.h,k_vdec_comm.h
Library File: libvdec.a
Notes
None.
Example
None.
Related Topics
None.
kd_mpi_vdec_query_status#
Description
Query the decoding channel status.
Syntax
k_s32 kd_mpi_vdec_query_status(k_u32 chn_num, k_vdec_chn_status *status);
Parameters
Parameter Name |
Description |
Input/Output |
|---|---|---|
chn_num |
Encode channel information. Value range: [0,VENC_MAX_CHN_NUMS). |
Input |
status |
Video decoding channel status structure pointer. |
Output |
Return Value
Return Value |
Description |
|---|---|
0 |
success. |
non-0 |
Failure, see error code. |
Chip differences
None.
Requirements
Header File: mpi_vdec_api.h,k_type.h,k_module.h,k_sys_comm.h,k_vdec_comm.h
Library File: libvdec.a
Notes
None.
Example
None.
Related Topics
None.
kd_mpi_vdec_send_stream#
Description
Send code stream data to the video decoding channel.
Syntax
k_s32 kd_mpi_vdec_send_stream(k_u32 chn_num, k_vdec_stream *stream, k_s32 milli_sec);
Parameters
Parameter Name |
Description |
Input/Output |
|---|---|---|
chn_num |
Encode channel information. Value range: [0,VENC_MAX_CHN_NUMS). |
Input |
stream |
Decoded code stream data pointer. |
Input |
milli_sec |
Send code stream mode flag. Value range: -1: blocking. 0: Non-blocking. Positive value: timeout time, no upper limit, in ms. |
Input |
Return Value
Return Value |
Description |
|---|---|
0 |
success. |
non-0 |
Failure, see error code. |
Chip differences
None.
Requirements
Header File: mpi_vdec_api.h,k_type.h,k_module.h,k_sys_comm.h,k_vdec_comm.h
Library File: libvdec.a
Notes
None.
Example
None.
Related Topics
None.
kd_mpi_vdec_get_frame#
Description
Get the decoded image of the video decoding channel.
Syntax
k_s32 kd_mpi_vdec_get_frame(k_u32 chn_num, k_video_frame_info *frame_info, k_vdec_supplement_info *supplement, k_s32 milli_sec);
Parameters
Parameter Name |
Description |
Input/Output |
|---|---|---|
chn |
Encode channel information. Value range: [0,VENC_MAX_CHN_NUMS). |
Input |
frame_info |
For the obtained decoded image information, refer to “K230 System Control API Reference”. |
Output |
supplement |
Obtained supplementary information of the decoded image. |
Output |
milli_sec |
Send code stream mode flag. Value range: -1: blocking. 0: Non-blocking. Positive value: timeout, no upper limit, in ms. Dynamic attribute. |
Input |
Return Value
Return Value |
Description |
|---|---|
0 |
success. |
non-0 |
Failure, see error code. |
Chip differences
None.
Requirements
Header File: mpi_vdec_api.h,k_type.h,k_module.h,k_sys_comm.h,k_vdec_comm.h
Library File: libvdec.a
Notes
None.
Example
None.
Related Topics
None.
kd_mpi_vdec_release_frame#
Description
Get the decoded image of the video decoding channel.
Syntax
k_s32 kd_mpi_vdec_release_frame(k_u32 chn_num, k_video_frame_info *frame_info);
Parameters
Parameter Name |
Description |
Input/Output |
|---|---|---|
chn |
Encode channel information. Value range: [0,VENC_MAX_CHN_NUMS). |
Input |
frame_info |
The decoded image information pointer is obtained through the kd_mpi_vdec_get_frame interface. Please refer to “K230 System Control API Reference”. |
Input |
Return Value
Return Value |
Description |
|---|---|
0 |
success. |
non-0 |
Failure, see error code. |
Chip differences
None.
Requirements
Header File: mpi_vdec_api.h,k_type.h,k_module.h,k_sys_comm.h,k_vdec_comm.h
Library File: libvdec.a
Notes
None.
Example
None.
Related Topics
kd_mpi_vdec_set_downscale#
Description
Sets decoding to output a reduced image (specify length and width or proportional).
Syntax
k_s32 kd_mpi_vdec_set_downscale(k_u32 chn_num, const k_vdec_downscale *downscale)
Parameters
Parameter Name |
Description |
Input/Output |
|---|---|---|
chn_num |
Encode channel information. Value range: [0,VENC_MAX_CHN_NUMS). |
Input |
downscale |
Reduce size parameter structure pointer. |
Input |
Return Value
Return Value |
Description |
|---|---|
0 |
success. |
non-0 |
Failure, see error code. |
Chip differences
None.
Requirements
Header File: mpi_vdec_api.h,k_type.h,k_module.h,k_sys_comm.h,k_vdec_comm.h
Library File: libvdec.a
Notes
Set between kd_mpi_vdec_create_chn and kd_mpi_vdec_start_chn.
Example
None.
Related Topics
None.
kd_mpi_vdec_set_rotation#
Description
Set the decoding rotation angle.
Syntax
k_s32 kd_mpi_vdec_set_rotation(k_u32 chn_num, k_rotation rotation)
Parameters
Parameter Name |
Description |
Input/Output |
|---|---|---|
chn_num |
Encode channel information. Value range: [0,VENC_MAX_CHN_NUMS). |
Input |
rotation |
Rotation angle enumeration. |
Input |
Return Value
Return Value |
Description |
|---|---|
0 |
success. |
non-0 |
Failure, see error code. |
Chip differences
None.
Requirements
Header File: mpi_vdec_api.h,k_type.h,k_module.h,k_sys_comm.h,k_vdec_comm.h
Library File: libvdec.a
Notes
Set between kd_mpi_vdec_create_chn and kd_mpi_vdec_start_chn.
Example
None.
Related Topics
None.
kd_mpi_vdec_close_fd#
Description
Shut down the VDEC device.
Syntax
k_s32 kd_mpi_vdec_close_fd()
Parameters None
Return Value
Return Value |
Description |
|---|---|
0 |
success. |
non-0 |
Failure, see error code. |
Chip differences
None.
Requirements
Header File: mpi_vdec_api.h,k_type.h,k_module.h,k_sys_comm.h,k_vdec_comm.h
Library File: libvdec.a
Notes
This function is called after all chn of kd_mpi_vdec_destroy_chn.
Example
None.
Related Topics
None.
data type#
Video encoding module#
The relevant data types of this function module are defined as follows:
VENC_MAX_CHN_NUMS: Define the maximum number of channels.
K_VENC_MAX_2D_OSD_REGION_NUM: Defines the maximum number of Regions for 2D operation superimposed OSD.
K_VENC_MAX_2D_BORDER_NUM: Defines the maximum number of 2D operation frames.
K_VENC_2D_COEF_NUM: Defines the number of 2D operation CSC conversion coefficients.
K_VENC_2D_MAX_CHN_NUM: Defines the number of 2D operation channels.
k_venc_rc_mode: Defines the encoding channel rate controller mode.
k_venc_pack_type: Defines the JPEG stream PACK type enumeration.
k_venc_2d_calc_mode: Defines the calculation mode enumeration of 2d operations.
k_venc_2d_src_dst_fmt: Defines the input and output data format enumeration of 2D operations.
k_venc_2d_osd_fmt: Defines the OSD layer data format enumeration for 2D operations.
k_venc_2d_add_order: Defines the OSD overlay enumeration for 2D operations.
k_rotation: Defines the encoded rotation angle enumeration.
k_venc_mirror: Defines the encoding flipping method enumeration.
k_venc_2d_color_gamut: Defines the color gamut enumeration for 2D operations.
k_venc_chn_attr: Define the encoding channel attribute structure.
k_venc_attr: Define the encoder attribute structure.
k_venc_rc_attr: Defines the encoding channel code rate controller attribute structure.
k_venc_cbr: Defines the H.264/H.265 encoding channel CBR attribute structure.
k_venc_vbr: Defines the H.264/H.265 encoding channel VBR attribute structure.
k_venc_fixqp: Defines the H.264/H.265 encoding channel Fixqp attribute structure.
k_venc_mjpeg_fixqp: Define the MJPEG encoding channel Fixqp attribute structure.
k_venc_chn_status: Defines the status structure of the encoding channel.
k_venc_stream: Define the frame code stream type structure.
k_venc_pack: Define the frame stream packet structure.
k_venc_2d_osd_attr: 2D overlay attribute structure.
k_venc_2d_border_attr: 2D frame structure.
k_venc_h265_sao: The structure that defines the H.265 protocol encoding channel Sao.
k_venc_rect: Define the rectangular area information structure.
k_venc_roi_attr: Define encoding region of interest information.
k_venc_h264_entropy: Defines the H.264 protocol encoding channel entropy encoding structure.
k_venc_h265_entropy: Defines the H.265 protocol encoding channel entropy encoding structure.
k_venc_2d_csc_attr: Define the 2D CSC parameter structure.
VENC_MAX_CHN_NUMS#
Description
Define the maximum number of channels.
definition
#define VENC_MAX_CHN_NUMS 4
Notes
None.
Related Data Types and Interfaces
None.
K_VENC_MAX_2D_OSD_REGION_NUM#
Description
Define the maximum number of Regions for 2D operation superimposed OSD.
definition
#define K_VENC_MAX_2D_OSD_REGION_NUM 8
Notes
None.
Related Data Types and Interfaces
None.
K_VENC_MAX_2D_BORDER_NUM#
Description
Define the maximum number of 2D operation frames.
definition
#define K_VENC_MAX_2D_BORDER_NUM 32
Notes
None.
Related Data Types and Interfaces
None.
K_VENC_2D_COEF_NUM#
Description
Define the number of 2D operation CSC conversion coefficients.
definition
#define K_VENC_2D_COEF_NUM 12
Notes
None.
Related Data Types and Interfaces
None.
K_VENC_2D_MAX_CHN_NUM#
Description
Define the number of 2D operation channels.
definition
#define K_VENC_2D_MAX_CHN_NUM 3
Notes
None.
Related Data Types and Interfaces
None.
k_venc_rc_mode#
Description
Define encoding channel rate controller mode.
definition
typedef enum { K_VENC_RC_MODE_CBR = 1, K_VENC_RC_MODE_VBR, K_VENC_RC_MODE_FIXQP, K_VENC_RC_MODE_MJPEG_FIXQP, K_VENC_RC_MODE_BUTT, } k_venc_rc_mode;
member
member name |
Description |
|---|---|
K_VENC_RC_MODE_CBR |
H.264/H.265 CBR mode. |
K_VENC_RC_MODE_VBR |
H.264/H.265 VBR mode. |
K_VENC_RC_MODE_FIXQP |
H.264/H.265 Fixqp mode. |
K_VENC_RC_MODE_MJPEG_FIXQP |
MJPEG Fixqp mode. |
Notes
None.
Related Data Types and Interfaces
None.
k_venc_pack_type#
Description
Defines the JPEG stream PACK type enumeration.
definition
typedef enum { K_VENC_P_FRAME = 1, K_VENC_I_FRAME = 2, K_VENC_HEADER = 3, K_VENC_BUTT } k_venc_pack_type;
member
member name |
Description |
|---|---|
K_VENC_P_FRAME |
I frame. |
K_VENC_I_FRAME |
P frame. |
K_VENC_HEADER |
Header。 |
Notes
None.
Related Data Types and Interfaces
None.
k_venc_2d_calc_mode#
Description
An enumeration that defines calculation modes for 2D operations.
definition
typedef enum { K_VENC_2D_CALC_MODE_CSC = 0, K_VENC_2D_CALC_MODE_OSD, K_VENC_2D_CALC_MODE_BORDER, K_VENC_2D_CALC_MODE_OSD_BORDER, K_VENC_2D_CALC_MODE_BUTT } k_venc_2d_calc_mode;
member
member name |
Description |
|---|---|
K_VENC_2D_CALC_MODE_CSC |
Image format conversion. |
K_VENC_2D_CALC_MODE_OSD |
Picture overlay. |
K_VENC_2D_CALC_MODE_BORDER |
picture frame. |
K_VENC_2D_CALC_MODE_OSD_BORDER |
First overlay the picture, then draw the frame. |
Notes
K_VENC_2D_CALC_MODE_CSC mode is currently not supported.
Related Data Types and Interfaces
None.
k_venc_2d_src_dst_fmt#
Description
Defines the input and output data format enumeration of 2D operations.
definition
typedef enum { K_VENC_2D_SRC_DST_FMT_YUV420_NV12= 0, K_VENC_2D_SRC_DST_FMT_YUV420_NV21, K_VENC_2D_SRC_DST_FMT_YUV420_I420, K_VENC_2D_SRC_DST_FMT_ARGB8888 = 4, K_VENC_2D_SRC_DST_FMT_ARGB4444, K_VENC_2D_SRC_DST_FMT_ARGB1555, K_VENC_2D_SRC_DST_FMT_XRGB8888, K_VENC_2D_SRC_DST_FMT_XRGB4444, K_VENC_2D_SRC_DST_FMT_XRGB1555, K_VENC_2D_SRC_DST_FMT_BGRA8888, K_VENC_2D_SRC_DST_FMT_BGRA4444, K_VENC_2D_SRC_DST_FMT_BGRA5551, K_VENC_2D_SRC_DST_FMT_BGRX8888, K_VENC_2D_SRC_DST_FMT_BGRX4444, K_VENC_2D_SRC_DST_FMT_BGRX5551, K_VENC_2D_SRC_DST_FMT_RGB888, K_VENC_2D_SRC_DST_FMT_BGR888, K_VENC_2D_SRC_DST_FMT_RGB565, K_VENC_2D_SRC_DST_FMT_BGR565, K_VENC_2D_SRC_DST_FMT_SEPERATE_RGB, K_VENC_2D_SRC_DST_FMT_BUTT } k_venc_2d_src_dst_fmt;
Notes
None.
Related Data Types and Interfaces
None.
k_venc_2d_osd_fmt#
Description
Defines the OSD layer data format enumeration for 2D operations.
definition
typedef enum { K_VENC_2D_OSD_FMT_ARGB8888= 0, K_VENC_2D_OSD_FMT_ARGB4444, K_VENC_2D_OSD_FMT_ARGB1555, K_VENC_2D_OSD_FMT_XRGB8888, K_VENC_2D_OSD_FMT_XRGB4444, K_VENC_2D_OSD_FMT_XRGB1555, K_VENC_2D_OSD_FMT_BGRA8888, K_VENC_2D_OSD_FMT_BGRA4444, K_VENC_2D_OSD_FMT_BGRA5551, K_VENC_2D_OSD_FMT_BGRX8888, K_VENC_2D_OSD_FMT_BGRX4444, K_VENC_2D_OSD_FMT_BGRX5551, K_VENC_2D_OSD_FMT_RGB888, K_VENC_2D_OSD_FMT_BGR888, K_VENC_2D_OSD_FMT_RGB565, K_VENC_2D_OSD_FMT_BGR565, K_VENC_2D_OSD_FMT_SEPERATE_RGB, K_VENC_2D_OSD_FMT_BUTT } k_venc_2d_osd_fmt;
Notes
Currently, overlay images only support the formats of ARGB8888, ARGB4444, and ARGB1555.
Related Data Types and Interfaces
None.
k_venc_2d_add_order#
Description
Defines the sequential enumeration of OSD overlays (video, osd and background layers) for 2D operations.
definition
typedef enum { /* bottom ——> top */ K_VENC_2D_ADD_ORDER_VIDEO_OSD= 0, K_VENC_2D_ADD_ORDER_OSD_VIDEO, K_VENC_2D_ADD_ORDER_VIDEO_BG, K_VENC_2D_ADD_ORDER_BG_VIDEO, K_VENC_2D_ADD_ORDER_VIDEO_BG_OSD, K_VENC_2D_ADD_ORDER_VIDEO_OSD_BG, K_VENC_2D_ADD_ORDER_BG_VIDEO_OSD, K_VENC_2D_ADD_ORDER_BG_OSD_VIDEO, K_VENC_2D_ADD_ORDER_OSD_VIDEO_BG, K_VENC_2D_ADD_ORDER_OSD_BG_VIDEO, K_VENC_2D_ADD_ORDER_BUTT } k_venc_2d_add_order;
member
member name |
Description |
|---|---|
K_VENC_2D_ADD_ORDER_VIDEO_OSD |
Video is at the bottom and OSD is at the top. |
K_VENC_2D_ADD_ORDER_OSD_VIDEO |
OSD is on the bottom layer and video is on the top layer. |
K_VENC_2D_ADD_ORDER_VIDEO_BG |
Video is at the bottom and background color is at the top. |
K_VENC_2D_ADD_ORDER_BG_VIDEO |
The background color is on the bottom layer and the video is on the top layer. |
K_VENC_2D_ADD_ORDER_VIDEO_BG_OSD |
Video is on the bottom layer, background color is on the middle layer, and OSD is on the top layer. |
K_VENC_2D_ADD_ORDER_VIDEO_OSD_BG |
Video is on the bottom layer, OSD is on the middle layer, and background color is on the top layer. |
K_VENC_2D_ADD_ORDER_BG_VIDEO_OSD |
The background color is on the bottom layer, the video is on the middle layer, and the OSD is on the top layer. |
K_VENC_2D_ADD_ORDER_BG_OSD_VIDEO |
The background color is on the bottom layer, the OSD is on the middle layer, and the video is on the top layer. |
K_VENC_2D_ADD_ORDER_OSD_VIDEO_BG |
OSD is on the bottom layer, video is on the middle layer, and background color is on the top layer. |
K_VENC_2D_ADD_ORDER_OSD_BG_VIDEO |
The OSD is on the bottom layer, the background color is on the middle layer, and the video is on the top layer. |
Notes
None.
Related Data Types and Interfaces
None.
k_rotation#
Description
Defines an enumeration of encoded rotation angles.
definition
typedef enum { K_VPU_ROTATION_0 = 0, K_VPU_ROTATION_90 = 1, K_VPU_ROTATION_180 = 2, K_VPU_ROTATION_270 = 3, K_VPU_ROTATION_BUTT } k_rotation;
member
member name |
Description |
|---|---|
K_VPU_ROTATION_0 |
No rotation, rotation 0 degrees. |
K_VPU_ROTATION_90 |
Rotate 90 degrees. |
K_VPU_ROTATION_180 |
Rotate 180 degrees. |
K_VPU_ROTATION_270 |
Rotate 270 degrees. |
Notes
None.
Related Data Types and Interfaces
None.
k_venc_mirror#
Description
Defines the encoding flipping method enumeration.
definition
typedef enum { K_VENC_MIRROR_HORI = 0, K_VENC_MIRROR_VERT = 1, K_VENC_MIRROR_BUTT } k_venc_mirror;
member
member name |
Description |
|---|---|
K_VENC_MIRROR_HORI |
Flip horizontally. |
K_VENC_MIRROR_VERT |
Flip vertically. |
Notes
None.
Related Data Types and Interfaces
None.
k_venc_2d_color_gamut#
Description
Defines the color gamut enumeration for 2D operations.
definition
typedef enum { VENC_2D_COLOR_GAMUT_BT601 = 0, VENC_2D_COLOR_GAMUT_BT709, VENC_2D_COLOR_GAMUT_BT2020, VENC_2D_COLOR_GAMUT_BUTT } k_venc_2d_color_gamut;
member
member name |
Description |
|---|---|
VENC_2D_COLOR_GAMUT_BT601 |
BT.601 color gamut |
VENC_2D_COLOR_GAMUT_BT709, |
BT.709 color gamut |
VENC_2D_COLOR_GAMUT_BT2020 |
BT.2020 color gamut |
Notes
None.
Related Data Types and Interfaces
None.
k_venc_chn_attr#
Description
Define the encoding channel attribute structure.
definition
typedef struct { k_venc_attr venc_attr; k_venc_rc_attr rc_attr; } k_venc_chn_attr;
member
member name |
Description |
|---|---|
venc_attr |
Encoder properties. |
rc_attr |
Rate controller properties. |
Notes
None.
Related Data Types and Interfaces
None.
k_venc_attr#
Description
Define the encoder attribute structure.
definition
typedef struct { k_payload_type type; k_u32 pic_width; k_u32 pic_height; k_venc_profile profile; } k_venc_attr;
member
member name |
Description |
|---|---|
type |
Encoding protocol type. |
profile |
Encoded level enumeration. |
pic_width |
Encoded image width. Value range: |
pic_height |
Encoded image height. Value range: |
Notes
None.
Related Data Types and Interfaces
None.
k_venc_rc_attr#
Description
Define the encoding channel rate controller attribute structure.
definition
typedef struct { k_venc_rc_mode rc_mode; union { k_venc_cbr cbr; k_venc_vbr vbr; k_venc_fixqp fixqp; k_venc_mjpeg_fixqp mjpeg_fixqp; }; } k_venc_rc_attr;
member
member name |
Description |
|---|---|
rc_mode |
RC mode. |
cbr |
H.264/H.265 protocol encoding channel fixed bitrate mode attribute. |
vbr |
H.264/H.265 protocol encoding channel variable bitrate mode attribute. |
fixqp |
H.264/H.265 protocol encoding channel fixed qp mode attribute. |
mjpeg_fixqp |
Mjpeg protocol encoding channel Fixqp mode attribute. |
Notes
None.
Related Data Types and Interfaces
None.
k_venc_cbr#
Description
Define the H.264/H.265 encoding channel CBR attribute structure.
definition
typedef struct { k_u32 gop; k_u32 stats_time; k_u32 src_frame_rate; k_u32 dst_frame_rate; k_u32 bit_rate; } k_venc_cbr;
member
member name |
Description |
|---|---|
gop |
gop value. |
stats_time |
CBR code rate statistics time, in seconds. Value range: |
src_frame_rate |
Enter the frame rate in fps. |
dst_frame_rate |
Encoder output frame rate, in fps. |
bit_rate |
Average bitrate, in kbps. |
Notes
If the set bit rate exceeds the maximum real-time bit rate specified in the chip manual, real-time encoding cannot be guaranteed.
Related Data Types and Interfaces
None.
k_venc_vbr#
Description
Define the H.264/H.265 encoding channel VBR attribute structure.
definition
typedef struct { k_u32 gop; k_u32 stats_time; k_u32 src_frame_rate; k_u32 dst_frame_rate; k_u32 max_bit_rate; k_u32 bit_rate; } k_venc_vbr;
member
member name |
Description |
|---|---|
gop |
gop value. |
stats_time |
VBR code rate statistics time, in seconds. Value range: |
src_frame_rate |
Enter the frame rate in fps. |
dst_frame_rate |
Encoder output frame rate, in fps. |
max_bit_rate |
Maximum bitrate, in kbps. |
bit_rate |
Average bitrate, in kbps. |
Notes
See k_venc_cbr’s description of src_frame_rate and dst_frame_rate.
Related Data Types and Interfaces
None.
k_venc_fixqp#
Description
Define the H.264/H.265 encoding channel Fixqp attribute structure.
definition
typedef struct { k_u32 gop; k_u32 src_frame_rate; k_u32 dst_frame_rate; k_u32 i_qp; k_u32 p_qp; } k_venc_fixqp;
member
member name |
Description |
|---|---|
gop |
gop value. |
src_frame_rate |
Enter the frame rate in fps. |
dst_frame_rate |
Encoder output frame rate, in fps. |
i_qp |
Qp value of all macroblocks in I frame. Value range: |
q_qp |
Qp value of all macroblocks in P frame. Value range: |
Notes
See k_venc_cbr’s description of src_frame_rate and dst_frame_rate.
Related Data Types and Interfaces
None.
k_venc_mjpeg_fixqp#
Description
Define the MJPEG encoding channel Fixqp attribute structure.
definition
typedef struct { k_u32 src_frame_rate; k_u32 dst_frame_rate; k_u32 q_factor; } k_venc_mjpeg_fixqp;
member
member name |
Description |
|---|---|
src_frame_rate |
Enter the frame rate in fps. |
dst_frame_rate |
Encoder output frame rate, in fps. |
q_factor |
Qfactor for MJPEG encoding. Value range: |
Notes
See k_venc_cbr’s description of src_frame_rate and dst_frame_rate.
Related Data Types and Interfaces
None.
k_venc_chn_status#
Description
Defines the state structure of the encoding channel.
definition
typedef struct { k_u32 cur_packs; k_u64 release_pic_pts; k_bool end_of_stream; } k_venc_chn_status;
member
member name |
Description |
|---|---|
cur_packs |
The number of code stream packets in the current frame. |
release_pic_pts |
Release the PTS of the image corresponding to the code stream. |
end_of_stream |
Stream end flag. |
Notes
None.
Related Data Types and Interfaces
None.
k_venc_stream#
Description
Define the frame code stream type structure.
definition
typedef struct { k_venc_pack *pack; k_u32 pack_cnt; } k_venc_stream;
member
member name |
Description |
|---|---|
pack |
Frame stream packet structure. |
pack_cnt |
The number of all packets in one frame of code stream. |
Notes
None.
Related Data Types and Interfaces
None.
k_venc_pack#
Description
Define the frame stream packet structure.
definition
typedef struct { k_u64 phys_addr; k_u32 len; k_u64 pts; k_venc_pack_type type; } k_venc_pack;
member
member name |
Description |
|---|---|
phys_addr |
The physical address of the stream packet. |
len |
Stream packet length. |
pts |
timestamp. Unit: us. |
type |
Packet data type. |
Notes
None.
Related Data Types and Interfaces
None.
k_venc_2d_osd_attr#
Description
2D overlay attribute structure.
definition
typedef struct{
k_u16 width;
k_u16 height;
k_u16 startx;
k_u16 starty;
k_u32 phys_addr[3];
k_u8 bg_alpha;
k_u8 osd_alpha;
k_u8 video_alpha;
k_venc_2d_add_order add_order;
k_u32 bg_color;
k_venc_2d_osd_fmt fmt;
} k_venc_2d_osd_attr;
member
member name |
Description |
|---|---|
width |
The width of the OSD overlay area. |
height |
The height of the OSD overlay area. |
startx |
Pixel offset of the upper left point of the OSD overlay area in the x direction of the original image |
starty |
Pixel offset of the upper left point of the OSD overlay area in the y direction of the original image |
phys_addr |
The physical address of the OSD image. |
bg_alpha |
The transparency of the background layer. |
osd_alpha |
Transparency of OSD images. |
video_alpha |
The transparency of the video input image. |
add_order |
OSD overlay sequence enumeration. |
bg_color |
OSD background layer color, YUV444 format. Y: bit0~bit7 U: bit8~bit15 V: bit16~bit 23 |
fmt |
OSD image format enumeration. |
Notes
The source image and the destination image must ensure 8byte align at the starting address of ddr.
Supports even-numbered images and OSD sizes.
The src and dst addresses of the OSD must be the same.
Related Data Types and Interfaces
None.
k_venc_2d_border_attr#
Description
2D frame structure.
definition
typedef struct { k_u16 width; k_u16 height; k_u16 line_width; k_u32 color; k_u16 startx; k_u16 starty; } k_venc_2d_border_attr;
member
member name |
Description |
|---|---|
width |
The width of the frame area. This is the width of the outer frame, including line width. |
height |
The height of the frame area. This is the height of the outer frame, including line width. |
line_width |
The line width of the frame. |
color |
The color of the box. The format is YUV444 Y: bit0~bit7 U: bit8~bit15 V: bit16~bit 23 |
startx |
Pixel offset of the upper left point of the frame area in the x direction of the original image |
starty |
Pixel offset of the upper left point of the frame area in the y direction of the original image |
Notes
The source image and the destination image must ensure 8byte align at the starting address of ddr.
Supports even-numbered image and frame sizes.
The src and dst addresses must be the same.
Related Data Types and Interfaces
None.
k_venc_h265_sao#
Description
The structure that defines the H.265 protocol encoding channel Sao.
definition
typedef struct { k_u32 slice_sao_luma_flag; k_u32 slice_sao_chroma_flag; } k_venc_h265_sao;
member
member name |
Description |
|---|---|
slice_sao_luma_flag |
Default is 1. Value range: 0 or 1. |
slice_sao_chroma_flag |
Default is 1. Value range: 0 or 1. |
Notes
None.
k_venc_rect#
Description
Define the rectangular area information structure.
definition
typedef struct { k_s32 left; k_s32 right; k_u32 top; k_u32 bottom; } k_venc_rect;
member
member name |
Description |
|---|---|
left |
Left offset。 |
right |
Right offset。 |
top |
Top offset。 |
bottom |
Bottom offset。 |
Notes
None.
Related Data Types and Interfaces
None.
k_venc_roi_attr#
Description
Define encoding region of interest information.
definition
typedef struct { k_u32 idx; k_bool enable; k_bool is_abs_qp; k_s32 qp; k_venc_rect rect; } k_venc_roi_attr;
member
member name |
Description |
|---|---|
idx |
The index of the ROI area, the index range supported by the system is |
enable |
Whether to enable this ROI area. |
is_abs_qp |
ROI area QP mode. K_FALSE: Relative QP. K_TRUE: Absolute QP. |
qp |
QP value, range |
rect |
ROI area. left, right, top, bottom must be 16 aligned. |
Notes
None.
Related Data Types and Interfaces
None.
k_venc_h264_entropy#
Description
Define the H.264 protocol encoding channel entropy encoding structure.
definition
typedef struct { k_u32 entropy_coding_mode; k_u32 cabac_init_idc; } k_venc_h264_entropy;
member
member name |
Description |
|---|---|
entropy_coding_mode |
Entropy coding mode. 0: cavlc. 1: Cabac. >=2 has no meaning. Baseline does not support cabac. The default value is 1. |
cabac_init_idc |
Value range: |
Notes
None.
Related Data Types and Interfaces
None.
k_venc_h265_entropy#
Description
Define the H.265 protocol encoding channel entropy encoding structure.
definition
typedef struct { k_u32 cabac_init_flag; } k_venc_h265_entropy;
member
member name |
Description |
|---|---|
cabac_init_flag |
Value range: |
Notes
None.
Related Data Types and Interfaces
None.
k_venc_2d_csc_attr#
Description
Define VENC 2D CSC parameter structure.
definition
typedef struct { k_venc_2d_src_dst_fmt dst_fmt; } k_venc_2d_csc_attr;
member
member name |
Description |
|---|---|
dst_fmt |
Value range:. Referencek_venc_2d_src_dst_fmt |
Notes
None.
Related Data Types and Interfaces
None.
video decoding#
The relevant data types of this function module are defined as follows:
k_vdec_send_mode: Define the decoding channel attribute structure.
k_vdec_chn_attr: Define the decoding channel attribute structure.
k_vdec_chn_status: Define the channel status structure.
k_vdec_dec_err: Define the decoding error information structure.
k_vdec_stream: Defines the code stream structure of video decoding.
k_vdec_supplement_info: Define output frame supplementary information.
k_vdec_dsl_mode: Defines the decoding reduced size mode enum.
k_vdec_dsl_size: Defines the decoding size reduction parameter structure according to size.
k_vdec_dsl_ratio: Define decoding to reduce the size parameter structure proportionally.
k_vdec_downscale: reduced size structure.
k_vdec_send_mode#
Description
Define the decoding channel attribute structure.
definition
typedef enum { K_VDEC_SEND_MODE_STREAM = 0, K_VDEC_SEND_MODE_FRAME, K_VDEC_SEND_MODE_BUTT } k_vdec_send_mode;
member
member name |
Description |
|---|---|
K_VDEC_SEND_MODE_STREAM |
Send the code stream in streaming mode. |
OT_VDEC_SEND_MODE_FRAME |
Send the code stream in frames. In frames. |
Notes
Currently only streaming is supported.
Related Data Types and Interfaces
None.
k_vdec_chn_attr#
Description
Define the decoding channel attribute structure.
definition
typedef struct { k_payload_type type; k_vdec_send_mode mode; k_u32 pic_width; k_u32 pic_height; k_u32 stream_buf_size; } k_vdec_chn_attr;
member
member name |
Description |
|---|---|
type |
Decode protocol type enumeration value. |
mode |
Code stream sending method. |
pic_width |
The maximum width (in pixels) of the decoded image supported by the channel |
pic_height |
The maximum height (in pixels) of the decoded image supported by the channel |
stream_buf_size |
The size of the stream buffer. |
Notes
The currently supported pic_format is: PIXEL_FORMAT_YUV_SEMIPLANAR_420 and PIXEL_FORMAT_YVU_PLANAR_420.
Related Data Types and Interfaces
None.
k_vdec_chn_status#
Description
Define the channel status structure.
definition
typedef struct { k_payload_type type; k_bool is_started; k_u32 recv_stream_frames; k_u32 dec_stream_frames; k_vdec_dec_err dec_err; k_u32 width; k_u32 height; k_u64 latest_frame_pts; k_bool end_of_stream; } k_vdec_chn_status;
member
member name |
Description |
|---|---|
type |
Decode the protocol. |
is_started |
Whether the decoder has started receiving the code stream. |
recv_stream_frames |
“The number of received code stream frames in the code stream buffer. -1 means invalid. Invalid when sending in streaming mode.” |
dec_stream_frames |
The number of decoded frames in the stream buffer. |
dec_err |
Decode error messages. |
width |
Image width. |
height |
Image height. |
latest_frame_pts |
The timestamp of the latest decoded image. |
end_of_stream |
Stream end flag. |
Notes
None.
Related Data Types and Interfaces
None.
k_vdec_dec_err#
Description
Define the decoding error message structure.
definition
typedef struct { k_s32 set_pic_size_err; k_s32 format_err; k_s32 stream_unsupport; } k_vdec_dec_err;
member
member name |
Description |
|---|---|
set_pic_size_err |
The width (or height) of the image is greater than the width (or height) of the channel. |
format_err |
Unsupported format. |
stream_unsupport |
Unsupported specifications (the code stream specifications are inconsistent with the specifications claimed to be supported by the solution). |
Notes
None.
Related Data Types and Interfaces
None.
k_vdec_stream#
Description
Define the code stream structure for video decoding.
definition
typedef struct { k_bool end_of_stream; k_u64 pts; k_u32 len; k_u8 * addr; } k_vdec_stream;
member
member name |
Description |
|---|---|
end_of_stream |
Whether all code streams have been sent. |
pts |
The timestamp of the stream packet. The unit is μs. |
len |
The length of the stream packet. The unit is byte. |
addr |
The address of the stream packet. |
Notes
None.
Related Data Types and Interfaces
None.
k_vdec_supplement_info#
Description
Define output frame supplementary information.
definition
typedef struct { k_payload_type type; k_bool is_valid_frame; k_bool end_of_stream; } k_vdec_supplement_info;
member
member name |
Description |
|---|---|
type |
Decode protocol type enumeration value. |
is_valid_frame |
Whether it is a valid frame. |
end_of_stream |
Stream end flag. |
Notes
None.
Related Data Types and Interfaces
None.
k_vdec_dsl_mode#
Description
Defines the decoding reduced size mode enum.
definition
typedef enum { K_VDEC_DSL_MODE_BY_SIZE, K_VDEC_DSL_MODE_BY_RATIO, K_VDEC_DSL_MODE_BUTT } k_vdec_dsl_mode;
member
member name |
Description |
|---|---|
K_VDEC_DSL_MODE_BY_SIZE |
Decrease according to size. |
K_VDEC_DSL_MODE_BY_RATIO |
Decrease according to proportion. |
Notes
None.
Related Data Types and Interfaces
None.
k_vdec_dsl_size#
Description
Define decoding size reduction parameter structure by size.
definition
typedef struct { k_u32 dsl_frame_width; k_u32 dsl_frame_height; } k_vdec_dsl_size;
member
member name |
Description |
|---|---|
dsl_frame_width |
Width after size reduction. |
dsl_frame_height |
Height after reduced size. |
Notes
None.
Related Data Types and Interfaces
None.
k_vdec_dsl_ratio#
Description
Define decoding proportionally reduced size parameter structure.
definition
typedef struct { k_u8 dsl_ratio_hor; k_u8 dsl_ratio_ver; } k_vdec_dsl_ratio;
member
member name |
Description |
|---|---|
dsl_frame_width |
Reduce the horizontal proportion of the size. |
dsl_frame_height |
Reduce the vertical proportion of the size. |
Notes
None.
Related Data Types and Interfaces
None.
k_vdec_downscale#
Description
Reduce the size of the structure.
definition
typedef struct { k_vdec_dsl_mode dsl_mode; union { k_vdec_dsl_size dsl_size; k_vdec_dsl_ratio dsl_ratio; }; } k_vdec_downscale;
member
member name |
Description |
|---|---|
dsl_mode |
Reduce size mode enum. |
dsl_size |
Reduce the size parameter structure by size. |
dsl_ratio |
Proportionately reduce the size of the parameter structure. |
Notes
None.
Related Data Types and Interfaces
None.
error code#
Encoding API error codes
error code |
Macro definition |
Description |
|---|---|---|
0xa0098001 |
K_ERR_VENC_INVALID_DEVID |
Device ID is outside the legal range |
0xa0098002 |
K_ERR_VENC_INVALID_CHNID |
Channel ID is outside the legal range |
0xa0098003 |
K_ERR_VENC_ILLEGAL_PARAM |
Parameter exceeds legal range |
0xa0098004 |
K_ERR_VENC_EXIST |
Trying to apply for or create an existing device, channel or resource |
0xa0098005 |
K_ERR_VENC_UNEXIST |
Attempting to use or destroy a non-existent device, channel or resource |
0xa0098006 |
K_ERR_VENC_NULL_PTR |
There is a null pointer in the function parameter |
0xa0098007 |
K_ERR_VENC_NOT_CONFIG |
Not configured before use |
0xa0098008 |
K_ERR_VENC_NOT_SUPPORT |
Unsupported parameters or functions |
0xa0098009 |
K_ERR_VENC_NOT_PERM |
This operation is not allowed, such as trying to modify static configuration parameters |
0xa009800c |
K_ERR_VENC_NOMEM |
Failed to allocate memory, such as insufficient system memory |
0xa009800d |
K_ERR_VENC_NOBUF |
Failed to allocate cache, such as the requested data buffer is too large |
0xa009800e |
K_ERR_VENC_BUF_EMPTY |
No data in buffer |
0xa009800f |
K_ERR_VENC_BUF_FULL |
The buffer is full of data |
0xa0098010 |
K_ERR_VENC_NOTREADY |
The system is not initialized or the corresponding module is not loaded. |
0xa0098011 |
K_ERR_VENC_BADADDR |
The address is outside the legal range |
0xa0098012 |
K_ERR_VENC_BUSY |
VENC system is busy |
Decode API error codes
error code |
Macro definition |
Description |
|---|---|---|
0xa00a8001 |
K_ERR_VDEC_INVALID_DEVID |
Device ID is outside the legal range |
0xa00a8002 |
K_ERR_VDEC_INVALID_CHNID |
Channel ID is outside the legal range |
0xa00a8003 |
K_ERR_VDEC_ILLEGAL_PARAM |
Parameter exceeds legal range |
0xa00a8004 |
K_ERR_VDEC_EXIST |
Trying to apply for or create an existing device, channel or resource |
0xa00a8005 |
K_ERR_VDEC_UNEXIST |
Attempting to use or destroy a non-existent device, channel or resource |
0xa00a8006 |
K_ERR_VDEC_NULL_PTR |
There is a null pointer in the function parameter |
0xa00a8007 |
K_ERR_VDEC_NOT_CONFIG |
Not configured before use |
0xa00a8008 |
K_ERR_VDEC_NOT_SUPPORT |
Unsupported parameters or functions |
0xa00a8009 |
K_ERR_VDEC_NOT_PERM |
This operation is not allowed, such as trying to modify static configuration parameters |
0xa00a800c |
K_ERR_VDEC_NOMEM |
Failed to allocate memory, such as insufficient system memory |
0xa00a800d |
K_ERR_VDEC_NOBUF |
Failed to allocate cache, such as the requested data buffer is too large |
0xa00a800e |
K_ERR_VDEC_BUF_EMPTY |
No data in buffer |
0xa00a800f |
K_ERR_VDEC_BUF_FULL |
The buffer is full of data |
0xa00a8010 |
K_ERR_VDEC_NOTREADY |
The system is not initialized or the corresponding module is not loaded. |
0xa00a8011 |
K_ERR_VDEC_BADADDR |
The address is outside the legal range |
0xa00a8012 |
K_ERR_VDEC_BUSY |
VDEC system busy |
debugging information#
For multimedia memory management and system binding debugging information, please refer to “K230 System Control API Reference”.
