VENC Functions and Restrictions

Function

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 × 2304.

Atlas 200I/500 A2 inference products

114 × 114 to 8192 × 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

During VENC video encoding, you can call the hi_mpi_dvpp_malloc or hi_mpi_dvpp_free API to allocate or free 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 users. The output buffer is managed by the system.

For the following product models, you can call the aclrtMalloc or aclrtFree API to allocate or free the input buffer on the device. The lifetime of the buffer is managed by users.

Atlas 200I/500 A2 inference products

Atlas inference products

hi_mpi_dvpp_malloc allocates a dedicated buffer for processing media data. However, the address space of the dedicated buffer is limited. If buffer planning is considered or buffer resources are limited, you are advised to allocate a buffer by calling aclrtMalloc. When calling aclrtMalloc to allocate a buffer, you are advised to allocate the buffer of the ACL_MEM_MALLOC_HUGE_FIRST type. Huge page buffer has better performance and is preferred.

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

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 Basic Concepts.

Table 1 Restrictions on image formats, width and height alignment, and buffers

Input Image Format

Input Width and Height Alignment

Input Width Stride, Height Stride, and Buffer Size

Output Stream Format

YUV420SP NV12 8-bit

YUV420SP NV21 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.

The start address of the buffer must be 16-byte aligned.

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

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