VDEC
- Functions and Restrictions
- Function: vdec_create_frame_config
- Function: vdec_destroy_frame_config
- Function: vdec_create_channel
- Function: vdec_destroy_channel
- Function: vdec_create_channel_desc
- Function: vdec_destroy_channel_desc
- Function: vdec_set_channel_desc_channel_id
- Function: vdec_set_channel_desc_thread_id
- Function: vdec_set_channel_desc_callback
- Function: vdec_set_channel_desc_entype
- Function: vdec_set_channel_desc_out_pic_format
- Function: vdec_set_channel_desc_out_pic_width
- Function: vdec_set_channel_desc_out_pic_height
- Function: vdec_set_channel_desc_ref_frame_num
- Function: vdec_get_channel_desc_channel_id
- Function: vdec_get_channel_desc_thread_id
- Function: vdec_get_channel_desc_callback
- Function: vdec_get_channel_desc_entype
- Function: vdec_get_channel_desc_out_pic_format
- Function: vdec_get_channel_desc_out_pic_width
- Function: vdec_get_channel_desc_out_pic_height
- Function: vdec_get_channel_desc_ref_frame_num
Functions and Restrictions
Functions and Restrictions
The video decoder (VDEC) decodes videos. After VPC processing, the VDEC outputs YUV420SP images (including NV12 and NV21).
Input description
Input resolution range:
128 x 128 to 4096 x 4096
Input formats:
H.264 BP/MP/HP Level 5.1 YUV420SP encoded streams
H.265 8-bit/10-bit Level 5.1 YUV420 encoded streams
Input memory:
Allocate memory by calling acl.rt.malloc and free memory by calling acl.rt.free. Alternatively, allocate memory by calling acl.media.dvpp_malloc and free memory by calling acl.media.dvpp_free.
Output description
Output image formats:
YUV420SP NV12
YUV420SP NV21
Output memory:
Calculate the output memory size according to the image format.
YUV420SP: widthStride x heightStride x 3/2
The start address of the output memory must be 16-byte aligned. Allocate memory by calling acl.media.dvpp_malloc and free memory by calling acl.media.dvpp_free.
widthStride and heightStride alignment:
widthStride: Round up the input width to the nearest multiple of 16.
heightStride: Round up the input height to the nearest multiple of 2.
The VDEC decodes input streams frame by frame.
Bad frames or frame loss in the streams may cause VDEC frame loss.
The VDEC cannot decode the streams encoded in interlaced scanning mode.
Performance Specifications
The recommended number of channels (n) for VDEC decoding is as follows:
720p indicates a resolution of 1280 x 720 pixels. 1080p indicates a resolution of 1920 x 1080 pixels. 4K indicates a resolution of 3840 x 2160 pixels.Resolution
Total Frame Rate
Single-channel performance (n)
Memory Consumption Per VDEC Channel (for Reference Only)
3840*2160
120fps
120 fps/n (n = 4 is recommended, 30 fps per channel.)
About 170 MB
1920*1080
480fps
480 fps/n (n = 16 is recommended, 30 fps per channel.)
About 86 MB
≤1280*720
960fps
960 fps/n (n = 32 is recommended, 30 fps per channel.)
About 70 MB
Suggestions on the number of decoding channels and frame rate:
The specifications in the following table are for reference only. If the number of channels started in a single process exceeds the specifications in the following table, memory insufficiency or performance drop may occur, leading to decoding channel creation failures and slow decoding.
720p indicates a resolution of 1280 x 720 pixels. 1080p indicates a resolution of 1920 x 1080 pixels. 4K indicates a resolution of 3840 x 2160 pixels.
Typical Resolution
Suggested Channel Count Per Process (Based on the Input Frame Rate)
-
Input frame rate ≥ 25 fps
20 fps < input frame rate < 25 fps
15 fps < input frame rate ≤ 20 fps
10 fps < input frame rate ≤ 15 fps
Input frame rate ≤ 10 fps
≤720p
32 channels
32 channels
32 channels
32 channels
32 channels
1080p
16 channels
19 channels
24 channels
32 channels
32 channels
4K
4 channels
4 channels
6 channels
8 channels
12 channels
Function: vdec_create_frame_config
C Prototype |
aclvdecFrameConfig *aclvdecCreateFrameConfig() |
---|---|
Python Function |
vdec_frame_config = acl.media.vdec_create_frame_config() |
Function Usage |
Creates data of the aclvdecFrameConfig type as the single-frame encoding configuration. It is a synchronous interface. |
Input Description |
None |
Return Value |
vdec_frame_config: int, pointer to data of the aclvdecFrameConfig type object.
|
Restrictions |
None |
Precautions |
None |
Function: vdec_destroy_frame_config
C Prototype |
aclError aclvdecDestroyFrameConfig(aclvdecFrameConfig *vdecFrameConfig) |
---|---|
Python Function |
ret = acl.media.vdec_destroy_frame_config(vdec_frame_config) |
Function Usage |
Destroys the configuration data created by calling acl.media.vdec_create_frame_config. It is a synchronous interface. |
Input Description |
vdec_frame_config: int, data to be destroyed. |
Return Value |
ret: int, error code.
|
Restrictions |
Destruction API: The released or destroyed resources are no longer available after this API is called. You are advised to set the released or destroyed resources to invalid values (for example, 0 or None) after calling this API. |
Precautions |
None |
Function: vdec_create_channel
C Prototype |
aclError aclvdecCreateChannel(aclvdecChannelDesc *channelDesc) |
---|---|
Python Function |
ret = acl.media.vdec_create_channel(vdec_channel_desc) |
Function Usage |
Creates a channel for video data processing. A channel can be reused. After being destroyed, the channel is no longer available. It is a synchronous interface. acl.rt.create_stream is encapsulated in the acl.media.vdec_create_channel to explicitly create a stream. acl.rt.subscribe_report specifies the thread for processing the callback function on the stream. The callback function and thread are specified when users call acl.media.vdec_set_channel_desc series. When implementing the VDEC function, you do not need to call acl.rt.create_stream and acl.rt.subscribe_report separately. |
Input Description |
vdec_channel_desc: int, VDEC channel description address object, description of the specified channel. acl.media.vdec_create_channel_desc is called to create data of the vdec_channel_desc type, and acl.media.vdec_set_channel_desc series is called to set the attributes of the channel description. |
Return Value |
ret: int, error code.
|
Restrictions |
None |
Precautions |
None |
Function: vdec_destroy_channel
C Prototype |
aclError aclvdecDestroyChannel(aclvdecChannelDesc *channelDesc) |
---|---|
Python Function |
ret = acl.media.vdec_destroy_channel(vdec_channel_desc) |
Function Usage |
|
Input Description |
vdec_channel_desc: int, VDEC channel description address object, description of the specified channel. It must be the same as the vdec_channel_desc argument passed to the acl.media.vdec_create_channel call. |
Return Value |
ret: int, error code.
|
Restrictions |
Destruction API: The released or destroyed resources are no longer available after this API is called. You are advised to set the released or destroyed resources to invalid values (for example, 0 or None) after calling this API. |
Precautions |
None |
Function: vdec_create_channel_desc
C Prototype |
aclvdecChannelDesc *aclvdecCreateChannelDesc() |
---|---|
Python Function |
vdec_channel_desc = acl.media.vdec_create_channel_desc() |
Function Usage |
Creates data of the vdec_channel_desc type to describe a video decoding channel. It is a synchronous interface. |
Input Description |
None |
Return Value |
vdec_channel_desc: int, VDEC channel description address object.
|
Restrictions |
None |
Precautions |
None |
Function: vdec_destroy_channel_desc
C Prototype |
aclError aclvdecDestroyChannelDesc(aclvdecChannelDesc *channelDesc) |
---|---|
Python Function |
ret = acl.media.vdec_destroy_channel_desc(vdec_channel_desc) |
Function Usage |
Destroys the vdec_channel_desc data. Only the vdec_channel_desc data created by calling acl.media.vdec_create_channel_desc can be destroyed. It is a synchronous interface. |
Input Description |
vdec_channel_desc: int, VDEC channel description address object, data to be destroyed. |
Return Value |
ret: int, error code.
|
Restrictions |
Destruction API: The released or destroyed resources are no longer available after this API is called. You are advised to set the released or destroyed resources to invalid values (for example, 0 or None) after calling this API. |
Precautions |
None |
Function: vdec_set_channel_desc_channel_id
C Prototype |
aclError aclvdecSetChannelDescChannelId(aclvdecChannelDesc *channelDesc, uint32_t channelId) |
---|---|
Python Function |
ret = acl.media.vdec_set_channel_desc_channel_id(vdec_channel_desc, channel_id) |
Function Usage |
Sets the decoding channel description attribute: decoding channel ID. |
Input Description |
vdec_channel_desc: int, VDEC channel description address object, to describe a video decoding channel. channel_id: int, decoding channel ID. The value range is [0, 31]. |
Return Value |
ret: int, error code.
|
Restrictions |
None |
Precautions |
None |
Function: vdec_set_channel_desc_thread_id
C Prototype |
aclError aclvdecSetChannelDescThreadId(aclvdecChannelDesc *channelDesc, uint64_t threadId) |
---|---|
Python Function |
ret = acl.media.vdec_set_channel_desc_thread_id(vdec_channel_desc, thread_id) |
Function Usage |
Sets the decoding channel description attribute: callback thread ID. |
Input Description |
vdec_channel_desc: int, VDEC channel description address object, to describe a video decoding channel. thread_id: int, callback thread ID. |
Return Value |
ret: int, error code.
|
Restrictions |
It is not allowed to pass the same thread ID for registering different VDEC callback functions on different devices in the same process. |
Precautions |
None |
Function: vdec_set_channel_desc_callback
C Prototype |
aclError aclvdecSetChannelDescCallback(aclvdecChannelDesc *channelDesc, aclvdecCallback callback) |
---|---|
Python Function |
ret = acl.media.vdec_set_channel_desc_callback(vdec_channel_desc, callback) |
Function Usage |
Sets the decoding channel description attribute: callback function. |
Input Description |
vdec_channel_desc: int, VDEC channel description address object, to describe a video decoding channel. callback: Python function object, callback function.
|
Return Value |
ret: int, error code.
|
Restrictions |
None |
Precautions |
None |
Function: vdec_set_channel_desc_entype
C Prototype |
aclError aclvdecSetChannelDescEnType(aclvdecChannelDesc *channelDesc, acldvppStreamFormat enType) |
---|---|
Python Function |
ret = acl.media.vdec_set_channel_desc_entype(vdec_channel_desc, entype) |
Function Usage |
Sets the decoding channel description attribute: video encoding protocol. |
Input Description |
vdec_channel_desc: int, VDEC channel description address object, to describe a video decoding channel. entype: int, video encoding protocol.
|
Return Value |
ret: int, error code.
|
Restrictions |
None |
Precautions |
None |
Function: vdec_set_channel_desc_out_pic_format
C Prototype |
aclError aclvdecSetChannelDescOutPicFormat(aclvdecChannelDesc *channelDesc, acldvppPixelFormat outPicFormat) |
---|---|
Python Function |
ret = acl.media.vdec_set_channel_desc_out_pic_format(vdec_channel_desc, out_pic_format) |
Function Usage |
Sets the decoding channel description attribute: YUV image storage format. |
Input Description |
vdec_channel_desc: int, VDEC channel description address object, to describe a video decoding channel. out_pic_format: int, YUV image storage format.
|
Return Value |
ret: int, error code.
|
Restrictions |
None |
Precautions |
If acl.vdec.set_channel_desc_out_pic_format is not called to set the output format, images in YUV420SP NV12 are output by default. |
Function: vdec_set_channel_desc_out_pic_width
C Prototype |
aclError aclvdecSetChannelDescOutPicWidth(aclvdecChannelDesc *channelDesc, uint32_t outPicWidth) |
---|---|
Python Function |
ret = acl.media.vdec_set_channel_desc_out_pic_width(vdec_channel_desc, out_pic_width) |
Function Usage |
Sets the decoding channel description attribute: image width. |
Input Description |
vdec_channel_desc: int, VDEC channel description address object, to describe a video decoding channel. out_pic_width: int, maximum output width. |
Return Value |
ret: int, error code.
|
Restrictions |
None |
Precautions |
None |
Function: vdec_set_channel_desc_out_pic_height
C Prototype |
aclError aclvdecSetChannelDescOutPicHeight(aclvdecChannelDesc *channelDesc, uint32_t outPicHeight) |
---|---|
Python Function |
ret = acl.media.vdec_set_channel_desc_out_pic_height(vdec_channel_desc, out_pic_height) |
Function Usage |
Sets the decoding channel description attribute: image height. |
Input Description |
vdec_channel_desc: int, VDEC channel description address object, to describe a video decoding channel. out_pic_height: int, maximum output height. |
Return Value |
ret: int, error code.
|
Restrictions |
None |
Precautions |
None |
Function: vdec_set_channel_desc_ref_frame_num
C Prototype |
aclError aclvdecSetChannelDescRefFrameNum(aclvdecChannelDesc *channelDesc, uint32_t refFrameNum) |
---|---|
Python Function |
ret = acl.media.vdec_set_channel_desc_ref_frame_num(vdec_channel_desc, ref_frame_num) |
Function Usage |
Sets the decoding channel description attribute: number of reference frames. |
Input Description |
vdec_channel_desc: int, VDEC channel description address object, to describe a video decoding channel. ref_frame_num: int, number of reference frames. The value range is [0, 16]. |
Return Value |
ret: int, error code.
|
Restrictions |
None |
Precautions |
None |
Function: vdec_get_channel_desc_channel_id
C Prototype |
uint32_t aclvdecGetChannelDescChannelId(const aclvdecChannelDesc *channelDesc) |
---|---|
Python Function |
channel_id = acl.media.vdec_get_channel_desc_channel_id(vdec_channel_desc) |
Function Usage |
Obtains the decoding channel description attribute: decoding channel ID. |
Input Description |
vdec_channel_desc: int, VDEC channel description address object, to describe a video decoding channel. |
Return Value |
channel_id: int, decoding channel ID. The value range is [0, 31]. |
Restrictions |
None |
Precautions |
None |
Function: vdec_get_channel_desc_thread_id
C Prototype |
uint32_t aclvdecGetChannelDescThreadId(const aclvdecChannelDesc *channelDesc); |
---|---|
Python Function |
thread_id = acl.media.vdec_get_channel_desc_thread_id(vdec_channel_desc) |
Function Usage |
Obtains the decoding channel description attribute: callback thread ID. |
Input Description |
vdec_channel_desc: int, VDEC channel description address object, to describe a video decoding channel. |
Return Value |
thread_id: int, callback thread ID. |
Restrictions |
None |
Precautions |
None |
Function: vdec_get_channel_desc_callback
C Prototype |
aclvdecCallback aclvdecGetChannelDescCallback(const aclvdecChannelDesc *channelDesc) |
---|---|
Python Function |
callback = acl.media.vdec_get_channel_desc_callback(vdec_channel_desc) |
Function Usage |
Obtains the decoding channel description attribute: callback function. |
Input Description |
vdec_channel_desc: int, VDEC channel description address object, to describe a video decoding channel. |
Return Value |
callback: Python function object, callback function.
|
Restrictions |
None |
Precautions |
None |
Function: vdec_get_channel_desc_entype
C Prototype |
acldvppStreamFormat aclvdecGetChannelDescEnType(const aclvdecChannelDesc *channelDesc); |
---|---|
Python Function |
entype = acl.media.vdec_get_channel_desc_entype(vdec_channel_desc) |
Function Usage |
Obtains the decoding channel description attribute: video encoding protocol. |
Input Description |
vdec_channel_desc: int, VDEC channel description address object, to describe a video decoding channel. |
Return Value |
entype: int, video encoding protocol. H265_MAIN_LEVEL = 0 H264_BASELINE_LEVEL = 1 H264_MAIN_LEVEL = 2 H264_HIGH_LEVEL = 3 |
Restrictions |
None |
Precautions |
None |
Function: vdec_get_channel_desc_out_pic_format
C Prototype |
acldvppPixelFormat aclvdecGetChannelDescOutPicFormat(const aclvdecChannelDesc *channelDesc); |
---|---|
Python Function |
out_pic_format = acl.media.vdec_get_channel_desc_out_pic_format(vdec_channel_desc) |
Function Usage |
Obtains the decoding channel description attribute: YUV image storage format. |
Input Description |
vdec_channel_desc: int, VDEC channel description address object, to describe a video decoding channel. |
Return Value |
out_pic_format: int, YUV image storage format. For details, see dvpp_set_pic_desc_format. |
Restrictions |
None |
Precautions |
None |
Function: vdec_get_channel_desc_out_pic_width
C Prototype |
uint32_t aclvdecGetChannelDescOutPicWidth(const aclvdecChannelDesc *channelDesc); |
---|---|
Python Function |
out_pic_width = acl.media.vdec_get_channel_desc_out_pic_width(vdec_channel_desc) |
Function Usage |
Obtains the decoding channel description attribute: image width. |
Input Description |
vdec_channel_desc: int, VDEC channel description address object, to describe a video decoding channel. |
Return Value |
out_pic_width: int, image width. |
Restrictions |
None |
Precautions |
None |
Function: vdec_get_channel_desc_out_pic_height
C Prototype |
uint32_t aclvdecGetChannelDescOutPicHeight(const aclvdecChannelDesc *channelDesc); |
---|---|
Python Function |
out_pic_height = acl.media.vdec_get_channel_desc_out_pic_height(vdec_channel_desc) |
Function Usage |
Obtains the decoding channel description attribute: image height. |
Input Description |
vdec_channel_desc: int, VDEC channel description address object, to describe a video decoding channel. |
Return Value |
out_pic_height: int, image height. |
Restrictions |
None |
Precautions |
None |
Function: vdec_get_channel_desc_ref_frame_num
C Prototype |
uint32_t aclvdecGetChannelDescRefFrameNum(const aclvdecChannelDesc *channelDesc) |
---|---|
Python Function |
ref_frame_num = acl.media.vdec_get_channel_desc_ref_frame_num(vdec_channel_desc) |
Function Usage |
Obtains the decoding channel description attribute: number of reference frames. |
Input Description |
vdec_channel_desc: int, VDEC channel description address object, to describe a video decoding channel. |
Return Value |
ref_frame_num: int, number of reference frames. The value range is [0, 16]. |
Restrictions |
None |
Precautions |
None |
- Functions and Restrictions
- Function: vdec_create_frame_config
- Function: vdec_destroy_frame_config
- Function: vdec_create_channel
- Function: vdec_destroy_channel
- Function: vdec_create_channel_desc
- Function: vdec_destroy_channel_desc
- Function: vdec_set_channel_desc_channel_id
- Function: vdec_set_channel_desc_thread_id
- Function: vdec_set_channel_desc_callback
- Function: vdec_set_channel_desc_entype
- Function: vdec_set_channel_desc_out_pic_format
- Function: vdec_set_channel_desc_out_pic_width
- Function: vdec_set_channel_desc_out_pic_height
- Function: vdec_set_channel_desc_ref_frame_num
- Function: vdec_get_channel_desc_channel_id
- Function: vdec_get_channel_desc_thread_id
- Function: vdec_get_channel_desc_callback
- Function: vdec_get_channel_desc_entype
- Function: vdec_get_channel_desc_out_pic_format
- Function: vdec_get_channel_desc_out_pic_width
- Function: vdec_get_channel_desc_out_pic_height
- Function: vdec_get_channel_desc_ref_frame_num