hi_mpi_venc_set_chn_attr

Applicability

Product

Supported

Atlas 350 Accelerator Card

Atlas A3 training product/Atlas A3 inference product

Atlas A2 training product/Atlas A2 inference product

Atlas 200I/500 A2 inference product

Atlas inference product

Atlas training product

Function Description

Set the attributes of an encoding channel.

Prototype

hi_s32 hi_mpi_venc_set_chn_attr(hi_venc_chn chn, const hi_venc_chn_attr *chn_attr)

Parameters

Parameter

Input/Output

Description

chn

Input

Encoding channel ID.

Atlas 200I/500 A2 inference product: The value range of this parameter is [0, 128). The JPEGE, and VENC functions share the same channels, and the maximum number of channels is 128.

For the Atlas inference product, the value range of the encoding channel ID is [0, 256). The JPEGE and VENC functions share channels. The maximum number of channels is 256.

chn_attr

Input

Pointer to the encoding channel attributes.

Returns

Restrictions

  • Only H.264/H.265 encoding channels support this API.
  • Before calling this MPI, you are advised to call hi_mpi_venc_get_chn_attr to obtain the current channel attributes.
  • Encoding channel attributes include the encoder attribute, frame structure GOP attribute, and RC attribute. These attributes are classified into dynamic attributes and static attributes. Static attributes are configured when a channel is created and cannot be modified after the channel is created. Dynamic attributes are configured when a channel is created and some settings cannot be modified, and others can be modified modified before the channel is destroyed. Error codes are returned if you set static attributes or modify parameters that cannot be modified. For details about static attributes, whether attributes can be modified, and attribute value ranges, see hi_venc_chn_attr.
  • If gop_mode is not changed when configuring encoding channel attributes, the channel attributes take effect immediately. If gop_mode is changed, the channel attributes will take effect after a delay. The following table lists the maximum delays (the HI_VENC_GOP_MODE_LOW_DELAY_B mode is not supported currently).

    Before gop_mode Is Changed

    After gop_mode Is Changed

    Maximum Delay Time (by encoded frame count)

    HI_VENC_GOP_MODE_LOW_DELAY_B

    Non-HI_VENC_GOP_MODE_LOW_DELAY_B

    1+b_frame_num

    Non-HI_VENC_GOP_MODE_LOW_DELAY_B

    Any GOP mode different from that before the change.

    1

  • When changing gop_mode, the I-slice refreshing for P-frames, frame skipping reference attributes (H.264/H.265), and pic_order_cnt_type (H.264) of the channel are restored to the default values. You need to re-configure them for further use.
  • If either the GOP or RC attribute is modified, the RC module is reinitialized, and all advanced RC parameters are restored to default values. If the advanced parameters of the RC are adjusted in the client program, you need to reconfigure them. For details about the advanced RC parameters, see hi_mpi_venc_set_rc_param.
  • If gop_mode and rc_mode are modified at the same time, the modification takes effect after a delay (see the preceding table). To prevent the RC parameter value obtained by calling hi_mpi_venc_get_rc_param from being incorrect, you are advised to perform the corresponding operation after the delay parameter takes effect.
  • By calling this API, you can change the channel width (pic_width) and height (pic_height) during video encoding. However, you need to note the following:
    • When you change the width and height by calling this API, the system discards the video data that is not completely encoded. As a result, part of the video data is lost.
    • After this API is called to change the width and height, the values of width and height delivered by hi_mpi_venc_send_frame must be the same as the values of pic_width and pic_height.
    • If the width and height are changed between hi_mpi_venc_get_stream and hi_mpi_venc_release_stream, the HI_ERR_VENC_ILLEGAL_PARAM error code is returned when the hi_mpi_venc_release_stream interface releases the received stream.