hi_venc_attr

Description

Defines the VENC encoder attributes.

Prototype

typedef struct {
    hi_payload_type type;
    hi_u32 max_pic_width;
    hi_u32 max_pic_height;
    hi_u32 buf_size;
    hi_u32 profile;
    hi_bool is_by_frame;
    hi_u32 pic_width;
    hi_u32 pic_height;
    union {
        hi_venc_h264_attr h264_attr; 
        hi_venc_h265_attr h265_attr; 
        hi_venc_jpeg_attr jpeg_attr; 
        hi_venc_prores_attr prores_attr; 
    };
}hi_venc_attr;

Members

Member

Description

type

Encode protocol type.

max_pic_width

Maximum width of the source image. Must be an integral multiple of 2. This is a static attribute.

Value range: [MIN_WIDTH, MAX_WIDTH] MIN_WIDTH and MAX_WIDTH indicate the minimum width and maximum width supported by an encoding channel, respectively. For details, see Table 1.

max_pic_height

Maximum height of the source image. Must be an integral multiple of 2. This is a static attribute and does not apply to JPEG encoding.

Value range: [MIN_HEIGHT, MAX_HEIGHT], in pixels. MIN_HEIGHT and MAX_HEIGHT indicate the minimum height and maximum height supported by an encoding channel, respectively. For details, see Table 1.

buf_size

Size of the stream buffer, in bytes. This is a static attribute.
  • When the hi_mpi_venc_send_jpege_frame interface is called to send original images for encoding, buf_size must be set to 0 during channel creation.
  • When the hi_mpi_venc_send_frame interface is called to send original images for video or image encoding, the value of buf_size must be an integral multiple of 64 during channel creation. The value range is as follows: [Min, Max], in bytes.

    (1) In video encoding scenarios, Min indicates 32 x 1024, and Max indicates 1 x 1024 x 1024 x 1024.

    When creating a channel, you can set buf_size of each channel to an appropriate value to reduce the memory usage overhead. You are advised to set buf_size to the result of (Original image width x Original image height x 3) /2 and then 64-byte aligned. However, the value of buf_size must be within the range of [Min, Max].

    In video encoding scenarios, if buf_size is set improperly, the following exceptions may occur:

    - Repeated re-encoding prolongs the encoding delay, deteriorates the performance, and deteriorates the image quality.

    - Encoding failed. The encoding result cannot be obtained.

    (2) In image encoding scenarios: Min (YUV420)=Source width 16-aligned x Source height 16-aligned x 3/2; Min (YUV422 Packed)=Source width 16-aligned x Source height 16-aligned x 2. Max = 1 x 1024 x 1024 x 1024.

    When creating a channel, you can set buf_size of each channel based on the actual maximum image resolution in the service scenario to reduce the memory overhead. The recommended value is Original image width x Original image height x Multiple. The recommended multiple is 5.

    For example, if the resolutions of user images are 720p (1280 x 720), 1080p (1080 x 1920), and 4K (3840 x 2160), the required buf_size is calculated as follows: 3840 x 2160 x 5.

    In the image encoding scenario, the minimum value of buf_size is 320 x 240 x 5. This prevents the buffer from being fully occupied in the small resolution scenario, which affects the encoding function. For example: The maximum resolution of a user picture is 128 x 128. You are advised to set buf_size to 320 x 240 x 5.

profile

Encoding profile. A larger value indicates better encoding quality. This is a static attribute.

  • H.264:
    • 0: Baseline. If this value is used, B-frame encoding is not supported.
    • 1: main profile.
    • 2: High Profile.
  • H.265:
    • 0: Main Profile.
    • 1 (reserved): Main 10 Profile.
    • 4: Main 12 Profile.
  • JPEG: 0 indicates Baseline.

is_by_frame

Stream obtaining in frame or packet mode. This is a static attribute.

  • HI_TRUE: frame mode.
  • HI_FALSE: packet mode.

pic_width

Encoding channel width, which must be an integral multiple of MIN_ALIGN. After a channel is created, the VENC channel width can be changed, but the JPEGE channel width cannot be changed.

Value range: [MIN_WIDTH, max_pic_width], in pixels. MIN_WIDTH, max_pic_width, and MIN_ALIGN indicate the minimum width of an encoding channel, and the maximum width and minimum alignment (in pixels) of the image to be encoded, respectively. For details, see Table 1.

For JPEG encoding, the channel width and height must meet the following condition: pic_width x pic_height ≤ max_pic_width x max_pic_height.

pic_height

Encoding channel height, which must be an integral multiple of MIN_ALIGN. Not applicable to JPEG encoding. After a channel is created, the VENC channel height can be changed, but the JPEGE channel height cannot be changed.

Value range: [MIN_HEIGHT, max_pic_height], in pixels. MIN_HEIGHT, max_pic_height, and MIN_ALIGN indicate the minimum height of an encoding channel, and the maximum height and minimum alignment (in pixels) of the image to be encoded, respectively. For details, see Table 1.

For JPEG encoding, the channel width and height must meet the following condition: pic_width x pic_height ≤ max_pic_width x max_pic_height.

h264_attr

Attributes of the encoding protocol.

Atlas 350 Accelerator Card does not support this parameter.

For the Atlas A3 training product/Atlas A3 inference product, this parameter is not supported.

For the Atlas A2 training product/Atlas A2 inference product, this parameter is not supported.

Atlas inference product: This parameter is reserved and is not supported currently.

h265_attr

Attributes of the encoding protocol.

Atlas 350 Accelerator Card does not support this parameter.

For the Atlas A3 training product/Atlas A3 inference product, this parameter is not supported.

For the Atlas A2 training product/Atlas A2 inference product, this parameter is not supported.

Atlas inference product: This parameter is reserved and is not supported currently.

jpeg_attr

Attributes of the encode protocol.

Reserved.

prores_attr

Attributes of the encode protocol.

Reserved.

See Also

MIN_WIDTH, MAX_WIDTH, MIN_HEIGHT, MAX_HEIGHT, and MIN_ALIGN indicate the minimum width, maximum width, minimum height, maximum height, and minimum alignment (in pixels) of an encoding channel, respectively.

Table 1 Encoding channel width and height

W/H (pixel)

H.264

H.265

JPEG

MIN_WIDTH

128

128

32

MAX_WIDTH

4096

4096

8192

MIN_HEIGHT

128

128

32

MAX_HEIGHT

4096

4096

8192

MIN_ALIGN

2

2

2