我要评分
获取效率
正确性
完整性
易理解

CreateBuffer

Function Usage

Creates a buffer.

Restrictions

N/A

Prototype

int32_t CreateBuffer(FrameFormat format, MemType type, GpuEncoderBufferT &buffer) = 0

Parameters

Field Name

Input/Output

Field Type

Description

format

Input

FrameFormat

Format of the buffer to be created.

FrameFormat is defined as follows:

enum FrameFormat : uint32_t {
    FRAME_FORMAT_NONE,
    FRAME_FORMAT_RGBA,
    FRAME_FORMAT_BGRA,
    FRAME_FORMAT_YUV,
    FRAME_FORMAT_NV12,
    FRAME_FORMAT_H264,
    FRAME_FORMAT_HEVC,
    FRAME_FORMAT_COUNT
};

Field Name

Input/Output

Field Type

Description

type

Input

MemType

Location of the space to be allocated to the buffer.

MemType is defined as follows:

enum MemType : uint32_t {
    MEM_TYPE_NONE,
    MEM_TYPE_HOST, // Allocates in the host memory.
    MEM_TYPE_DEVICE, // Allocates in the device memory.
    MEM_TYPE_COUNT
};

Field Name

Input/Output

Field Type

Description

buffer

Output

GpuEncoderBufferT &

Pointer used to mount the buffer after allocation.

The definition of GpuEncoderBufferT is as follows. When implementing this interface, developers or vendors need to use new to allocate memory for GpuEncoderBuffer and release the memory in the ReleaseBuffer interface.

struct GpuEncoderBuffer {
    FrameFormat format = FRAME_FORMAT_NONE;
    MemType memType = MEM_TYPE_NONE;
    FrameSize size = {};
    GpuType gpuType = GPU_NONE;
    uint8_t *data  = nullptr;
    uint32_t dataLen = 0;
};
using GpuEncoderBufferT = GpuEncoderBuffer *;

Returns

Data type: GpuEncoderErrorCode

The value can be:

  • OK: The buffer is successfully created.
  • Other values except OK: The buffer fails to be created.