VENC Functions and Restrictions

The Ascend 910_95 AI Processor does not support this function.

The Atlas A2 training products/Atlas A2 inference products do not support this function.

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

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 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 encodes images without changing the image resolution. Therefore, the output image resolution is the same as the input image resolution.

APIs for Buffer Allocation and Freeing

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.

Model

APIs for Buffer Allocation and Freeing

Atlas 200I/500 A2 inference products

When using VENC, the following two types of APIs for buffer allocation/freeing are supported:

  • Call aclrtMalloc to allocate the input buffer on the device, and aclrtFree to free the input buffer. 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 is preferred.
  • Call hi_mpi_dvpp_malloc to allocate the input buffer on the device, and hi_mpi_dvpp_free to free the input buffer. The buffer lifetime is managed by the user.

Note: hi_mpi_dvpp_malloc allocates a dedicated buffer for processing media data. However, the address space of the dedicated buffer is limited. If buffer resources are limited, aclrtMalloc is recommended for allocating buffer.

Atlas inference products

When using VENC, the following two types of APIs for buffer allocation/freeing are supported:

  • Call aclrtMalloc to allocate the input buffer on the device, and aclrtFree to free the input buffer. 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 is preferred.
  • Call hi_mpi_dvpp_malloc to allocate the input buffer on the device, and hi_mpi_dvpp_free to free the input buffer. The buffer lifetime is managed by the user.

When using VENC, if non-input image data (such as the QpMap table information) is stored, only hi_mpi_dvpp_malloc and hi_mpi_dvpp_free can be called to allocate and free the input buffer on the device, respectively. The lifecycle of the buffer is managed by the user.

Note: hi_mpi_dvpp_malloc allocates a dedicated buffer for processing media data. However, the address space of the dedicated buffer is limited. If buffer resources are limited, aclrtMalloc is recommended for allocating buffer.

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 stream/image formats, width and height alignment, and buffers

Model

Input Image Format

Input Width and Height Alignment

Input Width Stride, Height Stride, and Buffer Size

Output Stream Format

Atlas 200I/500 A2 inference products

Atlas inference products

YUV420SP NV12 8-bit

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

  • H.264 Baseline Profile (BP), Main Profile (MP), or High Profile (HP)
  • H.265 MP (slice streams only)