---
title: Init
description: "初始化GPU加速实例。"
url: https://www.hikunpeng.com/document/detail/zh/kunpengboostkithistory/2530/armnative/kunpengcpsvideo_16_0087.html
sourcePath: /source/zh/kunpengboostkithistory/2530/armnative/kunpengcpsvideo_16_0087.html
indexId: f65b8e30ab274089e26679ccf07006f7859069d0fd0fe4f7fd1faf614103d7c377
---
# Init

#### 函数功能

初始化GPU加速实例。


#### 函数原型

int32_t Init(EncoderConfig &config) = 0


#### 参数说明

| 字段名称 | 输入/输出 | 字段类型 | 字段描述 |
| --- | --- | --- | --- |
| config | 输入 | EncoderConfig & | EncoderConfig结构体引用类型，GPU编码配置项。 |


EncoderConfig结构体和相关枚举定义如下：

```
enum EncoderCapability : uint32_t {
    CAP_NONE,
    CAP_FORMAT_CONVERT,
    CAP_VA_ENCODE_H264,
    CAP_VA_ENCODE_HEVC,
    CAP_MAX,
};
```

```
enum DeviceNode : uint32_t {
    DEV_DRI_RENDERD128 = 128,
    DEV_DRI_RENDERD129 = 129,
    DEV_DRI_RENDERD130 = 130,
    DEV_DRI_RENDERD131 = 131,
    DEV_DRI_OTHER = 132
};
struct FrameSize {
    uint32_t width = 0;
    uint32_t height = 0;
    uint32_t widthAligned = 0;
    uint32_t heightAligned = 0;
    bool operator==(const FrameSize &other)
    {
        return this->width == other.width &&
               this->height == other.height &&
               this->widthAligned == other.widthAligned &&
               this->heightAligned == other.heightAligned;
    }
    bool operator!=(const FrameSize &other)
    {
        return this->width != other.width ||
               this->height != other.height ||
               this->widthAligned != other.widthAligned ||
               this->heightAligned != other.heightAligned;
    }
};
```

```
struct EncoderConfig {
    EncoderCapability capability = CAP_NONE; 
    DeviceNode deviceNode = DEV_DRI_OTHER;
    FrameSize inSize = {};
    FrameSize outSize = {};
};
```


#### 返回值说明

数据类型：GpuEncoderErrorCode

取值如下：

- OK：初始化GPU加速实例成功。
- 其他：初始化GPU加速实例失败。
