Rate This Document
Findability
Accuracy
Completeness
Readability

CreateBuffer

Function Usage

Creates a buffer.

Prototype

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

Parameter Description

Field Name

Input/Output

Field Type

Description

format

Input

FrameFormat

Format of the buffer to be created.

Enumeration of FrameFormat:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
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 space to be allocated to the buffer.

Enumeration of MemType:

1
2
3
4
5
6
enum MemType : uint32_t {
    MEM_TYPE_NONE,
    MEM_TYPE_HOST, // Host memory
    MEM_TYPE_DEVICE, // 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 API, developers or the vendor need to use new to allocate memory for GpuEncoderBuffer and release the memory in the ReleaseBuffer API.

1
2
3
4
5
6
7
8
9
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 *;

Return Value Description

Data type: GpuEncoderErrorCode

The value can be any of the following:

  • OK: The buffer is successfully created.
  • Other: Failed to create a buffer.