VENC Functions and Restrictions

The Atlas training products does not support the VENC function described in this section.

For the Atlas A2 training products/Atlas A2 inference products, this function is not supported.

For the Atlas A3 training products/Atlas A3 inference products, this function is not supported.

Function Usage

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

Resolution Restrictions

  • Input image resolution range

    Version

    Resolution Range

    Atlas inference products

    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 products

    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

For details about the input buffer size, see the formula in Table 1. The output buffer is managed by the system, and therefore does not need to be allocated or freed by the user.

Version

Buffer Allocation/Freeing API

Atlas inference products

During VENC video encoding, call acl.himpi.dvpp_malloc\acl.himpi.dvpp_free to allocate or free the input buffer on the device. The buffer lifetime is managed by the user.

Atlas 200I/500 A2 inference products

During VENC video encoding, the following two types of buffer allocation/freeing APIs are supported:

acl.himpi.dvpp_malloc allocates a dedicated buffer for processing media data. However, the address space of the dedicated buffer is limited. If buffer planning is cared or buffer resources are limited, you are advised to allocate buffer by calling acl.rt.malloc.

Atlas inference products

In the VENC scenario, the following two types of buffer allocation/freeing APIs are supported for storing input image data:

  • Allocate or free the input buffer on the device by calling acl.rt.malloc/acl.rt.free. The buffer lifetime is managed by the user. During buffer allocation, you are advised to allocate buffer of the ACL_MEM_MALLOC_HUGE_FIRST type. Huge page buffer has better performance and therefore is preferred.
  • Allocate or free the input buffer on the device by calling acl.himpi.dvpp_malloc/acl.himpi.dvpp_free. The buffer lifetime is managed by the user.

In the VENC scenario, if non-input image data (such as the QpMap table information) is stored, only acl.himpi.dvpp_malloc/acl.himpi.dvpp_free can be used to allocate and free the input buffer on the device, respectively. The lifecycle of the buffer is managed by the user.

Note: acl.himpi.dvpp_malloc allocates a dedicated buffer for processing media data. However, the address space of the dedicated buffer is limited. If buffer planning is cared or buffer resources are limited, you are advised to allocate buffer by calling acl.rt.malloc.

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

For details about the definition of the input image format, see hi_pixel_format. For details about the concepts such as 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

Input Width Stride, Height Stride, and Buffer Size

Output Format

YUV420SP NV12 8-bit

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 stride x 3/2

  • H.264 BP/MP/HP
  • H.265 MP (slice streams only)

YUV420SP NV21 8-bit