hi_venc_attr

Description

Defines the VENC attributes.

Prototype

hi_venc_attr = {"type": hi_payload_type,
                "max_pic_width": max_pic_width,
                "max_pic_height": max_pic_height,
                "buf_size": buf_size,
                "profile": profile,
                "is_by_frame": is_by_frame,
                "pic_width": pic_width,
                "pic_height": pic_height, 
                "h264_attr":hi_venc_h264_attr} # attributes of H264e

hi_venc_attr = {"type": type,
                "max_pic_width": max_pic_width,
                "max_pic_height": max_pic_height,
                "buf_size": buf_size,
                "profile": profile,
                "is_by_frame": is_by_frame,
                "pic_width": pic_width,
                "pic_height": pic_height,
                "h265_attr":hi_venc_h265_attr} # attributes of H265e

hi_venc_attr = {"type": hi_payload_type,
                "max_pic_width": max_pic_width,
                "max_pic_height": max_pic_height,
                "buf_size": buf_size,
                "profile": profile,
                "is_by_frame": is_by_frame,
                "pic_width": pic_width,
                "pic_height": pic_height,
                "jpeg_attr":hi_venc_jpeg_attr} # attributes of jpeg

hi_venc_attr = {"type": hi_payload_type,
                "max_pic_width": max_pic_width,
                "max_pic_height": max_pic_height,
                "buf_size": buf_size,
                "profile": profile,
                "is_by_frame": is_by_frame,
                "pic_width": pic_width,
                "pic_height": pic_height,
                "prores_attr":hi_venc_prores_attr} # attributes of prores

Members

Member

Description

type

Int, encoding protocol type.

max_pic_width

Int, maximum width of the source image. Must be a multiple of 2. This is a static attribute.

Value range: [MIN_WIDTH, MAX_WIDTH], in pixels. 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

Int, maximum height of the source image. Must be a 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

Int, size of the stream buffer, in bytes. This is a static attribute.

  • When acl.himpi.venc_send_jpege_frame is called to send source images for encoding, buf_size must be set to 0 during channel creation.
  • When acl.himpi.venc_send_frame is called to send source images for video or image encoding, buf_size must be set to an integral multiple of 64 within the range [Min, Max] during channel creation. The unit is byte.
    • In video encoding scenarios, Min indicates 32 x 1024, and Max indicates 1 x 1024 x 1024 x 1024.

      When creating a channel, set buf_size properly to reduce the buffer overhead. You are advised to set buf_size to: source width x source height x 3/2, rounded up to the nearest multiple of 64 (64-aligned). Ensure that buf_size is 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, degrades the performance, and deteriorates the image quality.
      • Encoding failure: fails to obtain the encoding result.
    • 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, set buf_size properly based on the largest image resolution in an actual service scenario to reduce the buffer overhead. You are advised to set buf_size to : source width x source height x multiple (5 is recommended).

      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 image encoding scenarios, the minimum value of buf_size is 320 x 240 x 5. This prevents the buffer from being completely occupied, which affects the encoding functionality when low-resolution (128 x 128 or less, for example) user images are input.

profile

Int, encoding profile. This is a static attribute.

  • For H.264, the value range is [0, 3].
    • 0: baseline. When this value is used, B-frame encoding is not supported.
    • 1: main profile.
    • 2: high profile.
  • For H.265, the value range is [0, 1].
    • 0: main profile.
    • 1 (reserved): main 10 profile.
  • Value range for JPEG:
    • 0 (baseline).

is_by_frame

Int, 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, it cannot be modified.

Value range: [MIN_WIDTH, MAX_WIDTH], in pixels. MIN_WIDTH, MAX_WIDTH, and MIN_ALIGN indicate the minimum width, maximum width, and minimum alignment (in pixels) of an encoding channel, receptively. 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, it cannot be modified.

Value range: [MIN_HEIGHT, MAX_HEIGHT], in pixels. MIN_HEIGHT, MAX_HEIGHT, and MIN_ALIGN indicate the minimum height, maximum height, and minimum alignment (in pixels) of an encoding channel, receptively. 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 coding protocol.

h265_attr

Attributes of the coding protocol.

jpeg_attr

Attributes of the coding protocol.

Reserved.

prores_attr

Attributes of the coding protocol.

Reserved.

References

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, receptively.

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