VENC Functions and Restrictions

Function Description

Video Encoder (VENC) encodes YUV420SP NV12/NV21 8-bit images into H.264/H.265 video streams.

Resolution Restrictions

Input image resolution::

Model

Resolution Range

Atlas inference product

The width and height range from 128 to 4096. For H.264 streams, the maximum resolution must not exceed 4096 x 2304.

Atlas 200I/500 A2 inference product

114 x 114 to 8192 x 8192

Output stream resolution:

VENC only encodes images and does not change the image resolution. Therefore, the resolution of the output image is the same as that of the input image.

Restrictions on Buffer Allocation and Freeing APIs

During VENC video encoding, call the hi_mpi_dvpp_malloc\hi_mpi_dvpp_free API to allocate or release the input buffer on the device. For details about the buffer size, see the formula in Restrictions on Stream/Image Formats, Width and Height Alignment, and Buffers. The lifecycle of the input buffer is managed by the user. The output memory does not need to be managed by users and is managed by the system.

For the following product models, the aclrtMalloc\aclrtFree API can be called to allocate or release the input buffer on the device. The lifecycle of the buffer is managed by users.

Atlas 200I/500 A2 inference product

Atlas inference product

The memory allocated by calling hi_mpi_dvpp_malloc is the dedicated memory for media data processing. However, the address space of the dedicated memory is limited. If you are concerned about memory planning or memory resources are limited, you are advised to call aclrtMalloc to allocate memory. When aclrtMalloc is called to apply for memory, you are advised to apply for memory of the ACL_MEM_MALLOC_HUGE_FIRST type. Huge pages are preferentially applied for, which has better performance.

Note: In the VENC scenario, if non-input image data (such as the QpMap table information) is stored, only the hi_mpi_dvpp_malloc\hi_mpi_dvpp_free API can be used to allocate or free the input memory on the device. The lifecycle of the memory is managed by the user.

Restrictions on Stream/Image Formats, Width and Height Alignment, and Buffers

For details about the input image format, see hi_pixel_format. For details about the width stride and height stride, see Terminology.

Table 1 Restrictions on the image format, width and height alignment, and buffer size

Input Format

Input Width and Height Alignment

Input Width Stride, Height Stride, and Buffer Size

Output Format

YUV420SP NV12 8bit

YUV420SP NV21 8bit

Width: Must be a multiple of 2.

Height: Must be a multiple of 2.

Width stride: Round up the width to the nearest multiple of 16.

The height stride does not need to be configured.

Buffer size (in bytes) = Width stride x Height x 3/2

  • H264 BP/MP/HP
  • H265 Main Profile (Only slice streams are supported.)