Updated on 2022-03-13 GMT+08:00

CreateVenc

Syntax

int32_t CreateVenc(struct VencConfig* vencConfig)

Function

Obtains the VENC instance, which is equivalent to obtaining the handle of the VENC executor. The caller can call RunVenc to encode images by using the obtained VENC instance.

Input

Pointer to the VencConfig structure. For details about the VencConfig structure, see Input parameter: VencConfig. You need to configure a callback function to process the encoding result.

Output

None

Return Value

  • If the return value is a non-negative number, a VENC instance is successfully created.
  • The return value –1 indicates that a VENC instance fails to be created.

Instructions

The caller creates the VencConfig object pointer. The VencConfig object pointer is passed by calling the CreateVenc function. If the application is successful, CreateVenc returns the handle to the VENC instance. Otherwise, –1 is returned. The caller needs to verify the return value.

Restriction

The caller is responsible for the life cycle of the VENC instance, including the application and release, which are implemented by using CreateVenc and DestroyVenc, respectively.

Input parameter: VencConfig

This input parameter is used when the VENC module is initialized. All member variables of the data structure must be initialized before being used.

Table 1 Input parameter VencConfig

Member Variable

Description

Value Range

uint32_t width

Image width

The value is an even number ranging from 128 to 1920.

uint32_t height

Image height

The value is an even number ranging from 128 to 1920.

uint32_t codingType

Video encoding protocols

0–3

  • 0: H.265 Main Profile Level (Only slice streams are supported.)
  • 1: H.264 Baseline Profile Level
  • 2: H.264 Main Profile Level
  • 3: H.264 High Profile Level

uint32_t yuvStoreType

YUV image storage format

The value is 0 or 1.

  • 0: YUV420 semi-planar (NV12)
  • 1: YVU420 semi-planar (NV21)

uint32_t keyFrameInterval

I-frame interval

The value range is (0, 65535).

VencOutMsgCallBack vencOutMsgCallBack

Callback function, which is used to process the encoding result.

When encoding each channel of image data, DVPP (the VENC module) calls the callback function twice for the first frame of image data. The first call is used to process the file header information, and the second call is used to process the image data of the current frame.

typedef void (*VencOutMsgCallBack)(struct VencOutMsg* vencOutMsg, void* userData). The value cannot be null.

void* userData

The user records the information to be passed. The data is returned to the user in the callback function.

The value can be NULL.