venc_create_chn

Applicable Products

Product

Supported

Ascend 950PR / Ascend 950DT

√

Atlas A3 training products / Atlas A3 inference products

√

Atlas A2 training products / Atlas A2 inference products

√

Atlas training products

x

Atlas inference products

√

Atlas 200I/500 A2 inference products

√

Description

Creates an encoding channel.

Prototype

  • C Prototype
    1
    hi_s32 hi_mpi_venc_create_chn(hi_venc_chn chn, const hi_venc_chn_attr *attr)
    
  • Python Function
    1
    ret = acl.himpi.venc_create_chn(chn, attr)
    

Parameters

Parameter

Description

chn

Int, decoding channel ID.

  • Ascend 950PR / Ascend 950DT : The value range of this parameter is [0, 256). The maximum number of channels is 256 for the JPEGD function.
  • Atlas inference products : The value range of this parameter is [0, 256). The JPEGD and VDEC functions share the same channels, and the maximum number of channels is 256.
  • Atlas A2 training products / Atlas A2 inference products : The value range of this parameter is [0, 256). The JPEGD and VDEC functions share the same channels, and the maximum number of channels is 256. Among them, a maximum of 256 JPEGD decoding channels and 32 VDEC decoding channels are supported.
  • Atlas 200I/500 A2 inference products : The value range of this parameter is [0, 128). The JPEGD and VDEC functions share the same channels, and the maximum number of channels is 128.
  • Atlas A3 training products / Atlas A3 inference products : The value range of this parameter is [0, 256). The JPEGD and VDEC functions share the same channels, and the maximum number of channels is 256. Among them, a maximum of 256 JPEGD decoding channels and 32 VDEC decoding channels are supported.
NOTE:

For Ascend virtual instances on Atlas inference products , total number of VENC and JPEGE channels = (Total number of allocated VENC and JPEGE hardware units/Total number of VENC and JPEGE hardware units) x 256. If the total number of channels is not an integer, round down the value.

For Ascend virtual instances on Atlas A2 training products / Atlas A2 inference products , the maximum number of JPEGE channels is 256.

For Ascend virtual instances on Atlas 200I/500 A2 inference products , the number of VENC channels is calculated as follows: Number of VENC channels = (Allocated VENC hardware units/Total VENC hardware units) x 128. If the total number of channels is not an integer, round down the value. The number of JPEGE channels is independent of the computing power, but the maximum number of JPEGE and VENC channels is 128.

To view the compute specifications of Ascend virtual instances in different use cases, run npu-smi info -t template-info on the server where the AI processor is installed.

attr

Dict, dictionary of the encoding channel attributes. For details, see hi_venc_chn_attr.

Return Value

Return Value

Description

ret

Int, error code.

Restrictions

  • The channel ID of a single device must not be greater than the maximum channel ID.
  • An encoding channel has the encoder attributes, rate controller (RC) attributes, and group of pictures (GOP) attributes.
  • In the encoder attributes, the stream buffer depth, stream fetching mode, and encoding profile must be set according to Table 1.
  • The recommended encoding sizes are 3840 x 2160 (4K), 1920 x 1080 (1080p), and 1280 x 720 (720p).
  • For H.264/H.265 encoding, a frame buffer consists of YHeaderSize, CHeaderSize, YSize, CSize, PmeSize, PmeInfoSize, and TmvSize. The encoder calculates the buffer allocation based on the maximum width and height by default. When configuring the channel width and height, ensure that each frame buffer calculated based on the channel width and height does not exceed that calculated based on the maximum channel width and height.
  • The input/output frame rate (src_frame_rate/dst_frame_rate) in the attributes of the RC is used to allocate the bitrate (bit_rate) during encoding, but not the final display frame rate of the player. For details about how to set the display frame rate, see acl.himpi.venc_set_h264_vui or acl.himpi.venc_set_h265_vui.

    You are advised to set the control frame rate to be the same as the display frame rate. Otherwise, the bit rate during playback may be different from the encoding bit rate configured by the user, and the playback bit rate will vary with the configured display frame rate.

Reference

For the API call sequence, see JPEGE and VENC.

References

Table 1 Restrictions on encoder attributes

Encoding Protocol

Encode Mode

Stream Buffer Depth

Stream Fetching Mode

Encode Profile

H.264

Frame

  • When mini_buf_mode = 0: Buffer allocation ≥ max_pic_width x max_pic_height x 3/4
  • When mini_buf_mode = 1: Buffer allocation ≥ 32 x 1024 bytes

Frame/Slice

Baseline

Mainprofile

Highprofile

JPEG

Frame

  • If mini_buf_mode is set to 0 and the original image format is YUV420, the minimum buffer size is calculated as follows: Minimum buffer size = 16-aligned original image width x 16-aligned original image height x 3/2. If the original image format is YUV422 packed, the minimum buffer size is calculated as follows: Minimum buffer size = 16-aligned width of the original image x 16-aligned height of the source image x 2
  • When mini_buf_mode = 1: Buffer allocation ≥ 32 x 1024 bytes

Frame/Ecs

Baseline

H.265

Frame

  • When mini_buf_mode = 0: Buffer allocation ≥ max_pic_width x max_pic_height x 3/4
  • When mini_buf_mode = 1: Buffer allocation ≥ 32 x 1024 bytes

Frame/Slice

Main profile

Main 10 profile (not supported currently)

  • When mini_buf_mode = 0: Buffer allocation ≥ max_pic_width x max_pic_height x (3/4) x (5/4)
  • When mini_buf_mode = 1: Buffer allocation ≥ 32 x 1024 bytes

Frame/Slice

Main 10 Profile (not supported currently)