mirror of
https://github.com/Tryanks/go-rkcodec.git
synced 2025-10-05 16:16:57 +08:00
more impl
This commit is contained in:
57
README.md
57
README.md
@@ -1,3 +1,58 @@
|
||||
# Go rkcodec
|
||||
|
||||
TODO...
|
||||
A cgo package for [rkmpp](https://github.com/rockchip-linux/mpp) media library.
|
||||
|
||||
Need **rkmpp** enviorment.
|
||||
|
||||
```shell
|
||||
pkg-config --cflags rockchip_mpp
|
||||
```
|
||||
|
||||
# Usage
|
||||
|
||||
## Install
|
||||
```shell
|
||||
go get -u github.com/Tryanks/go-rkcodec
|
||||
```
|
||||
|
||||
## Code
|
||||
```go
|
||||
package main
|
||||
|
||||
import "C"
|
||||
import "rkcodec"
|
||||
|
||||
func main() {
|
||||
decoder := rkcodec.NewMppCodec()
|
||||
decoder.Control(rkcodec.MppDecSetParserSplitMode, C.int(1))
|
||||
decoder.Init(rkcodec.MppCtxDec, rkcodec.MppCodingAVC)
|
||||
|
||||
frame, err := rkcodec.MppFrameInit()
|
||||
if err != rkcodec.MppSuccess {
|
||||
panic(err)
|
||||
}
|
||||
defer frame.Deinit()
|
||||
|
||||
packet, err := rkcodec.NewMppPacket()
|
||||
if err != rkcodec.MppSuccess {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
h264NALU := make([]byte, 1024) // H.264 NALU data
|
||||
|
||||
packet.SetData(h264NALU)
|
||||
|
||||
err = decoder.DecodePutPacket(*packet)
|
||||
if err != rkcodec.MppSuccess {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
err = decoder.DecodeGetFrame(frame)
|
||||
if err != rkcodec.MppSuccess {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
// Do something with the frame
|
||||
}
|
||||
|
||||
```
|
41
buffer.go
Normal file
41
buffer.go
Normal file
@@ -0,0 +1,41 @@
|
||||
package rkcodec
|
||||
|
||||
//#include <rockchip/mpp_buffer.h>
|
||||
import "C"
|
||||
|
||||
type MppBufferMode = C.int
|
||||
|
||||
const (
|
||||
MppBufferInternal = MppBufferMode(C.MPP_BUFFER_INTERNAL)
|
||||
MppBufferExternal = MppBufferMode(C.MPP_BUFFER_EXTERNAL)
|
||||
MppBufferModeButt = MppBufferMode(C.MPP_BUFFER_MODE_BUTT)
|
||||
)
|
||||
|
||||
type MppBufferType = C.int
|
||||
|
||||
const (
|
||||
MppBufferTypeNormal = MppBufferType(C.MPP_BUFFER_TYPE_NORMAL)
|
||||
MppBufferTypeIon = MppBufferType(C.MPP_BUFFER_TYPE_ION)
|
||||
MppBufferTypeExtDma = MppBufferType(C.MPP_BUFFER_TYPE_EXT_DMA)
|
||||
MppBufferTypeDrm = MppBufferType(C.MPP_BUFFER_TYPE_DRM)
|
||||
MppBufferTypeDmaHeap = MppBufferType(C.MPP_BUFFER_TYPE_DMA_HEAP)
|
||||
MppBufferTypeButt = MppBufferType(C.MPP_BUFFER_TYPE_BUTT)
|
||||
)
|
||||
|
||||
const MppBufferTypeMask = C.MPP_BUFFER_TYPE_MASK
|
||||
|
||||
const MppBufferFlagsMask = C.MPP_BUFFER_FLAGS_MASK // ROCKCHIP_BO_MASK << 16
|
||||
const MppBufferFlagsContig = C.MPP_BUFFER_FLAGS_CONTIG // ROCKCHIP_BO_CONTIG << 16
|
||||
const MppBufferFlagsCachable = C.MPP_BUFFER_FLAGS_CACHABLE // ROCKCHIP_BO_CACHABLE << 16
|
||||
const MppBufferFlagsWC = C.MPP_BUFFER_FLAGS_WC // ROCKCHIP_BO_WC << 16
|
||||
const MppBufferFlagsSecure = C.MPP_BUFFER_FLAGS_SECURE // ROCKCHIP_BO_SECURE << 16
|
||||
const MppBufferFlagsAllocKmap = C.MPP_BUFFER_FLAGS_ALLOC_KMAP // ROCKCHIP_BO_ALLOC_KMAP << 16
|
||||
const MppBufferFlagsDMA32 = C.MPP_BUFFER_FLAGS_DMA32 // ROCKCHIP_BO_DMA32 << 16
|
||||
|
||||
type MppBufferInfo struct {
|
||||
c *C.struct_MppBufferInfo
|
||||
}
|
||||
|
||||
// const BufferGroupSizeDefault = BUFFER_GROUP_SIZE_DEFAULT // TODO: not found
|
||||
|
||||
// TODO: all function port
|
4
cgo.go
Normal file
4
cgo.go
Normal file
@@ -0,0 +1,4 @@
|
||||
package rkcodec
|
||||
|
||||
//#cgo pkg-config: rockchip_mpp
|
||||
import "C"
|
97
codec.h
Normal file
97
codec.h
Normal file
@@ -0,0 +1,97 @@
|
||||
#ifndef __CODEC_H__
|
||||
#define __CODEC_H__
|
||||
|
||||
#include <rockchip/rk_mpi.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
typedef struct MppCodec {
|
||||
MppCtx ctx;
|
||||
MppApi *api;
|
||||
} MppCodec;
|
||||
|
||||
static inline MppCodec *mpp_ctx_api_alloc() {
|
||||
MppCtx ctx = NULL;
|
||||
MppApi *mpi = NULL;
|
||||
mpp_create(&ctx, &mpi);
|
||||
MppCodec *codec;
|
||||
codec = (MppCodec *)malloc(sizeof(MppCodec));
|
||||
codec->ctx = ctx;
|
||||
codec->api = mpi;
|
||||
return codec;
|
||||
}
|
||||
|
||||
static inline MPP_RET codec_init(MppCodec *codec, MppCtxType type, MppCodingType coding) {
|
||||
return mpp_init(codec->ctx, type, coding);
|
||||
}
|
||||
|
||||
static inline MPP_RET codec_destroy(MppCodec *codec) {
|
||||
MPP_RET ret = mpp_destroy(codec->ctx);
|
||||
free(codec);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline RK_U32 codec_size(MppCodec *codec) {
|
||||
return codec->api->size;
|
||||
}
|
||||
|
||||
static inline RK_U32 codec_version(MppCodec *codec) {
|
||||
return codec->api->version;
|
||||
}
|
||||
|
||||
static inline MPP_RET codec_decode(MppCodec *codec, MppPacket packet, MppFrame *frame) {
|
||||
return codec->api->decode(codec->ctx, packet, frame);
|
||||
}
|
||||
|
||||
static inline MPP_RET codec_decode_put_packet(MppCodec *codec, MppPacket packet) {
|
||||
return codec->api->decode_put_packet(codec->ctx, packet);
|
||||
}
|
||||
|
||||
static inline MPP_RET codec_decode_get_frame(MppCodec *codec, MppFrame *frame) {
|
||||
return codec->api->decode_get_frame(codec->ctx, frame);
|
||||
}
|
||||
|
||||
static inline MPP_RET codec_encode(MppCodec *codec, MppFrame frame, MppPacket *packet) {
|
||||
return codec->api->encode(codec->ctx, frame, packet);
|
||||
}
|
||||
|
||||
static inline MPP_RET codec_encode_put_frame(MppCodec *codec, MppFrame frame) {
|
||||
return codec->api->encode_put_frame(codec->ctx, frame);
|
||||
}
|
||||
|
||||
static inline MPP_RET codec_encode_get_packet(MppCodec *codec, MppPacket *packet) {
|
||||
return codec->api->encode_get_packet(codec->ctx, packet);
|
||||
}
|
||||
|
||||
static inline MPP_RET codec_isp(MppCodec *codec, MppFrame dst, MppFrame src) {
|
||||
return codec->api->isp(codec->ctx, dst, src);
|
||||
}
|
||||
|
||||
static inline MPP_RET codec_isp_put_frame(MppCodec *codec, MppFrame frame) {
|
||||
return codec->api->isp_put_frame(codec->ctx, frame);
|
||||
}
|
||||
|
||||
static inline MPP_RET codec_isp_get_frame(MppCodec *codec, MppFrame *frame) {
|
||||
return codec->api->isp_get_frame(codec->ctx, frame);
|
||||
}
|
||||
|
||||
static inline MPP_RET codec_poll(MppCodec *codec, MppPortType type, MppPollType timeout) {
|
||||
return codec->api->poll(codec->ctx, type, timeout);
|
||||
}
|
||||
|
||||
static inline MPP_RET codec_dequeue(MppCodec *codec, MppPortType type, MppTask *task) {
|
||||
return codec->api->dequeue(codec->ctx, type, task);
|
||||
}
|
||||
|
||||
static inline MPP_RET codec_enqueue(MppCodec *codec, MppPortType type, MppTask task) {
|
||||
return codec->api->enqueue(codec->ctx, type, task);
|
||||
}
|
||||
|
||||
static inline MPP_RET codec_reset(MppCodec *codec) {
|
||||
return codec->api->reset(codec->ctx);
|
||||
}
|
||||
|
||||
static inline MPP_RET codec_control(MppCodec *codec, MpiCmd cmd, void* param) {
|
||||
return codec->api->control(codec->ctx, cmd, param);
|
||||
}
|
||||
|
||||
#endif /* __CODEC_H__ */
|
@@ -1,5 +0,0 @@
|
||||
这个文件夹放置了开发过程中的参考资料
|
||||
|
||||
## 文件叫列表释义
|
||||
|
||||
- `rockchip` rkmpp 的头文件
|
@@ -1,361 +0,0 @@
|
||||
/*
|
||||
* Copyright 2015 Rockchip Electronics Co. LTD
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __MPP_BUFFER_H__
|
||||
#define __MPP_BUFFER_H__
|
||||
|
||||
#include "rk_type.h"
|
||||
#include "mpp_err.h"
|
||||
|
||||
/*
|
||||
* MppBuffer module has several functions:
|
||||
*
|
||||
* 1. buffer get / put / reference management / external commit / get info.
|
||||
* this part is the basic user interface for MppBuffer.
|
||||
*
|
||||
* function:
|
||||
*
|
||||
* mpp_buffer_get
|
||||
* mpp_buffer_put
|
||||
* mpp_buffer_inc_ref
|
||||
* mpp_buffer_commit
|
||||
* mpp_buffer_info_get
|
||||
*
|
||||
* 2. user buffer working flow control abstraction.
|
||||
* buffer should attach to certain group, and buffer mode control the buffer usage flow.
|
||||
* this part is also a part of user interface.
|
||||
*
|
||||
* function:
|
||||
*
|
||||
* mpp_buffer_group_get
|
||||
* mpp_buffer_group_normal_get
|
||||
* mpp_buffer_group_limit_get
|
||||
* mpp_buffer_group_put
|
||||
* mpp_buffer_group_limit_config
|
||||
*
|
||||
* 3. buffer allocator management
|
||||
* this part is for allocator on different os, it does not have user interface
|
||||
* it will support normal buffer, Android ion buffer, Linux v4l2 vb2 buffer
|
||||
* user can only use MppBufferType to choose.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* mpp buffer group support two work flow mode:
|
||||
*
|
||||
* normal flow: all buffer are generated by MPP
|
||||
* under this mode, buffer pool is maintained internally
|
||||
*
|
||||
* typical call flow:
|
||||
*
|
||||
* mpp_buffer_group_get() return A
|
||||
* mpp_buffer_get(A) return a ref +1 -> used
|
||||
* mpp_buffer_inc_ref(a) ref +1
|
||||
* mpp_buffer_put(a) ref -1
|
||||
* mpp_buffer_put(a) ref -1 -> unused
|
||||
* mpp_buffer_group_put(A)
|
||||
*
|
||||
* commit flow: all buffer are commited out of MPP
|
||||
* under this mode, buffers is commit by external api.
|
||||
* normally MPP only use it but not generate it.
|
||||
*
|
||||
* typical call flow:
|
||||
*
|
||||
* ==== external allocator ====
|
||||
* mpp_buffer_group_get() return A
|
||||
* mpp_buffer_commit(A, x)
|
||||
* mpp_buffer_commit(A, y)
|
||||
*
|
||||
* ======= internal user ======
|
||||
* mpp_buffer_get(A) return a
|
||||
* mpp_buffer_get(A) return b
|
||||
* mpp_buffer_put(a)
|
||||
* mpp_buffer_put(b)
|
||||
*
|
||||
* ==== external allocator ====
|
||||
* mpp_buffer_group_put(A)
|
||||
*
|
||||
* NOTE: commit interface required group handle to record group information
|
||||
*/
|
||||
|
||||
/*
|
||||
* mpp buffer group has two buffer limit mode: normal and limit
|
||||
*
|
||||
* normal mode: allows any buffer size and always general new buffer is no unused buffer
|
||||
* is available.
|
||||
* This mode normally use with normal flow and is used for table / stream buffer
|
||||
*
|
||||
* limit mode : restrict the buffer's size and count in the buffer group. if try to calloc
|
||||
* buffer with different size or extra count it will fail.
|
||||
* This mode normally use with commit flow and is used for frame buffer
|
||||
*/
|
||||
|
||||
/*
|
||||
* NOTE: normal mode is recommanded to work with normal flow, working with limit mode is not.
|
||||
* limit mode is recommanded to work with commit flow, working with normal mode is not.
|
||||
*/
|
||||
typedef enum {
|
||||
MPP_BUFFER_INTERNAL,
|
||||
MPP_BUFFER_EXTERNAL,
|
||||
MPP_BUFFER_MODE_BUTT,
|
||||
} MppBufferMode;
|
||||
|
||||
/*
|
||||
* the mpp buffer has serval types:
|
||||
*
|
||||
* normal : normal malloc buffer for unit test or hardware simulation
|
||||
* ion : use ion device under Android/Linux, MppBuffer will encapsulte ion file handle
|
||||
* ext_dma : the DMABUF(DMA buffers) come from the application
|
||||
* drm : use the drm device interface for memory management
|
||||
*
|
||||
* MPP default allocator select priority for kernel above 5.10:
|
||||
* MPP_BUFFER_TYPE_DMA_HEAP > MPP_BUFFER_TYPE_DRM > MPP_BUFFER_TYPE_ION
|
||||
* MPP_BUFFER_TYPE_EXT_DMA is only used for general external dma_buf fd import.
|
||||
*/
|
||||
typedef enum {
|
||||
MPP_BUFFER_TYPE_NORMAL,
|
||||
MPP_BUFFER_TYPE_ION,
|
||||
MPP_BUFFER_TYPE_EXT_DMA,
|
||||
MPP_BUFFER_TYPE_DRM,
|
||||
MPP_BUFFER_TYPE_DMA_HEAP,
|
||||
MPP_BUFFER_TYPE_BUTT,
|
||||
} MppBufferType;
|
||||
|
||||
#define MPP_BUFFER_TYPE_MASK 0x0000FFFF
|
||||
|
||||
/*
|
||||
* MPP_BUFFER_FLAGS cooperate with MppBufferType
|
||||
* 16 high bits of MppBufferType are used in flags
|
||||
*
|
||||
* eg:
|
||||
* DMA_HEAP CMA buffer : MPP_BUFFER_TYPE_DMA_HEAP | MPP_BUFFER_FLAGS_CONTIG
|
||||
* = 0x00010004
|
||||
* DRM SECURE buffer : MPP_BUFFER_TYPE_DRM | MPP_BUFFER_FLAGS_SECURE
|
||||
* = 0x00080003
|
||||
*
|
||||
* The dma buffer source can also be set by format: flags | type.
|
||||
* dma buffer source flags:
|
||||
* MPP_BUFFER_FLAGS_CONTIG means cma
|
||||
* MPP_BUFFER_FLAGS_CACHABLE means cachable
|
||||
* MPP_BUFFER_FLAGS_DMA32 means dma32
|
||||
*
|
||||
* flags originate from drm_rockchip_gem_mem_type
|
||||
*/
|
||||
#define MPP_BUFFER_FLAGS_MASK 0x003f0000 //ROCKCHIP_BO_MASK << 16
|
||||
#define MPP_BUFFER_FLAGS_CONTIG 0x00010000 //ROCKCHIP_BO_CONTIG << 16
|
||||
#define MPP_BUFFER_FLAGS_CACHABLE 0x00020000 //ROCKCHIP_BO_CACHABLE << 16
|
||||
#define MPP_BUFFER_FLAGS_WC 0x00040000 //ROCKCHIP_BO_WC << 16
|
||||
#define MPP_BUFFER_FLAGS_SECURE 0x00080000 //ROCKCHIP_BO_SECURE << 16
|
||||
#define MPP_BUFFER_FLAGS_ALLOC_KMAP 0x00100000 //ROCKCHIP_BO_ALLOC_KMAP << 16
|
||||
#define MPP_BUFFER_FLAGS_DMA32 0x00200000 //ROCKCHIP_BO_DMA32 << 16
|
||||
|
||||
/*
|
||||
* MppBufferInfo variable's meaning is different in different MppBufferType
|
||||
*
|
||||
* Common
|
||||
* index - the buffer index used to track buffer in buffer pool
|
||||
* size - the buffer size
|
||||
*
|
||||
* MPP_BUFFER_TYPE_NORMAL
|
||||
*
|
||||
* ptr - virtual address of normal malloced buffer
|
||||
* fd - unused and set to -1, the allocator would return its
|
||||
* internal buffer counter number
|
||||
*
|
||||
* MPP_BUFFER_TYPE_ION
|
||||
*
|
||||
* ptr - virtual address of ion buffer in user space
|
||||
* hnd - ion handle in user space
|
||||
* fd - ion buffer file handle for map / unmap
|
||||
*
|
||||
*/
|
||||
typedef struct MppBufferInfo_t {
|
||||
MppBufferType type;
|
||||
size_t size;
|
||||
void *ptr;
|
||||
void *hnd;
|
||||
int fd;
|
||||
int index;
|
||||
} MppBufferInfo;
|
||||
|
||||
#define BUFFER_GROUP_SIZE_DEFAULT (SZ_1M*80)
|
||||
|
||||
/*
|
||||
* mpp_buffer_import_with_tag(MppBufferGroup group, MppBufferInfo *info, MppBuffer *buffer)
|
||||
*
|
||||
* 1. group - specified the MppBuffer to be attached to.
|
||||
* group can be NULL then this buffer will attached to default legecy group
|
||||
* Default to NULL on mpp_buffer_import case
|
||||
*
|
||||
* 2. info - input information for the output MppBuffer
|
||||
* info can NOT be NULL. It must contain at least one of ptr/fd.
|
||||
*
|
||||
* 3. buffer - generated MppBuffer from MppBufferInfo.
|
||||
* buffer can be NULL then the buffer is commit to group with unused status.
|
||||
* Otherwise generated buffer will be directly got and ref_count increased.
|
||||
* Default to NULL on mpp_buffer_commit case
|
||||
*
|
||||
* mpp_buffer_commit usage:
|
||||
*
|
||||
* Add a external buffer info to group. This buffer will be on unused status.
|
||||
* Typical usage is on Android. MediaPlayer gralloc Graphic buffer then commit these buffer
|
||||
* to decoder's buffer group. Then decoder will recycle these buffer and return buffer reference
|
||||
* to MediaPlayer for display.
|
||||
*
|
||||
* mpp_buffer_import usage:
|
||||
*
|
||||
* Transfer a external buffer info to MppBuffer but it is not expected to attached to certain
|
||||
* buffer group. So the group is set to NULL. Then this buffer can be used for MppFrame/MppPacket.
|
||||
* Typical usage is for image processing. Image processing normally will be a oneshot operation
|
||||
* It does not need complicated group management. But in other hand mpp still need to know the
|
||||
* imported buffer is leak or not and trace its usage inside mpp process. So we attach this kind
|
||||
* of buffer to default misc buffer group for management.
|
||||
*/
|
||||
#define mpp_buffer_commit(group, info) \
|
||||
mpp_buffer_import_with_tag(group, info, NULL, MODULE_TAG, __FUNCTION__)
|
||||
|
||||
#define mpp_buffer_import(buffer, info) \
|
||||
mpp_buffer_import_with_tag(NULL, info, buffer, MODULE_TAG, __FUNCTION__)
|
||||
|
||||
#define mpp_buffer_get(group, buffer, size) \
|
||||
mpp_buffer_get_with_tag(group, buffer, size, MODULE_TAG, __FUNCTION__)
|
||||
|
||||
#define mpp_buffer_put(buffer) \
|
||||
mpp_buffer_put_with_caller(buffer, __FUNCTION__)
|
||||
|
||||
#define mpp_buffer_inc_ref(buffer) \
|
||||
mpp_buffer_inc_ref_with_caller(buffer, __FUNCTION__)
|
||||
|
||||
#define mpp_buffer_info_get(buffer, info) \
|
||||
mpp_buffer_info_get_with_caller(buffer, info, __FUNCTION__)
|
||||
|
||||
#define mpp_buffer_read(buffer, offset, data, size) \
|
||||
mpp_buffer_read_with_caller(buffer, offset, data, size, __FUNCTION__)
|
||||
|
||||
#define mpp_buffer_write(buffer, offset, data, size) \
|
||||
mpp_buffer_write_with_caller(buffer, offset, data, size, __FUNCTION__)
|
||||
|
||||
#define mpp_buffer_get_ptr(buffer) \
|
||||
mpp_buffer_get_ptr_with_caller(buffer, __FUNCTION__)
|
||||
|
||||
#define mpp_buffer_get_fd(buffer) \
|
||||
mpp_buffer_get_fd_with_caller(buffer, __FUNCTION__)
|
||||
|
||||
#define mpp_buffer_get_size(buffer) \
|
||||
mpp_buffer_get_size_with_caller(buffer, __FUNCTION__)
|
||||
|
||||
#define mpp_buffer_get_index(buffer) \
|
||||
mpp_buffer_get_index_with_caller(buffer, __FUNCTION__)
|
||||
|
||||
#define mpp_buffer_set_index(buffer, index) \
|
||||
mpp_buffer_set_index_with_caller(buffer, index, __FUNCTION__)
|
||||
|
||||
#define mpp_buffer_get_offset(buffer) \
|
||||
mpp_buffer_get_offset_with_caller(buffer, __FUNCTION__)
|
||||
|
||||
#define mpp_buffer_set_offset(buffer, offset) \
|
||||
mpp_buffer_set_offset_with_caller(buffer, offset, __FUNCTION__)
|
||||
|
||||
#define mpp_buffer_sync_begin(buffer) \
|
||||
mpp_buffer_sync_begin_f(buffer, 0, __FUNCTION__)
|
||||
#define mpp_buffer_sync_end(buffer) \
|
||||
mpp_buffer_sync_end_f(buffer, 0, __FUNCTION__)
|
||||
#define mpp_buffer_sync_partial_begin(buffer, offset, length) \
|
||||
mpp_buffer_sync_partial_begin_f(buffer, 0, offset, length, __FUNCTION__)
|
||||
#define mpp_buffer_sync_partial_end(buffer, offset, length) \
|
||||
mpp_buffer_sync_partial_end_f(buffer, 0, offset, length, __FUNCTION__)
|
||||
|
||||
#define mpp_buffer_sync_ro_begin(buffer) \
|
||||
mpp_buffer_sync_begin_f(buffer, 1, __FUNCTION__)
|
||||
#define mpp_buffer_sync_ro_end(buffer) \
|
||||
mpp_buffer_sync_end_f(buffer, 1, __FUNCTION__)
|
||||
#define mpp_buffer_sync_ro_partial_begin(buffer, offset, length) \
|
||||
mpp_buffer_sync_partial_begin_f(buffer, 1, offset, length, __FUNCTION__)
|
||||
#define mpp_buffer_sync_ro_partial_end(buffer, offset, length) \
|
||||
mpp_buffer_sync_partial_end_f(buffer, 1, offset, length, __FUNCTION__)
|
||||
|
||||
#define mpp_buffer_group_get_internal(group, type, ...) \
|
||||
mpp_buffer_group_get(group, (MppBufferType)(type), MPP_BUFFER_INTERNAL, MODULE_TAG, __FUNCTION__)
|
||||
|
||||
#define mpp_buffer_group_get_external(group, type, ...) \
|
||||
mpp_buffer_group_get(group, (MppBufferType)(type), MPP_BUFFER_EXTERNAL, MODULE_TAG, __FUNCTION__)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* MppBuffer interface
|
||||
* these interface will change value of group and buffer so before calling functions
|
||||
* parameter need to be checked.
|
||||
*
|
||||
* IMPORTANT:
|
||||
* mpp_buffer_import_with_tag - compounded interface for commit and import
|
||||
*
|
||||
*/
|
||||
MPP_RET mpp_buffer_import_with_tag(MppBufferGroup group, MppBufferInfo *info, MppBuffer *buffer,
|
||||
const char *tag, const char *caller);
|
||||
MPP_RET mpp_buffer_get_with_tag(MppBufferGroup group, MppBuffer *buffer, size_t size,
|
||||
const char *tag, const char *caller);
|
||||
MPP_RET mpp_buffer_put_with_caller(MppBuffer buffer, const char *caller);
|
||||
MPP_RET mpp_buffer_inc_ref_with_caller(MppBuffer buffer, const char *caller);
|
||||
|
||||
MPP_RET mpp_buffer_info_get_with_caller(MppBuffer buffer, MppBufferInfo *info, const char *caller);
|
||||
MPP_RET mpp_buffer_read_with_caller(MppBuffer buffer, size_t offset, void *data, size_t size, const char *caller);
|
||||
MPP_RET mpp_buffer_write_with_caller(MppBuffer buffer, size_t offset, void *data, size_t size, const char *caller);
|
||||
void *mpp_buffer_get_ptr_with_caller(MppBuffer buffer, const char *caller);
|
||||
int mpp_buffer_get_fd_with_caller(MppBuffer buffer, const char *caller);
|
||||
size_t mpp_buffer_get_size_with_caller(MppBuffer buffer, const char *caller);
|
||||
int mpp_buffer_get_index_with_caller(MppBuffer buffer, const char *caller);
|
||||
MPP_RET mpp_buffer_set_index_with_caller(MppBuffer buffer, int index, const char *caller);
|
||||
size_t mpp_buffer_get_offset_with_caller(MppBuffer buffer, const char *caller);
|
||||
MPP_RET mpp_buffer_set_offset_with_caller(MppBuffer buffer, size_t offset, const char *caller);
|
||||
|
||||
/**
|
||||
* @brief MppBuffer cache operation function
|
||||
* @param buffer The MppBuffer to run the cache operation
|
||||
* @param ro for readonly option
|
||||
* @param offset partial sync data start offset
|
||||
* @param length partial sync data length
|
||||
*/
|
||||
MPP_RET mpp_buffer_sync_begin_f(MppBuffer buffer, RK_S32 ro, const char* caller);
|
||||
MPP_RET mpp_buffer_sync_end_f(MppBuffer buffer, RK_S32 ro, const char* caller);
|
||||
MPP_RET mpp_buffer_sync_partial_begin_f(MppBuffer buffer, RK_S32 ro, RK_U32 offset, RK_U32 length, const char* caller);
|
||||
MPP_RET mpp_buffer_sync_partial_end_f(MppBuffer buffer, RK_S32 ro, RK_U32 offset, RK_U32 length, const char* caller);
|
||||
|
||||
MPP_RET mpp_buffer_group_get(MppBufferGroup *group, MppBufferType type, MppBufferMode mode,
|
||||
const char *tag, const char *caller);
|
||||
MPP_RET mpp_buffer_group_put(MppBufferGroup group);
|
||||
MPP_RET mpp_buffer_group_clear(MppBufferGroup group);
|
||||
RK_S32 mpp_buffer_group_unused(MppBufferGroup group);
|
||||
size_t mpp_buffer_group_usage(MppBufferGroup group);
|
||||
MppBufferMode mpp_buffer_group_mode(MppBufferGroup group);
|
||||
MppBufferType mpp_buffer_group_type(MppBufferGroup group);
|
||||
|
||||
/*
|
||||
* size : 0 - no limit, other - max buffer size
|
||||
* count : 0 - no limit, other - max buffer count
|
||||
*/
|
||||
MPP_RET mpp_buffer_group_limit_config(MppBufferGroup group, size_t size, RK_S32 count);
|
||||
|
||||
RK_U32 mpp_buffer_total_now();
|
||||
RK_U32 mpp_buffer_total_max();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*__MPP_BUFFER_H__*/
|
@@ -1,62 +0,0 @@
|
||||
/*
|
||||
* Copyright 2021 Rockchip Electronics Co. LTD
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __MPP_COMPAT_H__
|
||||
#define __MPP_COMPAT_H__
|
||||
|
||||
#include "rk_type.h"
|
||||
#include "mpp_err.h"
|
||||
|
||||
typedef enum MppCompatId_e {
|
||||
MPP_COMPAT_INC_FBC_BUF_SIZE,
|
||||
MPP_COMPAT_ENC_ASYNC_INPUT,
|
||||
MPP_COMPAT_DEC_FBC_HDR_256_ODD,
|
||||
MPP_COMPAT_BUTT,
|
||||
} MppCompatId;
|
||||
|
||||
typedef enum MppCompatType_e {
|
||||
MPP_COMPAT_BOOL,
|
||||
MPP_COMPAT_S32,
|
||||
MPP_COMPAT_TYPE_BUTT,
|
||||
} MppCompatType;
|
||||
|
||||
typedef struct MppCompat_t MppCompat;
|
||||
|
||||
/* external user can only update value_ext to notify mpp to change its behavior */
|
||||
struct MppCompat_t {
|
||||
const MppCompatId feature_id;
|
||||
const MppCompatType feature_type;
|
||||
const RK_S32 value_mpp;
|
||||
RK_S32 value_usr;
|
||||
const char *name;
|
||||
MppCompat * const next;
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
MppCompat *mpp_compat_query(void);
|
||||
MppCompat *mpp_compat_query_by_id(MppCompatId id);
|
||||
MPP_RET mpp_compat_update(MppCompat *compat, RK_S32 value);
|
||||
|
||||
void mpp_compat_show(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*__MPP_COMPAT_H__*/
|
@@ -1,54 +0,0 @@
|
||||
/*
|
||||
* Copyright 2015 Rockchip Electronics Co. LTD
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __MPP_ERR_H__
|
||||
#define __MPP_ERR_H__
|
||||
|
||||
#define RK_OK 0
|
||||
#define RK_SUCCESS 0
|
||||
|
||||
typedef enum {
|
||||
MPP_SUCCESS = RK_SUCCESS,
|
||||
MPP_OK = RK_OK,
|
||||
|
||||
MPP_NOK = -1,
|
||||
MPP_ERR_UNKNOW = -2,
|
||||
MPP_ERR_NULL_PTR = -3,
|
||||
MPP_ERR_MALLOC = -4,
|
||||
MPP_ERR_OPEN_FILE = -5,
|
||||
MPP_ERR_VALUE = -6,
|
||||
MPP_ERR_READ_BIT = -7,
|
||||
MPP_ERR_TIMEOUT = -8,
|
||||
MPP_ERR_PERM = -9,
|
||||
|
||||
MPP_ERR_BASE = -1000,
|
||||
|
||||
/* The error in stream processing */
|
||||
MPP_ERR_LIST_STREAM = MPP_ERR_BASE - 1,
|
||||
MPP_ERR_INIT = MPP_ERR_BASE - 2,
|
||||
MPP_ERR_VPU_CODEC_INIT = MPP_ERR_BASE - 3,
|
||||
MPP_ERR_STREAM = MPP_ERR_BASE - 4,
|
||||
MPP_ERR_FATAL_THREAD = MPP_ERR_BASE - 5,
|
||||
MPP_ERR_NOMEM = MPP_ERR_BASE - 6,
|
||||
MPP_ERR_PROTOL = MPP_ERR_BASE - 7,
|
||||
MPP_FAIL_SPLIT_FRAME = MPP_ERR_BASE - 8,
|
||||
MPP_ERR_VPUHW = MPP_ERR_BASE - 9,
|
||||
MPP_EOS_STREAM_REACHED = MPP_ERR_BASE - 11,
|
||||
MPP_ERR_BUFFER_FULL = MPP_ERR_BASE - 12,
|
||||
MPP_ERR_DISPLAY_FULL = MPP_ERR_BASE - 13,
|
||||
} MPP_RET;
|
||||
|
||||
#endif /*__MPP_ERR_H__*/
|
@@ -1,458 +0,0 @@
|
||||
/* SPDX-License-Identifier: Apache-2.0 OR MIT */
|
||||
/*
|
||||
* Copyright (c) 2015 Rockchip Electronics Co., Ltd.
|
||||
*/
|
||||
|
||||
#ifndef __MPP_FRAME_H__
|
||||
#define __MPP_FRAME_H__
|
||||
|
||||
#include "mpp_buffer.h"
|
||||
#include "mpp_meta.h"
|
||||
|
||||
/*
|
||||
* bit definition for mode flag in MppFrame
|
||||
*/
|
||||
/* progressive frame */
|
||||
#define MPP_FRAME_FLAG_FRAME (0x00000000)
|
||||
/* top field only */
|
||||
#define MPP_FRAME_FLAG_TOP_FIELD (0x00000001)
|
||||
/* bottom field only */
|
||||
#define MPP_FRAME_FLAG_BOT_FIELD (0x00000002)
|
||||
/* paired field */
|
||||
#define MPP_FRAME_FLAG_PAIRED_FIELD (MPP_FRAME_FLAG_TOP_FIELD|MPP_FRAME_FLAG_BOT_FIELD)
|
||||
/* paired field with field order of top first */
|
||||
#define MPP_FRAME_FLAG_TOP_FIRST (0x00000004)
|
||||
/* paired field with field order of bottom first */
|
||||
#define MPP_FRAME_FLAG_BOT_FIRST (0x00000008)
|
||||
/* paired field with unknown field order (MBAFF) */
|
||||
#define MPP_FRAME_FLAG_DEINTERLACED (MPP_FRAME_FLAG_TOP_FIRST|MPP_FRAME_FLAG_BOT_FIRST)
|
||||
#define MPP_FRAME_FLAG_FIELD_ORDER_MASK (0x0000000C)
|
||||
// for multiview stream
|
||||
#define MPP_FRAME_FLAG_VIEW_ID_MASK (0x000000f0)
|
||||
|
||||
#define MPP_FRAME_FLAG_IEP_DEI_MASK (0x00000f00)
|
||||
#define MPP_FRAME_FLAG_IEP_DEI_I2O1 (0x00000100)
|
||||
#define MPP_FRAME_FLAG_IEP_DEI_I4O2 (0x00000200)
|
||||
#define MPP_FRAME_FLAG_IEP_DEI_I4O1 (0x00000300)
|
||||
|
||||
/*
|
||||
* MPEG vs JPEG YUV range.
|
||||
*/
|
||||
typedef enum {
|
||||
MPP_FRAME_RANGE_UNSPECIFIED = 0,
|
||||
MPP_FRAME_RANGE_MPEG = 1, ///< the normal 219*2^(n-8) "MPEG" YUV ranges
|
||||
MPP_FRAME_RANGE_JPEG = 2, ///< the normal 2^n-1 "JPEG" YUV ranges
|
||||
MPP_FRAME_RANGE_NB, ///< Not part of ABI
|
||||
} MppFrameColorRange;
|
||||
|
||||
typedef enum {
|
||||
MPP_FRAME_CHROMA_DOWN_SAMPLE_MODE_NONE,
|
||||
MPP_FRAME_CHORMA_DOWN_SAMPLE_MODE_AVERAGE,
|
||||
MPP_FRAME_CHORMA_DOWN_SAMPLE_MODE_DISCARD,
|
||||
} MppFrameChromaDownSampleMode;
|
||||
|
||||
typedef enum {
|
||||
MPP_FRAME_VIDEO_FMT_COMPONEMT = 0,
|
||||
MPP_FRAME_VIDEO_FMT_PAL = 1,
|
||||
MPP_FRAME_VIDEO_FMT_NTSC = 2,
|
||||
MPP_FRAME_VIDEO_FMT_SECAM = 3,
|
||||
MPP_FRAME_VIDEO_FMT_MAC = 4,
|
||||
MPP_FRAME_VIDEO_FMT_UNSPECIFIED = 5,
|
||||
MPP_FRAME_VIDEO_FMT_RESERVED0 = 6,
|
||||
MPP_FRAME_VIDEO_FMT_RESERVED1 = 7,
|
||||
} MppFrameVideoFormat;
|
||||
|
||||
/*
|
||||
* Chromaticity coordinates of the source primaries.
|
||||
*/
|
||||
typedef enum {
|
||||
MPP_FRAME_PRI_RESERVED0 = 0,
|
||||
MPP_FRAME_PRI_BT709 = 1, ///< also ITU-R BT1361 / IEC 61966-2-4 / SMPTE RP177 Annex B
|
||||
MPP_FRAME_PRI_UNSPECIFIED = 2,
|
||||
MPP_FRAME_PRI_RESERVED = 3,
|
||||
MPP_FRAME_PRI_BT470M = 4, ///< also FCC Title 47 Code of Federal Regulations 73.682 (a)(20)
|
||||
|
||||
MPP_FRAME_PRI_BT470BG = 5, ///< also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM
|
||||
MPP_FRAME_PRI_SMPTE170M = 6, ///< also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC/SMPTE ST 170 (2004)
|
||||
MPP_FRAME_PRI_SMPTE240M = 7, ///< functionally identical to above/SMPTE ST 240
|
||||
MPP_FRAME_PRI_FILM = 8, ///< colour filters using Illuminant C
|
||||
MPP_FRAME_PRI_BT2020 = 9, ///< ITU-R BT2020 / ITU-R BT.2100-2
|
||||
MPP_FRAME_PRI_SMPTEST428_1 = 10, ///< SMPTE ST 428-1 (CIE 1931 XYZ)
|
||||
MPP_FRAME_PRI_SMPTE431 = 11, ///< SMPTE ST 431-2 (2011) / DCI P3
|
||||
MPP_FRAME_PRI_SMPTE432 = 12, ///< SMPTE ST 432-1 (2010) / P3 D65 / Display P3
|
||||
MPP_FRAME_PRI_JEDEC_P22 = 22, ///< JEDEC P22 phosphors
|
||||
MPP_FRAME_PRI_NB, ///< Not part of ABI
|
||||
} MppFrameColorPrimaries;
|
||||
|
||||
/*
|
||||
* Color Transfer Characteristic.
|
||||
*/
|
||||
typedef enum {
|
||||
MPP_FRAME_TRC_RESERVED0 = 0,
|
||||
MPP_FRAME_TRC_BT709 = 1, ///< also ITU-R BT1361
|
||||
MPP_FRAME_TRC_UNSPECIFIED = 2,
|
||||
MPP_FRAME_TRC_RESERVED = 3,
|
||||
MPP_FRAME_TRC_GAMMA22 = 4, ///< also ITU-R BT470M / ITU-R BT1700 625 PAL & SECAM
|
||||
MPP_FRAME_TRC_GAMMA28 = 5, ///< also ITU-R BT470BG
|
||||
MPP_FRAME_TRC_SMPTE170M = 6, ///< also ITU-R BT601-6 525 or 625 / ITU-R BT1358 525 or 625 / ITU-R BT1700 NTSC
|
||||
MPP_FRAME_TRC_SMPTE240M = 7,
|
||||
MPP_FRAME_TRC_LINEAR = 8, ///< "Linear transfer characteristics"
|
||||
MPP_FRAME_TRC_LOG = 9, ///< "Logarithmic transfer characteristic (100:1 range)"
|
||||
MPP_FRAME_TRC_LOG_SQRT = 10, ///< "Logarithmic transfer characteristic (100 * Sqrt(10) : 1 range)"
|
||||
MPP_FRAME_TRC_IEC61966_2_4 = 11, ///< IEC 61966-2-4
|
||||
MPP_FRAME_TRC_BT1361_ECG = 12, ///< ITU-R BT1361 Extended Colour Gamut
|
||||
MPP_FRAME_TRC_IEC61966_2_1 = 13, ///< IEC 61966-2-1 (sRGB or sYCC)
|
||||
MPP_FRAME_TRC_BT2020_10 = 14, ///< ITU-R BT2020 for 10 bit system
|
||||
MPP_FRAME_TRC_BT2020_12 = 15, ///< ITU-R BT2020 for 12 bit system
|
||||
MPP_FRAME_TRC_SMPTEST2084 = 16, ///< SMPTE ST 2084 for 10-, 12-, 14- and 16-bit systems
|
||||
MPP_FRAME_TRC_SMPTEST428_1 = 17, ///< SMPTE ST 428-1
|
||||
MPP_FRAME_TRC_ARIB_STD_B67 = 18, ///< ARIB STD-B67, known as "Hybrid log-gamma"
|
||||
MPP_FRAME_TRC_NB, ///< Not part of ABI
|
||||
} MppFrameColorTransferCharacteristic;
|
||||
|
||||
/*
|
||||
* YUV colorspace type.
|
||||
*/
|
||||
typedef enum {
|
||||
MPP_FRAME_SPC_RGB = 0, ///< order of coefficients is actually GBR, also IEC 61966-2-1 (sRGB)
|
||||
MPP_FRAME_SPC_BT709 = 1, ///< also ITU-R BT1361 / IEC 61966-2-4 xvYCC709 / SMPTE RP177 Annex B
|
||||
MPP_FRAME_SPC_UNSPECIFIED = 2,
|
||||
MPP_FRAME_SPC_RESERVED = 3,
|
||||
MPP_FRAME_SPC_FCC = 4, ///< FCC Title 47 Code of Federal Regulations 73.682 (a)(20)
|
||||
MPP_FRAME_SPC_BT470BG = 5, ///< also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM / IEC 61966-2-4 xvYCC601
|
||||
MPP_FRAME_SPC_SMPTE170M = 6, ///< also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC / functionally identical to above
|
||||
MPP_FRAME_SPC_SMPTE240M = 7,
|
||||
MPP_FRAME_SPC_YCOCG = 8, ///< Used by Dirac / VC-2 and H.264 FRext, see ITU-T SG16
|
||||
MPP_FRAME_SPC_BT2020_NCL = 9, ///< ITU-R BT2020 non-constant luminance system
|
||||
MPP_FRAME_SPC_BT2020_CL = 10, ///< ITU-R BT2020 constant luminance system
|
||||
MPP_FRAME_SPC_SMPTE2085 = 11, ///< SMPTE 2085, Y'D'zD'x
|
||||
MPP_FRAME_SPC_CHROMA_DERIVED_NCL = 12, ///< Chromaticity-derived non-constant luminance system
|
||||
MPP_FRAME_SPC_CHROMA_DERIVED_CL = 13, ///< Chromaticity-derived constant luminance system
|
||||
MPP_FRAME_SPC_ICTCP = 14, ///< ITU-R BT.2100-0, ICtCp
|
||||
MPP_FRAME_SPC_NB, ///< Not part of ABI
|
||||
} MppFrameColorSpace;
|
||||
|
||||
/*
|
||||
* Location of chroma samples.
|
||||
*
|
||||
* Illustration showing the location of the first (top left) chroma sample of the
|
||||
* image, the left shows only luma, the right
|
||||
* shows the location of the chroma sample, the 2 could be imagined to overlay
|
||||
* each other but are drawn separately due to limitations of ASCII
|
||||
*
|
||||
* 1st 2nd 1st 2nd horizontal luma sample positions
|
||||
* v v v v
|
||||
* ______ ______
|
||||
*1st luma line > |X X ... |3 4 X ... X are luma samples,
|
||||
* | |1 2 1-6 are possible chroma positions
|
||||
*2nd luma line > |X X ... |5 6 X ... 0 is undefined/unknown position
|
||||
*/
|
||||
typedef enum {
|
||||
MPP_CHROMA_LOC_UNSPECIFIED = 0,
|
||||
MPP_CHROMA_LOC_LEFT = 1, ///< mpeg2/4 4:2:0, h264 default for 4:2:0
|
||||
MPP_CHROMA_LOC_CENTER = 2, ///< mpeg1 4:2:0, jpeg 4:2:0, h263 4:2:0
|
||||
MPP_CHROMA_LOC_TOPLEFT = 3, ///< ITU-R 601, SMPTE 274M 296M S314M(DV 4:1:1), mpeg2 4:2:2
|
||||
MPP_CHROMA_LOC_TOP = 4,
|
||||
MPP_CHROMA_LOC_BOTTOMLEFT = 5,
|
||||
MPP_CHROMA_LOC_BOTTOM = 6,
|
||||
MPP_CHROMA_LOC_NB, ///< Not part of ABI
|
||||
} MppFrameChromaLocation;
|
||||
|
||||
typedef enum {
|
||||
MPP_CHROMA_UNSPECIFIED,
|
||||
MPP_CHROMA_400,
|
||||
MPP_CHROMA_410,
|
||||
MPP_CHROMA_411,
|
||||
MPP_CHROMA_420,
|
||||
MPP_CHROMA_422,
|
||||
MPP_CHROMA_440,
|
||||
MPP_CHROMA_444,
|
||||
} MppFrameChromaFormat;
|
||||
|
||||
/*
|
||||
* MppFrameFormat bit flag:
|
||||
*
|
||||
* +-----------------------------------------------+
|
||||
* | 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 |
|
||||
* +-----------------------------------------------+
|
||||
* bit 0 ~ 15: YUV / RGB format value
|
||||
* bit 16 ~ 19: YUV / RGB flag 0 - YUV; 1 - RGB;
|
||||
* bit 20 ~ 23: Frame Buffer Compression (FBC) flag, 0 - No FBC; 1 - FBCv1; 2 - FBCv2;
|
||||
* bit 24 : Big / little end flag, 0 - big end; 1 - little end;
|
||||
* bit 25 : Tile format flag, 0 - No tile; 1 - tile format;
|
||||
* bit 26 ~ 27: High Dynamic Range (HDR) flag, 0 - Standard Dynamic Range (SDR); 1 - HDR;
|
||||
*
|
||||
* NOTE: FBC format and tile format can not exist at the same time.
|
||||
*/
|
||||
|
||||
#define MPP_FRAME_FMT_MASK (0x000fffff)
|
||||
#define MPP_FRAME_FMT_PROP_MASK (0x0ff00000)
|
||||
|
||||
#define MPP_FRAME_FMT_COLOR_MASK (0x000f0000)
|
||||
#define MPP_FRAME_FMT_YUV (0x00000000)
|
||||
#define MPP_FRAME_FMT_RGB (0x00010000)
|
||||
|
||||
#define MPP_FRAME_FBC_MASK (0x00f00000)
|
||||
#define MPP_FRAME_FBC_NONE (0x00000000)
|
||||
|
||||
#define MPP_FRAME_HDR_MASK (0x0c000000)
|
||||
#define MPP_FRAME_HDR_NONE (0x00000000)
|
||||
#define MPP_FRAME_HDR (0x04000000)
|
||||
|
||||
#define MPP_FRAME_TILE_FLAG (0x02000000)
|
||||
|
||||
/*
|
||||
* AFBC_V1 is for ISP output.
|
||||
* It has default payload offset to be calculated * from width and height:
|
||||
* Payload offset = MPP_ALIGN(MPP_ALIGN(width, 16) * MPP_ALIGN(height, 16) / 16, SZ_4K)
|
||||
*/
|
||||
#define MPP_FRAME_FBC_AFBC_V1 (0x00100000)
|
||||
/*
|
||||
* AFBC_V2 is for video decoder output.
|
||||
* It stores payload offset in first 32-bit in header address
|
||||
* Payload offset is always set to zero.
|
||||
*/
|
||||
#define MPP_FRAME_FBC_AFBC_V2 (0x00200000)
|
||||
|
||||
#define MPP_FRAME_FMT_LE_MASK (0x01000000)
|
||||
|
||||
#define MPP_FRAME_FMT_IS_YUV(fmt) (((fmt & MPP_FRAME_FMT_COLOR_MASK) == MPP_FRAME_FMT_YUV) && \
|
||||
((fmt & MPP_FRAME_FMT_MASK) < MPP_FMT_YUV_BUTT))
|
||||
#define MPP_FRAME_FMT_IS_YUV_10BIT(fmt) ((fmt & MPP_FRAME_FMT_MASK) == MPP_FMT_YUV420SP_10BIT || \
|
||||
(fmt & MPP_FRAME_FMT_MASK) == MPP_FMT_YUV422SP_10BIT)
|
||||
#define MPP_FRAME_FMT_IS_RGB(fmt) (((fmt & MPP_FRAME_FMT_COLOR_MASK) == MPP_FRAME_FMT_RGB) && \
|
||||
((fmt & MPP_FRAME_FMT_MASK) < MPP_FMT_RGB_BUTT))
|
||||
|
||||
/*
|
||||
* For MPP_FRAME_FBC_AFBC_V1 the 16byte aligned stride is used.
|
||||
*/
|
||||
#define MPP_FRAME_FMT_IS_FBC(fmt) (fmt & MPP_FRAME_FBC_MASK)
|
||||
|
||||
#define MPP_FRAME_FMT_IS_HDR(fmt) (fmt & MPP_FRAME_HDR_MASK)
|
||||
|
||||
#define MPP_FRAME_FMT_IS_LE(fmt) ((fmt & MPP_FRAME_FMT_LE_MASK) == MPP_FRAME_FMT_LE_MASK)
|
||||
#define MPP_FRAME_FMT_IS_BE(fmt) ((fmt & MPP_FRAME_FMT_LE_MASK) == 0)
|
||||
|
||||
#define MPP_FRAME_FMT_IS_TILE(fmt) (fmt & MPP_FRAME_TILE_FLAG)
|
||||
|
||||
/* mpp color format index definition */
|
||||
typedef enum {
|
||||
MPP_FMT_YUV420SP = (MPP_FRAME_FMT_YUV + 0), /* YYYY... UV... (NV12) */
|
||||
/*
|
||||
* A rockchip specific pixel format, without gap between pixel aganist
|
||||
* the P010_10LE/P010_10BE
|
||||
*/
|
||||
MPP_FMT_YUV420SP_10BIT = (MPP_FRAME_FMT_YUV + 1),
|
||||
MPP_FMT_YUV422SP = (MPP_FRAME_FMT_YUV + 2), /* YYYY... UVUV... (NV16) */
|
||||
MPP_FMT_YUV422SP_10BIT = (MPP_FRAME_FMT_YUV + 3), ///< Not part of ABI
|
||||
MPP_FMT_YUV420P = (MPP_FRAME_FMT_YUV + 4), /* YYYY... U...V... (I420) */
|
||||
MPP_FMT_YUV420SP_VU = (MPP_FRAME_FMT_YUV + 5), /* YYYY... VUVUVU... (NV21) */
|
||||
MPP_FMT_YUV422P = (MPP_FRAME_FMT_YUV + 6), /* YYYY... UU...VV...(422P) */
|
||||
MPP_FMT_YUV422SP_VU = (MPP_FRAME_FMT_YUV + 7), /* YYYY... VUVUVU... (NV61) */
|
||||
MPP_FMT_YUV422_YUYV = (MPP_FRAME_FMT_YUV + 8), /* YUYVYUYV... (YUY2) */
|
||||
MPP_FMT_YUV422_YVYU = (MPP_FRAME_FMT_YUV + 9), /* YVYUYVYU... (YVY2) */
|
||||
MPP_FMT_YUV422_UYVY = (MPP_FRAME_FMT_YUV + 10), /* UYVYUYVY... (UYVY) */
|
||||
MPP_FMT_YUV422_VYUY = (MPP_FRAME_FMT_YUV + 11), /* VYUYVYUY... (VYUY) */
|
||||
MPP_FMT_YUV400 = (MPP_FRAME_FMT_YUV + 12), /* YYYY... */
|
||||
MPP_FMT_YUV440SP = (MPP_FRAME_FMT_YUV + 13), /* YYYY... UVUV... */
|
||||
MPP_FMT_YUV411SP = (MPP_FRAME_FMT_YUV + 14), /* YYYY... UV... */
|
||||
MPP_FMT_YUV444SP = (MPP_FRAME_FMT_YUV + 15), /* YYYY... UVUVUVUV... */
|
||||
MPP_FMT_YUV444P = (MPP_FRAME_FMT_YUV + 16), /* YYYY... UUUU... VVVV... */
|
||||
MPP_FMT_YUV_BUTT,
|
||||
|
||||
MPP_FMT_RGB565 = (MPP_FRAME_FMT_RGB + 0), /* 16-bit RGB */
|
||||
MPP_FMT_BGR565 = (MPP_FRAME_FMT_RGB + 1), /* 16-bit RGB */
|
||||
MPP_FMT_RGB555 = (MPP_FRAME_FMT_RGB + 2), /* 15-bit RGB */
|
||||
MPP_FMT_BGR555 = (MPP_FRAME_FMT_RGB + 3), /* 15-bit RGB */
|
||||
MPP_FMT_RGB444 = (MPP_FRAME_FMT_RGB + 4), /* 12-bit RGB */
|
||||
MPP_FMT_BGR444 = (MPP_FRAME_FMT_RGB + 5), /* 12-bit RGB */
|
||||
MPP_FMT_RGB888 = (MPP_FRAME_FMT_RGB + 6), /* 24-bit RGB */
|
||||
MPP_FMT_BGR888 = (MPP_FRAME_FMT_RGB + 7), /* 24-bit RGB */
|
||||
MPP_FMT_RGB101010 = (MPP_FRAME_FMT_RGB + 8), /* 30-bit RGB */
|
||||
MPP_FMT_BGR101010 = (MPP_FRAME_FMT_RGB + 9), /* 30-bit RGB */
|
||||
MPP_FMT_ARGB8888 = (MPP_FRAME_FMT_RGB + 10), /* 32-bit RGB */
|
||||
MPP_FMT_ABGR8888 = (MPP_FRAME_FMT_RGB + 11), /* 32-bit RGB */
|
||||
MPP_FMT_BGRA8888 = (MPP_FRAME_FMT_RGB + 12), /* 32-bit RGB */
|
||||
MPP_FMT_RGBA8888 = (MPP_FRAME_FMT_RGB + 13), /* 32-bit RGB */
|
||||
MPP_FMT_RGB_BUTT,
|
||||
|
||||
MPP_FMT_BUTT,
|
||||
} MppFrameFormat;
|
||||
|
||||
/**
|
||||
* Rational number (pair of numerator and denominator).
|
||||
*/
|
||||
typedef struct MppFrameRational {
|
||||
RK_S32 num; ///< Numerator
|
||||
RK_S32 den; ///< Denominator
|
||||
} MppFrameRational;
|
||||
|
||||
typedef struct MppFrameMasteringDisplayMetadata {
|
||||
RK_U16 display_primaries[3][2];
|
||||
RK_U16 white_point[2];
|
||||
RK_U32 max_luminance;
|
||||
RK_U32 min_luminance;
|
||||
} MppFrameMasteringDisplayMetadata;
|
||||
|
||||
typedef struct MppFrameContentLightMetadata {
|
||||
RK_U16 MaxCLL;
|
||||
RK_U16 MaxFALL;
|
||||
} MppFrameContentLightMetadata;
|
||||
|
||||
typedef struct MppFrameHdrDynamicMeta {
|
||||
RK_U32 hdr_fmt;
|
||||
RK_U32 size;
|
||||
RK_U8 data[];
|
||||
} MppFrameHdrDynamicMeta;
|
||||
|
||||
typedef enum MppFrameError {
|
||||
/* General error not specified */
|
||||
MPP_FRAME_ERR_UNKNOW = 0x0001,
|
||||
|
||||
/* Critical error for decoder not support error */
|
||||
MPP_FRAME_ERR_UNSUPPORT = 0x0002,
|
||||
|
||||
/*
|
||||
* Fatal error for decoder can not parse a valid frame for hardware.
|
||||
* the pixel data is all invalid.
|
||||
*/
|
||||
MPP_FRAME_ERR_DEC_INVALID = 0x0010,
|
||||
|
||||
/*
|
||||
* Normal error for decoder found hardware error on decoding.
|
||||
*/
|
||||
MPP_FRAME_ERR_DEC_HW_ERR = 0x0100,
|
||||
|
||||
/*
|
||||
* Normal error for decoder found missing reference frame on decoding.
|
||||
*/
|
||||
MPP_FRAME_ERR_DEC_MISS_REF = 0x0200,
|
||||
} MppFrameError;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* MppFrame interface
|
||||
*/
|
||||
MPP_RET mpp_frame_init(MppFrame *frame);
|
||||
MPP_RET mpp_frame_deinit(MppFrame *frame);
|
||||
|
||||
/*
|
||||
* normal parameter
|
||||
*
|
||||
* offset_x
|
||||
* <-------->
|
||||
*
|
||||
* <---------------+ hor_stride +--------------->
|
||||
*
|
||||
* +------------------------------------------------------+ ^ ^
|
||||
* | | | |
|
||||
* | | | | offset_y
|
||||
* | | | |
|
||||
* | +--------------------------------+ ^ | | v
|
||||
* | | | | | |
|
||||
* | | | + | +
|
||||
* | | | |
|
||||
* | | valid data area | height | ver_stride
|
||||
* | | | |
|
||||
* | | | + | +
|
||||
* | | | | | |
|
||||
* | +--------------------------------+ v | |
|
||||
* | | |
|
||||
* | <----------+ width +---------> | |
|
||||
* | | |
|
||||
* +------------------------------------------------------+ v
|
||||
*
|
||||
*/
|
||||
RK_U32 mpp_frame_get_width(const MppFrame frame);
|
||||
void mpp_frame_set_width(MppFrame frame, RK_U32 width);
|
||||
RK_U32 mpp_frame_get_height(const MppFrame frame);
|
||||
void mpp_frame_set_height(MppFrame frame, RK_U32 height);
|
||||
RK_U32 mpp_frame_get_hor_stride(const MppFrame frame);
|
||||
void mpp_frame_set_hor_stride(MppFrame frame, RK_U32 hor_stride);
|
||||
RK_U32 mpp_frame_get_ver_stride(const MppFrame frame);
|
||||
void mpp_frame_set_ver_stride(MppFrame frame, RK_U32 ver_stride);
|
||||
void mpp_frame_set_hor_stride_pixel(MppFrame frame, RK_U32 hor_stride_pixel);
|
||||
RK_U32 mpp_frame_get_hor_stride_pixel(const MppFrame frame);
|
||||
void mpp_frame_set_fbc_hdr_stride(MppFrame frame, RK_U32 fbc_hdr_stride);
|
||||
RK_U32 mpp_frame_get_fbc_hdr_stride(const MppFrame frame);
|
||||
|
||||
RK_U32 mpp_frame_get_offset_x(const MppFrame frame);
|
||||
void mpp_frame_set_offset_x(MppFrame frame, RK_U32 offset_x);
|
||||
RK_U32 mpp_frame_get_offset_y(const MppFrame frame);
|
||||
void mpp_frame_set_offset_y(MppFrame frame, RK_U32 offset_y);
|
||||
RK_U32 mpp_frame_get_mode(const MppFrame frame);
|
||||
void mpp_frame_set_mode(MppFrame frame, RK_U32 mode);
|
||||
RK_U32 mpp_frame_get_discard(const MppFrame frame);
|
||||
void mpp_frame_set_discard(MppFrame frame, RK_U32 discard);
|
||||
RK_U32 mpp_frame_get_viewid(const MppFrame frame);
|
||||
void mpp_frame_set_viewid(MppFrame frame, RK_U32 viewid);
|
||||
RK_U32 mpp_frame_get_poc(const MppFrame frame);
|
||||
void mpp_frame_set_poc(MppFrame frame, RK_U32 poc);
|
||||
RK_S64 mpp_frame_get_pts(const MppFrame frame);
|
||||
void mpp_frame_set_pts(MppFrame frame, RK_S64 pts);
|
||||
RK_S64 mpp_frame_get_dts(const MppFrame frame);
|
||||
void mpp_frame_set_dts(MppFrame frame, RK_S64 dts);
|
||||
RK_U32 mpp_frame_get_errinfo(const MppFrame frame);
|
||||
void mpp_frame_set_errinfo(MppFrame frame, RK_U32 errinfo);
|
||||
size_t mpp_frame_get_buf_size(const MppFrame frame);
|
||||
void mpp_frame_set_buf_size(MppFrame frame, size_t buf_size);
|
||||
void mpp_frame_set_thumbnail_en(MppFrame frame, RK_U32 thumbnail_en);
|
||||
RK_U32 mpp_frame_get_thumbnail_en(const MppFrame frame);
|
||||
|
||||
/*
|
||||
* flow control parmeter
|
||||
*/
|
||||
RK_U32 mpp_frame_get_eos(const MppFrame frame);
|
||||
void mpp_frame_set_eos(MppFrame frame, RK_U32 eos);
|
||||
RK_U32 mpp_frame_get_info_change(const MppFrame frame);
|
||||
void mpp_frame_set_info_change(MppFrame frame, RK_U32 info_change);
|
||||
|
||||
/*
|
||||
* buffer parameter
|
||||
*/
|
||||
MppBuffer mpp_frame_get_buffer(const MppFrame frame);
|
||||
void mpp_frame_set_buffer(MppFrame frame, MppBuffer buffer);
|
||||
|
||||
/*
|
||||
* meta data parameter
|
||||
*/
|
||||
RK_S32 mpp_frame_has_meta(const MppFrame frame);
|
||||
MppMeta mpp_frame_get_meta(const MppFrame frame);
|
||||
void mpp_frame_set_meta(MppFrame frame, MppMeta meta);
|
||||
|
||||
/*
|
||||
* color related parameter
|
||||
*/
|
||||
MppFrameColorRange mpp_frame_get_color_range(const MppFrame frame);
|
||||
void mpp_frame_set_color_range(MppFrame frame, MppFrameColorRange color_range);
|
||||
MppFrameColorPrimaries mpp_frame_get_color_primaries(const MppFrame frame);
|
||||
void mpp_frame_set_color_primaries(MppFrame frame, MppFrameColorPrimaries color_primaries);
|
||||
MppFrameColorTransferCharacteristic mpp_frame_get_color_trc(const MppFrame frame);
|
||||
void mpp_frame_set_color_trc(MppFrame frame, MppFrameColorTransferCharacteristic color_trc);
|
||||
MppFrameColorSpace mpp_frame_get_colorspace(const MppFrame frame);
|
||||
void mpp_frame_set_colorspace(MppFrame frame, MppFrameColorSpace colorspace);
|
||||
MppFrameChromaLocation mpp_frame_get_chroma_location(const MppFrame frame);
|
||||
void mpp_frame_set_chroma_location(MppFrame frame, MppFrameChromaLocation chroma_location);
|
||||
MppFrameFormat mpp_frame_get_fmt(MppFrame frame);
|
||||
void mpp_frame_set_fmt(MppFrame frame, MppFrameFormat fmt);
|
||||
MppFrameRational mpp_frame_get_sar(const MppFrame frame);
|
||||
void mpp_frame_set_sar(MppFrame frame, MppFrameRational sar);
|
||||
MppFrameMasteringDisplayMetadata mpp_frame_get_mastering_display(const MppFrame frame);
|
||||
void mpp_frame_set_mastering_display(MppFrame frame, MppFrameMasteringDisplayMetadata mastering_display);
|
||||
MppFrameContentLightMetadata mpp_frame_get_content_light(const MppFrame frame);
|
||||
void mpp_frame_set_content_light(MppFrame frame, MppFrameContentLightMetadata content_light);
|
||||
MppFrameHdrDynamicMeta* mpp_frame_get_hdr_dynamic_meta(const MppFrame frame);
|
||||
void mpp_frame_set_hdr_dynamic_meta(MppFrame frame, MppFrameHdrDynamicMeta *vivi_data);
|
||||
|
||||
/*
|
||||
* HDR parameter
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*__MPP_FRAME_H__*/
|
@@ -1,99 +0,0 @@
|
||||
/*
|
||||
* Copyright 2022 Rockchip Electronics Co. LTD
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __MPP_LOG_H__
|
||||
#define __MPP_LOG_H__
|
||||
|
||||
#include "rk_type.h"
|
||||
#include "mpp_log_def.h"
|
||||
|
||||
/*
|
||||
* _c function will add condition check
|
||||
* _f function will add function name to the log
|
||||
* _cf function will add both function name and condition check
|
||||
*/
|
||||
|
||||
/*
|
||||
* mpp runtime log system usage:
|
||||
* mpp_logf is for fatal logging. For use when aborting
|
||||
* mpp_loge is for error logging. For use with unrecoverable failures.
|
||||
* mpp_logw is for warning logging. For use with recoverable failures.
|
||||
* mpp_logi is for informational logging.
|
||||
* mpp_logd is for debug logging.
|
||||
* mpp_logv is for verbose logging
|
||||
*/
|
||||
|
||||
#define mpp_logf(fmt, ...) _mpp_log_l(MPP_LOG_FATAL, MODULE_TAG, fmt, NULL, ## __VA_ARGS__)
|
||||
#define mpp_loge(fmt, ...) _mpp_log_l(MPP_LOG_ERROR, MODULE_TAG, fmt, NULL, ## __VA_ARGS__)
|
||||
#define mpp_logw(fmt, ...) _mpp_log_l(MPP_LOG_WARN, MODULE_TAG, fmt, NULL, ## __VA_ARGS__)
|
||||
#define mpp_logi(fmt, ...) _mpp_log_l(MPP_LOG_INFO, MODULE_TAG, fmt, NULL, ## __VA_ARGS__)
|
||||
#define mpp_logd(fmt, ...) _mpp_log_l(MPP_LOG_DEBUG, MODULE_TAG, fmt, NULL, ## __VA_ARGS__)
|
||||
#define mpp_logv(fmt, ...) _mpp_log_l(MPP_LOG_VERBOSE, MODULE_TAG, fmt, NULL, ## __VA_ARGS__)
|
||||
|
||||
#define mpp_logf_f(fmt, ...) _mpp_log_l(MPP_LOG_FATAL, MODULE_TAG, fmt, __FUNCTION__, ## __VA_ARGS__)
|
||||
#define mpp_loge_f(fmt, ...) _mpp_log_l(MPP_LOG_ERROR, MODULE_TAG, fmt, __FUNCTION__, ## __VA_ARGS__)
|
||||
#define mpp_logw_f(fmt, ...) _mpp_log_l(MPP_LOG_WARN, MODULE_TAG, fmt, __FUNCTION__, ## __VA_ARGS__)
|
||||
#define mpp_logi_f(fmt, ...) _mpp_log_l(MPP_LOG_INFO, MODULE_TAG, fmt, __FUNCTION__, ## __VA_ARGS__)
|
||||
#define mpp_logd_f(fmt, ...) _mpp_log_l(MPP_LOG_DEBUG, MODULE_TAG, fmt, __FUNCTION__, ## __VA_ARGS__)
|
||||
#define mpp_logv_f(fmt, ...) _mpp_log_l(MPP_LOG_VERBOSE, MODULE_TAG, fmt, __FUNCTION__, ## __VA_ARGS__)
|
||||
|
||||
#define mpp_logf_c(cond, fmt, ...) do { if (cond) mpp_logf(fmt, ## __VA_ARGS__); } while (0)
|
||||
#define mpp_loge_c(cond, fmt, ...) do { if (cond) mpp_loge(fmt, ## __VA_ARGS__); } while (0)
|
||||
#define mpp_logw_c(cond, fmt, ...) do { if (cond) mpp_logw(fmt, ## __VA_ARGS__); } while (0)
|
||||
#define mpp_logi_c(cond, fmt, ...) do { if (cond) mpp_logi(fmt, ## __VA_ARGS__); } while (0)
|
||||
#define mpp_logd_c(cond, fmt, ...) do { if (cond) mpp_logd(fmt, ## __VA_ARGS__); } while (0)
|
||||
#define mpp_logv_c(cond, fmt, ...) do { if (cond) mpp_logv(fmt, ## __VA_ARGS__); } while (0)
|
||||
|
||||
#define mpp_logf_cf(cond, fmt, ...) do { if (cond) mpp_logf_f(fmt, ## __VA_ARGS__); } while (0)
|
||||
#define mpp_loge_cf(cond, fmt, ...) do { if (cond) mpp_loge_f(fmt, ## __VA_ARGS__); } while (0)
|
||||
#define mpp_logw_cf(cond, fmt, ...) do { if (cond) mpp_logw_f(fmt, ## __VA_ARGS__); } while (0)
|
||||
#define mpp_logi_cf(cond, fmt, ...) do { if (cond) mpp_logi_f(fmt, ## __VA_ARGS__); } while (0)
|
||||
#define mpp_logd_cf(cond, fmt, ...) do { if (cond) mpp_logd_f(fmt, ## __VA_ARGS__); } while (0)
|
||||
#define mpp_logv_cf(cond, fmt, ...) do { if (cond) mpp_logv_f(fmt, ## __VA_ARGS__); } while (0)
|
||||
|
||||
/*
|
||||
* mpp runtime log system usage:
|
||||
* mpp_err is for error status message, it will print for sure.
|
||||
* mpp_log is for important message like open/close/reset/flush, it will print too.
|
||||
*/
|
||||
|
||||
#define mpp_log(fmt, ...) mpp_logi(fmt, ## __VA_ARGS__)
|
||||
#define mpp_err(fmt, ...) mpp_loge(fmt, ## __VA_ARGS__)
|
||||
|
||||
#define mpp_log_f(fmt, ...) mpp_logi_f(fmt, ## __VA_ARGS__)
|
||||
#define mpp_err_f(fmt, ...) mpp_loge_f(fmt, ## __VA_ARGS__)
|
||||
|
||||
#define mpp_log_c(cond, fmt, ...) do { if (cond) mpp_log(fmt, ## __VA_ARGS__); } while (0)
|
||||
#define mpp_log_cf(cond, fmt, ...) do { if (cond) mpp_log_f(fmt, ## __VA_ARGS__); } while (0)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void _mpp_log_l(int level, const char *tag, const char *fmt, const char *func, ...);
|
||||
|
||||
void mpp_set_log_level(int level);
|
||||
int mpp_get_log_level(void);
|
||||
|
||||
/* deprecated function */
|
||||
void _mpp_log(const char *tag, const char *fmt, const char *func, ...);
|
||||
void _mpp_err(const char *tag, const char *fmt, const char *func, ...);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*__MPP_LOG_H__*/
|
@@ -1,37 +0,0 @@
|
||||
/*
|
||||
* Copyright 2022 Rockchip Electronics Co. LTD
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __MPP_LOG_DEF_H__
|
||||
#define __MPP_LOG_DEF_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define MPP_LOG_UNKNOWN 0 /* internal use only */
|
||||
#define MPP_LOG_FATAL 1 /* fatal error on aborting */
|
||||
#define MPP_LOG_ERROR 2 /* error log on unrecoverable failures */
|
||||
#define MPP_LOG_WARN 3 /* warning log on recoverable failures */
|
||||
#define MPP_LOG_INFO 4 /* Informational log */
|
||||
#define MPP_LOG_DEBUG 5 /* Debug log */
|
||||
#define MPP_LOG_VERBOSE 6 /* Verbose log */
|
||||
#define MPP_LOG_SILENT 7 /* internal use only */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*__MPP_LOG_DEF_H__*/
|
@@ -1,194 +0,0 @@
|
||||
/*
|
||||
* Copyright 2015 Rockchip Electronics Co. LTD
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __MPP_META_H__
|
||||
#define __MPP_META_H__
|
||||
|
||||
#include <stdint.h>
|
||||
#include "rk_type.h"
|
||||
|
||||
#define FOURCC_META(a, b, c, d) ((RK_U32)(a) << 24 | \
|
||||
((RK_U32)(b) << 16) | \
|
||||
((RK_U32)(c) << 8) | \
|
||||
((RK_U32)(d) << 0))
|
||||
|
||||
/*
|
||||
* Mpp Metadata definition
|
||||
*
|
||||
* Metadata is for information transmision in mpp.
|
||||
* Mpp task will contain two meta data:
|
||||
*
|
||||
* 1. Data flow metadata
|
||||
* This metadata contains information of input / output data flow. For example
|
||||
* A. decoder input side task the input packet must be defined and output frame
|
||||
* may not be defined. Then decoder will try malloc or use committed buffer to
|
||||
* complete decoding.
|
||||
* B. decoder output side task
|
||||
*
|
||||
*
|
||||
* 2. Flow control metadata
|
||||
*
|
||||
*/
|
||||
typedef enum MppMetaDataType_e {
|
||||
/*
|
||||
* mpp meta data of data flow
|
||||
* reference counter will be used for these meta data type
|
||||
*/
|
||||
TYPE_FRAME = FOURCC_META('m', 'f', 'r', 'm'),
|
||||
TYPE_PACKET = FOURCC_META('m', 'p', 'k', 't'),
|
||||
TYPE_BUFFER = FOURCC_META('m', 'b', 'u', 'f'),
|
||||
|
||||
/* mpp meta data of normal data type */
|
||||
TYPE_S32 = FOURCC_META('s', '3', '2', ' '),
|
||||
TYPE_S64 = FOURCC_META('s', '6', '4', ' '),
|
||||
TYPE_PTR = FOURCC_META('p', 't', 'r', ' '),
|
||||
} MppMetaType;
|
||||
|
||||
typedef enum MppMetaKey_e {
|
||||
/* data flow key */
|
||||
KEY_INPUT_FRAME = FOURCC_META('i', 'f', 'r', 'm'),
|
||||
KEY_INPUT_PACKET = FOURCC_META('i', 'p', 'k', 't'),
|
||||
KEY_OUTPUT_FRAME = FOURCC_META('o', 'f', 'r', 'm'),
|
||||
KEY_OUTPUT_PACKET = FOURCC_META('o', 'p', 'k', 't'),
|
||||
/* output motion information for motion detection */
|
||||
KEY_MOTION_INFO = FOURCC_META('m', 'v', 'i', 'f'),
|
||||
KEY_HDR_INFO = FOURCC_META('h', 'd', 'r', ' '),
|
||||
KEY_HDR_META_OFFSET = FOURCC_META('h', 'd', 'r', 'o'),
|
||||
KEY_HDR_META_SIZE = FOURCC_META('h', 'd', 'r', 'l'),
|
||||
|
||||
/* flow control key */
|
||||
KEY_INPUT_BLOCK = FOURCC_META('i', 'b', 'l', 'k'),
|
||||
KEY_OUTPUT_BLOCK = FOURCC_META('o', 'b', 'l', 'k'),
|
||||
KEY_INPUT_IDR_REQ = FOURCC_META('i', 'i', 'd', 'r'), /* input idr frame request flag */
|
||||
KEY_OUTPUT_INTRA = FOURCC_META('o', 'i', 'd', 'r'), /* output intra frame indicator */
|
||||
|
||||
/* mpp_frame / mpp_packet meta data info key */
|
||||
KEY_TEMPORAL_ID = FOURCC_META('t', 'l', 'i', 'd'),
|
||||
KEY_LONG_REF_IDX = FOURCC_META('l', 't', 'i', 'd'),
|
||||
KEY_ENC_AVERAGE_QP = FOURCC_META('a', 'v', 'g', 'q'),
|
||||
KEY_ENC_START_QP = FOURCC_META('s', 't', 'r', 'q'),
|
||||
KEY_ROI_DATA = FOURCC_META('r', 'o', 'i', ' '),
|
||||
KEY_OSD_DATA = FOURCC_META('o', 's', 'd', ' '),
|
||||
KEY_OSD_DATA2 = FOURCC_META('o', 's', 'd', '2'),
|
||||
KEY_USER_DATA = FOURCC_META('u', 's', 'r', 'd'),
|
||||
KEY_USER_DATAS = FOURCC_META('u', 'r', 'd', 's'),
|
||||
|
||||
/* num of inter different size predicted block */
|
||||
KEY_LVL64_INTER_NUM = FOURCC_META('l', '6', '4', 'p'),
|
||||
KEY_LVL32_INTER_NUM = FOURCC_META('l', '3', '2', 'p'),
|
||||
KEY_LVL16_INTER_NUM = FOURCC_META('l', '1', '6', 'p'),
|
||||
KEY_LVL8_INTER_NUM = FOURCC_META('l', '8', 'p', ' '),
|
||||
/* num of intra different size predicted block */
|
||||
KEY_LVL32_INTRA_NUM = FOURCC_META('l', '3', '2', 'i'),
|
||||
KEY_LVL16_INTRA_NUM = FOURCC_META('l', '1', '6', 'i'),
|
||||
KEY_LVL8_INTRA_NUM = FOURCC_META('l', '8', 'i', ' '),
|
||||
KEY_LVL4_INTRA_NUM = FOURCC_META('l', '4', 'i', ' '),
|
||||
/* output P skip frame indicator */
|
||||
KEY_OUTPUT_PSKIP = FOURCC_META('o', 'p', 's', 'p'),
|
||||
KEY_ENC_SSE = FOURCC_META('e', 's', 's', 'e'),
|
||||
|
||||
/*
|
||||
* For vepu580 roi buffer config mode
|
||||
* The encoder roi structure is so complex that we should provide a buffer
|
||||
* tunnel for externl user to config encoder hardware by direct sending
|
||||
* roi data buffer.
|
||||
* This way can reduce the config parsing and roi buffer data generating
|
||||
* overhead in mpp.
|
||||
*/
|
||||
KEY_ROI_DATA2 = FOURCC_META('r', 'o', 'i', '2'),
|
||||
|
||||
/*
|
||||
* qpmap for rv1109/1126 encoder qpmap config
|
||||
* Input data is a MppBuffer which contains an array of 16bit Vepu541RoiCfg.
|
||||
* And each 16bit represents a 16x16 block qp info.
|
||||
*
|
||||
* H.264 - 16x16 block qp is arranged in raster order:
|
||||
* each value is a 16bit data
|
||||
* 00 01 02 03 04 05 06 07 -> 00 01 02 03 04 05 06 07
|
||||
* 10 11 12 13 14 15 16 17 10 11 12 13 14 15 16 17
|
||||
* 20 21 22 23 24 25 26 27 20 21 22 23 24 25 26 27
|
||||
* 30 31 32 33 34 35 36 37 30 31 32 33 34 35 36 37
|
||||
*
|
||||
* H.265 - 16x16 block qp is reorder to 64x64/32x32 ctu order then 64x64 / 32x32 ctu raster order
|
||||
* 64x64 ctu
|
||||
* 00 01 02 03 04 05 06 07 -> 00 01 02 03 10 11 12 13 20 21 22 23 30 31 32 33 04 05 06 07 14 15 16 17 24 25 26 27 34 35 36 37
|
||||
* 10 11 12 13 14 15 16 17
|
||||
* 20 21 22 23 24 25 26 27
|
||||
* 30 31 32 33 34 35 36 37
|
||||
* 32x32 ctu
|
||||
* 00 01 02 03 04 05 06 07 -> 00 01 10 11 02 03 12 13 04 05 14 15 06 07 16 17
|
||||
* 10 11 12 13 14 15 16 17 20 21 30 31 22 23 32 33 24 25 34 35 26 27 36 37
|
||||
* 20 21 22 23 24 25 26 27
|
||||
* 30 31 32 33 34 35 36 37
|
||||
*/
|
||||
KEY_QPMAP0 = FOURCC_META('e', 'q', 'm', '0'),
|
||||
|
||||
/* input motion list for smart p rate control */
|
||||
KEY_MV_LIST = FOURCC_META('m', 'v', 'l', 't'),
|
||||
|
||||
/* frame long-term reference frame operation */
|
||||
KEY_ENC_MARK_LTR = FOURCC_META('m', 'l', 't', 'r'),
|
||||
KEY_ENC_USE_LTR = FOURCC_META('u', 'l', 't', 'r'),
|
||||
|
||||
/* MLVEC specified encoder feature */
|
||||
KEY_ENC_FRAME_QP = FOURCC_META('f', 'r', 'm', 'q'),
|
||||
KEY_ENC_BASE_LAYER_PID = FOURCC_META('b', 'p', 'i', 'd'),
|
||||
|
||||
/* Thumbnail info for decoder output frame */
|
||||
KEY_DEC_TBN_EN = FOURCC_META('t', 'b', 'e', 'n'),
|
||||
KEY_DEC_TBN_Y_OFFSET = FOURCC_META('t', 'b', 'y', 'o'),
|
||||
KEY_DEC_TBN_UV_OFFSET = FOURCC_META('t', 'b', 'c', 'o'),
|
||||
} MppMetaKey;
|
||||
|
||||
#define mpp_meta_get(meta) mpp_meta_get_with_tag(meta, MODULE_TAG, __FUNCTION__)
|
||||
|
||||
#include "mpp_frame.h"
|
||||
#include "mpp_packet.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
MPP_RET mpp_meta_get_with_tag(MppMeta *meta, const char *tag, const char *caller);
|
||||
MPP_RET mpp_meta_put(MppMeta meta);
|
||||
RK_S32 mpp_meta_size(MppMeta meta);
|
||||
|
||||
MPP_RET mpp_meta_set_s32(MppMeta meta, MppMetaKey key, RK_S32 val);
|
||||
MPP_RET mpp_meta_set_s64(MppMeta meta, MppMetaKey key, RK_S64 val);
|
||||
MPP_RET mpp_meta_set_ptr(MppMeta meta, MppMetaKey key, void *val);
|
||||
MPP_RET mpp_meta_get_s32(MppMeta meta, MppMetaKey key, RK_S32 *val);
|
||||
MPP_RET mpp_meta_get_s64(MppMeta meta, MppMetaKey key, RK_S64 *val);
|
||||
MPP_RET mpp_meta_get_ptr(MppMeta meta, MppMetaKey key, void **val);
|
||||
|
||||
MPP_RET mpp_meta_set_frame (MppMeta meta, MppMetaKey key, MppFrame frame);
|
||||
MPP_RET mpp_meta_set_packet(MppMeta meta, MppMetaKey key, MppPacket packet);
|
||||
MPP_RET mpp_meta_set_buffer(MppMeta meta, MppMetaKey key, MppBuffer buffer);
|
||||
MPP_RET mpp_meta_get_frame (MppMeta meta, MppMetaKey key, MppFrame *frame);
|
||||
MPP_RET mpp_meta_get_packet(MppMeta meta, MppMetaKey key, MppPacket *packet);
|
||||
MPP_RET mpp_meta_get_buffer(MppMeta meta, MppMetaKey key, MppBuffer *buffer);
|
||||
|
||||
MPP_RET mpp_meta_get_s32_d(MppMeta meta, MppMetaKey key, RK_S32 *val, RK_S32 def);
|
||||
MPP_RET mpp_meta_get_s64_d(MppMeta meta, MppMetaKey key, RK_S64 *val, RK_S64 def);
|
||||
MPP_RET mpp_meta_get_ptr_d(MppMeta meta, MppMetaKey key, void **val, void *def);
|
||||
MPP_RET mpp_meta_get_frame_d(MppMeta meta, MppMetaKey key, MppFrame *frame, MppFrame def);
|
||||
MPP_RET mpp_meta_get_packet_d(MppMeta meta, MppMetaKey key, MppPacket *packet, MppPacket def);
|
||||
MPP_RET mpp_meta_get_buffer_d(MppMeta meta, MppMetaKey key, MppBuffer *buffer, MppBuffer def);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*__MPP_META_H__*/
|
@@ -1,117 +0,0 @@
|
||||
/*
|
||||
* Copyright 2015 Rockchip Electronics Co. LTD
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __MPP_PACKET_H__
|
||||
#define __MPP_PACKET_H__
|
||||
|
||||
#include "mpp_meta.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* MppPacket interface
|
||||
*
|
||||
* mpp_packet_init = mpp_packet_new + mpp_packet_set_data + mpp_packet_set_size
|
||||
* mpp_packet_copy_init = mpp_packet_init + memcpy
|
||||
*/
|
||||
MPP_RET mpp_packet_new(MppPacket *packet);
|
||||
MPP_RET mpp_packet_init(MppPacket *packet, void *data, size_t size);
|
||||
MPP_RET mpp_packet_init_with_buffer(MppPacket *packet, MppBuffer buffer);
|
||||
MPP_RET mpp_packet_copy_init(MppPacket *packet, const MppPacket src);
|
||||
MPP_RET mpp_packet_deinit(MppPacket *packet);
|
||||
|
||||
/*
|
||||
* data : ( R/W ) start address of the whole packet memory
|
||||
* size : ( R/W ) total size of the whole packet memory
|
||||
* pos : ( R/W ) current access position of the whole packet memory, used for buffer read/write
|
||||
* length : ( R/W ) the rest length from current position to end of buffer
|
||||
* NOTE: normally length is updated only by set_pos,
|
||||
* so set length must be used carefully for special usage
|
||||
*/
|
||||
void mpp_packet_set_data(MppPacket packet, void *data);
|
||||
void mpp_packet_set_size(MppPacket packet, size_t size);
|
||||
void mpp_packet_set_pos(MppPacket packet, void *pos);
|
||||
void mpp_packet_set_length(MppPacket packet, size_t size);
|
||||
|
||||
void* mpp_packet_get_data(const MppPacket packet);
|
||||
void* mpp_packet_get_pos(const MppPacket packet);
|
||||
size_t mpp_packet_get_size(const MppPacket packet);
|
||||
size_t mpp_packet_get_length(const MppPacket packet);
|
||||
|
||||
|
||||
void mpp_packet_set_pts(MppPacket packet, RK_S64 pts);
|
||||
RK_S64 mpp_packet_get_pts(const MppPacket packet);
|
||||
void mpp_packet_set_dts(MppPacket packet, RK_S64 dts);
|
||||
RK_S64 mpp_packet_get_dts(const MppPacket packet);
|
||||
|
||||
void mpp_packet_set_flag(MppPacket packet, RK_U32 flag);
|
||||
RK_U32 mpp_packet_get_flag(const MppPacket packet);
|
||||
|
||||
MPP_RET mpp_packet_set_eos(MppPacket packet);
|
||||
MPP_RET mpp_packet_clr_eos(MppPacket packet);
|
||||
RK_U32 mpp_packet_get_eos(MppPacket packet);
|
||||
MPP_RET mpp_packet_set_extra_data(MppPacket packet);
|
||||
|
||||
void mpp_packet_set_buffer(MppPacket packet, MppBuffer buffer);
|
||||
MppBuffer mpp_packet_get_buffer(const MppPacket packet);
|
||||
|
||||
/*
|
||||
* data access interface
|
||||
*/
|
||||
MPP_RET mpp_packet_read(MppPacket packet, size_t offset, void *data, size_t size);
|
||||
MPP_RET mpp_packet_write(MppPacket packet, size_t offset, void *data, size_t size);
|
||||
|
||||
/*
|
||||
* meta data access interface
|
||||
*/
|
||||
RK_S32 mpp_packet_has_meta(const MppPacket packet);
|
||||
MppMeta mpp_packet_get_meta(const MppPacket packet);
|
||||
|
||||
/*
|
||||
* multi packet sequence interface for slice/split encoding/decoding
|
||||
* partition - the packet is a part of a while image
|
||||
* soi - Start Of Image
|
||||
* eoi - End Of Image
|
||||
*/
|
||||
RK_U32 mpp_packet_is_partition(const MppPacket packet);
|
||||
RK_U32 mpp_packet_is_soi(const MppPacket packet);
|
||||
RK_U32 mpp_packet_is_eoi(const MppPacket packet);
|
||||
|
||||
/*
|
||||
* packet segement pack info for
|
||||
* segment number - number of segment
|
||||
* segment info - base address of segment info
|
||||
*/
|
||||
typedef struct MppPktSeg_t MppPktSeg;
|
||||
|
||||
struct MppPktSeg_t {
|
||||
RK_S32 index;
|
||||
RK_S32 type;
|
||||
RK_U32 offset;
|
||||
RK_U32 len;
|
||||
const MppPktSeg *next;
|
||||
};
|
||||
|
||||
RK_U32 mpp_packet_get_segment_nb(const MppPacket packet);
|
||||
const MppPktSeg *mpp_packet_get_segment_info(const MppPacket packet);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*__MPP_PACKET_H__*/
|
@@ -1,263 +0,0 @@
|
||||
/*
|
||||
* Copyright 2016 Rockchip Electronics Co. LTD
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __MPP_RC_API_H__
|
||||
#define __MPP_RC_API_H__
|
||||
|
||||
#include "mpp_err.h"
|
||||
#include "rk_venc_rc.h"
|
||||
#include "mpp_rc_defs.h"
|
||||
|
||||
/*
|
||||
* Mpp rate control has three parts:
|
||||
*
|
||||
* 1. MPI user config module
|
||||
* MppEncRcCfg structure is provided to user for overall rate control config
|
||||
* Mpp will receive MppEncRcCfg from user, check parameter and set it to
|
||||
* encoder.
|
||||
*
|
||||
* 2. Encoder rate control module
|
||||
* Encoder will implement the rate control strategy required by users
|
||||
* including CBR, VBR, AVBR and so on.
|
||||
* This module only implement the target bit calculation behavior and
|
||||
* quality restriction. And the quality level will be controlled by hal.
|
||||
*
|
||||
* 3. Hal rate control module
|
||||
* Hal will implement the rate control on hardware. Hal will calculate the
|
||||
* QP parameter for hardware according to the frame level target bit
|
||||
* specified by the encoder. And the report the real bitrate and quality to
|
||||
* encoder.
|
||||
*
|
||||
* The header defines the communication interfaces and structures used between
|
||||
* MPI, encoder and hal.
|
||||
*/
|
||||
|
||||
typedef enum RcMode_e {
|
||||
RC_VBR,
|
||||
RC_CBR,
|
||||
RC_FIXQP,
|
||||
RC_AVBR,
|
||||
RC_CVBR,
|
||||
RC_QVBR,
|
||||
RC_LEARNING,
|
||||
RC_MODE_BUTT,
|
||||
} RcMode;
|
||||
|
||||
typedef enum GopMode_e {
|
||||
NORMAL_P,
|
||||
SMART_P,
|
||||
} GopMode;
|
||||
|
||||
/*
|
||||
* frame rate parameters have great effect on rate control
|
||||
*
|
||||
* fps_in_flex
|
||||
* 0 - fix input frame rate
|
||||
* 1 - variable input frame rate
|
||||
*
|
||||
* fps_in_num
|
||||
* input frame rate numerator, if 0 then default 30
|
||||
*
|
||||
* fps_in_denom
|
||||
* input frame rate denominator, if 0 then default 1
|
||||
*
|
||||
* fps_out_flex
|
||||
* 0 - fix output frame rate
|
||||
* 1 - variable output frame rate
|
||||
*
|
||||
* fps_out_num
|
||||
* output frame rate numerator, if 0 then default 30
|
||||
*
|
||||
* fps_out_denom
|
||||
* output frame rate denominator, if 0 then default 1
|
||||
*/
|
||||
typedef struct RcFpsCfg_t {
|
||||
RK_S32 fps_in_flex;
|
||||
RK_S32 fps_in_num;
|
||||
RK_S32 fps_in_denom;
|
||||
RK_S32 fps_out_flex;
|
||||
RK_S32 fps_out_num;
|
||||
RK_S32 fps_out_denom;
|
||||
} RcFpsCfg;
|
||||
|
||||
typedef struct RcSuperframeCfg_t {
|
||||
MppEncRcSuperFrameMode super_mode;
|
||||
RK_U32 super_i_thd;
|
||||
RK_U32 super_p_thd;
|
||||
MppEncRcPriority rc_priority;
|
||||
} RcSuperframeCfg;
|
||||
|
||||
typedef struct RcDebreathCfg_t {
|
||||
RK_U32 enable;
|
||||
RK_U32 strength;
|
||||
} RcDebreathCfg;
|
||||
|
||||
typedef struct RcHierQPCfg_t {
|
||||
RK_S32 hier_qp_en;
|
||||
RK_S32 hier_qp_delta[4];
|
||||
RK_S32 hier_frame_num[4];
|
||||
} RcHierQPCfg;
|
||||
|
||||
/*
|
||||
* Control parameter from external config
|
||||
*
|
||||
* It will be updated on rc/prep/gopref config changed.
|
||||
*/
|
||||
typedef struct RcCfg_s {
|
||||
/* encode image size */
|
||||
RK_S32 width;
|
||||
RK_S32 height;
|
||||
|
||||
/* Use rc_mode to find different api */
|
||||
RcMode mode;
|
||||
|
||||
RcFpsCfg fps;
|
||||
|
||||
GopMode gop_mode;
|
||||
/* I frame gop len */
|
||||
RK_S32 igop;
|
||||
/* visual gop len */
|
||||
RK_S32 vgop;
|
||||
|
||||
/* bitrate parameter */
|
||||
RK_S32 bps_min;
|
||||
RK_S32 bps_target;
|
||||
RK_S32 bps_max;
|
||||
RK_S32 stats_time;
|
||||
|
||||
/* max I frame bit ratio to P frame bit */
|
||||
RK_S32 max_i_bit_prop;
|
||||
RK_S32 min_i_bit_prop;
|
||||
RK_S32 init_ip_ratio;
|
||||
/* layer bitrate proportion */
|
||||
RK_S32 layer_bit_prop[4];
|
||||
|
||||
/* quality parameter */
|
||||
RK_S32 init_quality;
|
||||
RK_S32 max_quality;
|
||||
RK_S32 min_quality;
|
||||
RK_S32 max_i_quality;
|
||||
RK_S32 min_i_quality;
|
||||
RK_S32 i_quality_delta;
|
||||
RK_S32 vi_quality_delta;
|
||||
RK_S32 fqp_min_i;
|
||||
RK_S32 fqp_min_p;
|
||||
RK_S32 fqp_max_i;
|
||||
RK_S32 fqp_max_p;
|
||||
/* layer quality proportion */
|
||||
RK_S32 layer_quality_delta[4];
|
||||
|
||||
/* reencode parameter */
|
||||
RK_S32 max_reencode_times;
|
||||
|
||||
/* still / motion desision parameter */
|
||||
RK_S32 min_still_prop;
|
||||
RK_S32 max_still_quality;
|
||||
|
||||
/*
|
||||
* vbr parameter
|
||||
*
|
||||
* vbr_hi_prop - high proportion bitrate for reduce quality
|
||||
* vbr_lo_prop - low proportion bitrate for increase quality
|
||||
*/
|
||||
RK_S32 vbr_hi_prop;
|
||||
RK_S32 vbr_lo_prop;
|
||||
|
||||
MppEncRcDropFrmMode drop_mode;
|
||||
RK_U32 drop_thd;
|
||||
RK_U32 drop_gap;
|
||||
|
||||
RcSuperframeCfg super_cfg;
|
||||
RcDebreathCfg debreath_cfg;
|
||||
RcHierQPCfg hier_qp_cfg;
|
||||
RK_U32 refresh_len;
|
||||
RK_S32 scene_mode;
|
||||
RK_U32 fps_chg_prop;
|
||||
} RcCfg;
|
||||
|
||||
/*
|
||||
* Different rate control strategy will be implemented by different API config
|
||||
*/
|
||||
typedef struct RcImplApi_t {
|
||||
char *name;
|
||||
MppCodingType type;
|
||||
RK_U32 ctx_size;
|
||||
|
||||
MPP_RET (*init)(void *ctx, RcCfg *cfg);
|
||||
MPP_RET (*deinit)(void *ctx);
|
||||
|
||||
MPP_RET (*check_drop)(void *ctx, EncRcTask *task);
|
||||
MPP_RET (*check_reenc)(void *ctx, EncRcTask *task);
|
||||
|
||||
/*
|
||||
* frm_start - frame level rate control frm_start.
|
||||
* The EncRcTaskInfo will be output to hal for hardware to implement.
|
||||
* frm_end - frame level rate control frm_end.
|
||||
* The EncRcTaskInfo is returned for real quality and bitrate.
|
||||
*/
|
||||
MPP_RET (*frm_start)(void *ctx, EncRcTask *task);
|
||||
MPP_RET (*frm_end)(void *ctx, EncRcTask *task);
|
||||
|
||||
/*
|
||||
* hal_start - hardware level rate control start.
|
||||
* The EncRcTaskInfo will be output to hal for hardware to implement.
|
||||
* hal_end - hardware level rate control end.
|
||||
* The EncRcTaskInfo is returned for real quality and bitrate.
|
||||
*/
|
||||
MPP_RET (*hal_start)(void *ctx, EncRcTask *task);
|
||||
MPP_RET (*hal_end)(void *ctx, EncRcTask *task);
|
||||
} RcImplApi;
|
||||
|
||||
/*
|
||||
* structures for RC API register and query
|
||||
*/
|
||||
typedef struct RcApiBrief_t {
|
||||
const char *name;
|
||||
MppCodingType type;
|
||||
} RcApiBrief;
|
||||
|
||||
typedef struct RcApiQueryAll_t {
|
||||
/* input param for query */
|
||||
RcApiBrief *brief;
|
||||
RK_S32 max_count;
|
||||
|
||||
/* output query count */
|
||||
RK_S32 count;
|
||||
} RcApiQueryAll;
|
||||
|
||||
typedef struct RcApiQueryType_t {
|
||||
/* input param for query */
|
||||
RcApiBrief *brief;
|
||||
RK_S32 max_count;
|
||||
MppCodingType type;
|
||||
|
||||
/* output query count */
|
||||
RK_S32 count;
|
||||
} RcApiQueryType;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
MPP_RET rc_api_add(const RcImplApi *api);
|
||||
MPP_RET rc_brief_get_all(RcApiQueryAll *query);
|
||||
MPP_RET rc_brief_get_by_type(RcApiQueryType *query);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __MPP_RC_API_H__ */
|
@@ -1,223 +0,0 @@
|
||||
/*
|
||||
* Copyright 2016 Rockchip Electronics Co. LTD
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __MPP_RC_DEFS_H__
|
||||
#define __MPP_RC_DEFS_H__
|
||||
|
||||
#include "rk_venc_ref.h"
|
||||
|
||||
#define MAX_CPB_REFS (8)
|
||||
|
||||
typedef enum EncFrmType_e {
|
||||
INTER_P_FRAME = 0,
|
||||
INTER_B_FRAME = 1,
|
||||
INTRA_FRAME = 2,
|
||||
INTER_VI_FRAME = 3,
|
||||
INTRA_RFH_FRAME = 4,
|
||||
} EncFrmType;
|
||||
|
||||
/*
|
||||
* EncFrmStatus controls record the encoding frame status and also control
|
||||
* work flow of encoder. It is the communicat channel between encoder implement
|
||||
* module, rate control module and hardware module.
|
||||
*
|
||||
* bit 0 ~ 31 frame status
|
||||
* 0 ~ 15 current frame status
|
||||
* 16 ~ 31 reference frame status
|
||||
* bit 32 ~ 63 encoding flow control
|
||||
*/
|
||||
typedef union EncFrmStatus_u {
|
||||
struct {
|
||||
/*
|
||||
* bit 0 ~ 31 frame status
|
||||
*/
|
||||
/* status flag */
|
||||
RK_U32 valid : 1;
|
||||
/*
|
||||
* 0 - write the reconstructed frame pixel to memory
|
||||
* 1 - do not write the reconstructed frame pixel to memory
|
||||
*/
|
||||
RK_U32 non_recn : 1;
|
||||
|
||||
/*
|
||||
* 0 - normal frame and normal dpb management
|
||||
* 1 - save recon frame as first pass extra frame. Used in two pass mode
|
||||
*/
|
||||
RK_U32 save_pass1 : 1;
|
||||
|
||||
/*
|
||||
* 0 - use normal input source frame as input
|
||||
* 1 - use the previously stored first pass recon frame as input frame
|
||||
*/
|
||||
RK_U32 use_pass1 : 1;
|
||||
|
||||
/* reference status flag */
|
||||
/*
|
||||
* 0 - inter frame
|
||||
* 1 - intra frame
|
||||
*/
|
||||
RK_U32 is_intra : 1;
|
||||
|
||||
/*
|
||||
* Valid when is_intra is true
|
||||
* 0 - normal intra frame
|
||||
* 1 - IDR frame
|
||||
*/
|
||||
RK_U32 is_idr : 1;
|
||||
|
||||
/*
|
||||
* 0 - mark as reference frame
|
||||
* 1 - mark as non-refernce frame
|
||||
*/
|
||||
RK_U32 is_non_ref : 1;
|
||||
|
||||
/*
|
||||
* Valid when is_non_ref is false
|
||||
* 0 - mark as short-term reference frame
|
||||
* 1 - mark as long-term refernce frame
|
||||
*/
|
||||
RK_U32 is_lt_ref : 1;
|
||||
|
||||
/* bit 8 - 15 */
|
||||
RK_U32 lt_idx : 4;
|
||||
RK_U32 temporal_id : 4;
|
||||
|
||||
/* distance between current frame and reference frame */
|
||||
MppEncRefMode ref_mode : 6;
|
||||
RK_S32 ref_arg : 8;
|
||||
RK_S32 ref_dist : 2;
|
||||
|
||||
/*
|
||||
* bit 32 ~ 63 encoder flow control flags
|
||||
*/
|
||||
/*
|
||||
* 0 - normal frame encoding
|
||||
* 1 - current frame will be dropped
|
||||
*/
|
||||
RK_U32 drop : 1;
|
||||
|
||||
/*
|
||||
* 0 - rate control module does not change frame type parameter
|
||||
* 1 - rate control module changes frame type parameter reencode is needed
|
||||
* to reprocess the dpb process. Also this means dpb module will follow
|
||||
* the frame status parameter provided by rate control module.
|
||||
*/
|
||||
RK_U32 re_dpb_proc : 1;
|
||||
|
||||
/*
|
||||
* 0 - current frame encoding is in normal flow
|
||||
* 1 - current frame encoding is in reencode flow
|
||||
*/
|
||||
RK_U32 reencode : 1;
|
||||
|
||||
/*
|
||||
* When true current frame size is super large then the frame should be reencoded.
|
||||
*/
|
||||
RK_U32 super_frame : 1;
|
||||
|
||||
/*
|
||||
* When true currnet frame is force to encoded as software skip frame
|
||||
*/
|
||||
RK_U32 force_pskip : 1;
|
||||
|
||||
/*
|
||||
* Current frame is intra refresh frame
|
||||
*/
|
||||
RK_U32 is_i_refresh : 1;
|
||||
/*
|
||||
* Current frame needs add recovery point prefix
|
||||
*/
|
||||
RK_U32 is_i_recovery : 1;
|
||||
RK_U32 reserved1 : 1;
|
||||
|
||||
/* reencode times */
|
||||
RK_U32 reencode_times : 8;
|
||||
|
||||
/* sequential index for each frame */
|
||||
RK_U32 seq_idx : 16;
|
||||
};
|
||||
RK_U64 val;
|
||||
} EncFrmStatus;
|
||||
|
||||
typedef struct EncCpbStatus_t {
|
||||
RK_S32 seq_idx;
|
||||
|
||||
EncFrmStatus curr;
|
||||
EncFrmStatus refr;
|
||||
|
||||
/* initial cpb status for current frame encoding */
|
||||
EncFrmStatus init[MAX_CPB_REFS];
|
||||
/* final cpb status after current frame encoding */
|
||||
EncFrmStatus final[MAX_CPB_REFS];
|
||||
} EncCpbStatus;
|
||||
|
||||
#define ENC_RC_FORCE_QP (0x00000001)
|
||||
|
||||
typedef struct EncRcForceCfg_t {
|
||||
RK_U32 force_flag;
|
||||
RK_S32 force_qp;
|
||||
RK_U32 reserve[6];
|
||||
} EncRcForceCfg;
|
||||
|
||||
/*
|
||||
* communication channel between rc / hal / hardware
|
||||
*
|
||||
* rc -> hal bit_target / bit_max / bit_min
|
||||
* hal -> hw quality_target / quality_max / quality_min
|
||||
* hw -> rc / hal bit_real / quality_real / madi / madp
|
||||
*/
|
||||
typedef struct EncRcCommonInfo_t {
|
||||
EncFrmType frame_type;
|
||||
|
||||
/* rc to hal */
|
||||
RK_S32 bit_target;
|
||||
RK_S32 bit_max;
|
||||
RK_S32 bit_min;
|
||||
|
||||
RK_S32 quality_target;
|
||||
RK_S32 quality_max;
|
||||
RK_S32 quality_min;
|
||||
|
||||
/* rc from hardware */
|
||||
RK_S32 bit_real;
|
||||
RK_S32 quality_real;
|
||||
RK_S32 madi;
|
||||
RK_S32 madp;
|
||||
|
||||
RK_U32 iblk4_prop; // scale 256
|
||||
|
||||
RK_S64 sse;
|
||||
RK_U32 lvl64_inter_num;
|
||||
RK_U32 lvl32_inter_num;
|
||||
RK_U32 lvl16_inter_num;
|
||||
RK_U32 lvl8_inter_num;
|
||||
RK_U32 lvl32_intra_num;
|
||||
RK_U32 lvl16_intra_num;
|
||||
RK_U32 lvl8_intra_num;
|
||||
RK_U32 lvl4_intra_num;
|
||||
|
||||
RK_S32 reserve[5];
|
||||
} EncRcTaskInfo;
|
||||
|
||||
typedef struct EncRcTask_s {
|
||||
EncCpbStatus cpb;
|
||||
EncFrmStatus frm;
|
||||
EncRcTaskInfo info;
|
||||
EncRcForceCfg force;
|
||||
MppFrame frame;
|
||||
} EncRcTask;
|
||||
|
||||
#endif /* __MPP_RC_DEFS_H__ */
|
@@ -1,237 +0,0 @@
|
||||
/*
|
||||
* Copyright 2015 Rockchip Electronics Co. LTD
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __MPP_TASK_H__
|
||||
#define __MPP_TASK_H__
|
||||
|
||||
#include "mpp_meta.h"
|
||||
|
||||
/*
|
||||
* Advanced task flow
|
||||
* Advanced task flow introduces three concepts: port, task and item
|
||||
*
|
||||
* Port is from OpenMAX
|
||||
* Port has two type: input port and output port which are all for data transaction.
|
||||
* Port work like a queue. task will be dequeue from or enqueue to one port.
|
||||
* On input side user will dequeue task from input port, setup task and enqueue task
|
||||
* back to input port.
|
||||
* On output side user will dequeue task from output port, get the information from
|
||||
* and then enqueue task back to output port.
|
||||
*
|
||||
* Task indicates one transaction on the port.
|
||||
* Task has two working mode: async mode and sync mode
|
||||
* If mpp is work in sync mode on task enqueue function return the task has been done
|
||||
* If mpp is work in async mode on task enqueue function return the task is just put
|
||||
* on the task queue for process.
|
||||
* Task can carry different items. Task just like a container of items
|
||||
*
|
||||
* Item indicates MppPacket or MppFrame which is contained in one task
|
||||
*/
|
||||
|
||||
/*
|
||||
* One mpp task queue has two ports: input and output
|
||||
*
|
||||
* The whole picture is:
|
||||
* Top layer mpp has two ports: mpp_input_port and mpp_output_port
|
||||
* But internally these two ports belongs to two task queue.
|
||||
* The mpp_input_port is the mpp_input_task_queue's input port.
|
||||
* The mpp_output_port is the mpp_output_task_queue's output port.
|
||||
*
|
||||
* Each port uses its task queue to communication
|
||||
*/
|
||||
typedef enum {
|
||||
MPP_PORT_INPUT,
|
||||
MPP_PORT_OUTPUT,
|
||||
MPP_PORT_BUTT,
|
||||
} MppPortType;
|
||||
|
||||
/*
|
||||
* Advance task work flow mode:
|
||||
******************************************************************************
|
||||
* 1. async mode (default_val)
|
||||
*
|
||||
* mpp_init(type, coding, MPP_WORK_ASYNC)
|
||||
*
|
||||
* input thread
|
||||
* a - poll(input)
|
||||
* b - dequeue(input, *task)
|
||||
* c - task_set_item(packet/frame)
|
||||
* d - enqueue(input, task) // when enqueue return the task is not done yet
|
||||
*
|
||||
* output thread
|
||||
* a - poll(output)
|
||||
* b - dequeue(output, *task)
|
||||
* c - task_get_item(frame/packet)
|
||||
* d - enqueue(output, task)
|
||||
******************************************************************************
|
||||
* 2. sync mode
|
||||
*
|
||||
* mpp_init(type, coding, MPP_WORK_SYNC)
|
||||
*
|
||||
* a - poll(input)
|
||||
* b - dequeue(input, *task)
|
||||
* c - task_set_item(packet/frame)
|
||||
* d - enqueue(task) // when enqueue return the task is finished
|
||||
******************************************************************************
|
||||
*/
|
||||
typedef enum {
|
||||
MPP_TASK_ASYNC,
|
||||
MPP_TASK_SYNC,
|
||||
MPP_TASK_WORK_MODE_BUTT,
|
||||
} MppTaskWorkMode;
|
||||
|
||||
/*
|
||||
* Mpp port poll type
|
||||
*
|
||||
* MPP_POLL_BLOCK - for block poll
|
||||
* MPP_POLL_NON_BLOCK - for non-block poll
|
||||
* small than MPP_POLL_MAX - for poll with timeout in ms
|
||||
* small than MPP_POLL_BUTT or larger than MPP_POLL_MAX is invalid value
|
||||
*/
|
||||
typedef enum {
|
||||
MPP_POLL_BUTT = -2,
|
||||
MPP_POLL_BLOCK = -1,
|
||||
MPP_POLL_NON_BLOCK = 0,
|
||||
MPP_POLL_MAX = 8000,
|
||||
} MppPollType;
|
||||
|
||||
/*
|
||||
* Mpp timeout define
|
||||
* MPP_TIMEOUT_BLOCK - for block poll
|
||||
* MPP_TIMEOUT_NON_BLOCK - for non-block poll
|
||||
* small than MPP_TIMEOUT_MAX - for poll with timeout in ms
|
||||
* small than MPP_TIMEOUT_BUTT or larger than MPP_TIMEOUT_MAX is invalid value
|
||||
*/
|
||||
#define MPP_TIMEOUT_BUTT (-2L)
|
||||
#define MPP_TIMEOUT_BLOCK (-1L)
|
||||
#define MPP_TIMEOUT_NON_BLOCK (0L)
|
||||
#define MPP_TIMEOUT_MAX (8000L)
|
||||
|
||||
/*
|
||||
* MppTask is descriptor of a task which send to mpp for process
|
||||
* mpp can support different type of work mode, for example:
|
||||
*
|
||||
* decoder:
|
||||
*
|
||||
* 1. typical decoder mode:
|
||||
* input - MppPacket (normal cpu buffer, need cpu copy)
|
||||
* output - MppFrame (ion/drm buffer in external/internal mode)
|
||||
* 2. secure decoder mode:
|
||||
* input - MppPacket (externel ion/drm buffer, cpu can not access)
|
||||
* output - MppFrame (ion/drm buffer in external/internal mode, cpu can not access)
|
||||
*
|
||||
* interface usage:
|
||||
*
|
||||
* typical flow
|
||||
* input side:
|
||||
* task_dequeue(ctx, PORT_INPUT, &task);
|
||||
* task_put_item(task, MODE_INPUT, packet)
|
||||
* task_enqueue(ctx, PORT_INPUT, task);
|
||||
* output side:
|
||||
* task_dequeue(ctx, PORT_OUTPUT, &task);
|
||||
* task_get_item(task, MODE_OUTPUT, &frame)
|
||||
* task_enqueue(ctx, PORT_OUTPUT, task);
|
||||
*
|
||||
* secure flow
|
||||
* input side:
|
||||
* task_dequeue(ctx, PORT_INPUT, &task);
|
||||
* task_put_item(task, MODE_INPUT, packet)
|
||||
* task_put_item(task, MODE_OUTPUT, frame) // buffer will be specified here
|
||||
* task_enqueue(ctx, PORT_INPUT, task);
|
||||
* output side:
|
||||
* task_dequeue(ctx, PORT_OUTPUT, &task);
|
||||
* task_get_item(task, MODE_OUTPUT, &frame)
|
||||
* task_enqueue(ctx, PORT_OUTPUT, task);
|
||||
*
|
||||
* encoder:
|
||||
*
|
||||
* 1. typical encoder mode:
|
||||
* input - MppFrame (ion/drm buffer in external mode)
|
||||
* output - MppPacket (normal cpu buffer, need cpu copy)
|
||||
* 2. user input encoder mode:
|
||||
* input - MppFrame (normal cpu buffer, need to build hardware table for this buffer)
|
||||
* output - MppPacket (normal cpu buffer, need cpu copy)
|
||||
* 3. secure encoder mode:
|
||||
* input - MppFrame (ion/drm buffer in external mode, cpu can not access)
|
||||
* output - MppPacket (externel ion/drm buffer, cpu can not access)
|
||||
*
|
||||
* typical / user input flow
|
||||
* input side:
|
||||
* task_dequeue(ctx, PORT_INPUT, &task);
|
||||
* task_put_item(task, MODE_INPUT, frame)
|
||||
* task_enqueue(ctx, PORT_INPUT, task);
|
||||
* output side:
|
||||
* task_dequeue(ctx, PORT_OUTPUT, &task);
|
||||
* task_get_item(task, MODE_OUTPUT, &packet)
|
||||
* task_enqueue(ctx, PORT_OUTPUT, task);
|
||||
*
|
||||
* secure flow
|
||||
* input side:
|
||||
* task_dequeue(ctx, PORT_INPUT, &task);
|
||||
* task_put_item(task, MODE_OUTPUT, packet) // buffer will be specified here
|
||||
* task_put_item(task, MODE_INPUT, frame)
|
||||
* task_enqueue(ctx, PORT_INPUT, task);
|
||||
* output side:
|
||||
* task_dequeue(ctx, PORT_OUTPUT, &task);
|
||||
* task_get_item(task, MODE_OUTPUT, &packet)
|
||||
* task_get_item(task, MODE_OUTPUT, &frame)
|
||||
* task_enqueue(ctx, PORT_OUTPUT, task);
|
||||
*
|
||||
* NOTE: this flow can specify the output frame. User will setup both intput frame and output packet
|
||||
* buffer at the input side. Then at output side when user gets a finished task user can get the output
|
||||
* packet and corresponding released input frame.
|
||||
*
|
||||
* image processing
|
||||
*
|
||||
* 1. typical image process mode:
|
||||
* input - MppFrame (ion/drm buffer in external mode)
|
||||
* output - MppFrame (ion/drm buffer in external mode)
|
||||
*
|
||||
* typical / user input flow
|
||||
* input side:
|
||||
* task_dequeue(ctx, PORT_INPUT, &task);
|
||||
* task_put_item(task, MODE_INPUT, frame)
|
||||
* task_enqueue(ctx, PORT_INPUT, task);
|
||||
* output side:
|
||||
* task_dequeue(ctx, PORT_OUTPUT, &task);
|
||||
* task_get_item(task, MODE_OUTPUT, &frame)
|
||||
* task_enqueue(ctx, PORT_OUTPUT, task);
|
||||
*/
|
||||
/* NOTE: use index rather then handle to descripbe task */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
MPP_RET mpp_task_meta_set_s32(MppTask task, MppMetaKey key, RK_S32 val);
|
||||
MPP_RET mpp_task_meta_set_s64(MppTask task, MppMetaKey key, RK_S64 val);
|
||||
MPP_RET mpp_task_meta_set_ptr(MppTask task, MppMetaKey key, void *val);
|
||||
MPP_RET mpp_task_meta_set_frame (MppTask task, MppMetaKey key, MppFrame frame);
|
||||
MPP_RET mpp_task_meta_set_packet(MppTask task, MppMetaKey key, MppPacket packet);
|
||||
MPP_RET mpp_task_meta_set_buffer(MppTask task, MppMetaKey key, MppBuffer buffer);
|
||||
|
||||
MPP_RET mpp_task_meta_get_s32(MppTask task, MppMetaKey key, RK_S32 *val, RK_S32 default_val);
|
||||
MPP_RET mpp_task_meta_get_s64(MppTask task, MppMetaKey key, RK_S64 *val, RK_S64 default_val);
|
||||
MPP_RET mpp_task_meta_get_ptr(MppTask task, MppMetaKey key, void **val, void *default_val);
|
||||
MPP_RET mpp_task_meta_get_frame (MppTask task, MppMetaKey key, MppFrame *frame);
|
||||
MPP_RET mpp_task_meta_get_packet(MppTask task, MppMetaKey key, MppPacket *packet);
|
||||
MPP_RET mpp_task_meta_get_buffer(MppTask task, MppMetaKey key, MppBuffer *buffer);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*__MPP_QUEUE_H__*/
|
@@ -1,118 +0,0 @@
|
||||
/*
|
||||
* Copyright 2022 Rockchip Electronics Co. LTD
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __RK_HDR_META_COM_H__
|
||||
#define __RK_HDR_META_COM_H__
|
||||
|
||||
#include "rk_type.h"
|
||||
|
||||
typedef enum HdrCodecType_e {
|
||||
HDR_AVS2 = 0,
|
||||
HDR_HEVC = 1,
|
||||
HDR_H264 = 2,
|
||||
HDR_AV1 = 3,
|
||||
HDR_CODEC_BUT,
|
||||
} HdrCodecType;
|
||||
|
||||
typedef enum HdrFormat_e {
|
||||
HDR_NONE = 0,
|
||||
HDR10 = 1,
|
||||
HLG = 2,
|
||||
// RESERVED3 = 3, //reserved for more future static hdr format
|
||||
// RESERVED4 = 4, //reserved for more future static hdr format
|
||||
HDRVIVID = 5,
|
||||
// RESERVED6 = 6, //reserved for hdr vivid
|
||||
// RESERVED7 = 7, //reserved for hdr vivid
|
||||
HDR10PLUS = 8,
|
||||
// RESERVED9 = 9, //reserved for hdr10+
|
||||
// RESERVED10 = 10,//reserved for hdr10+
|
||||
DOLBY = 11,
|
||||
// RESERVED12 = 12, //reserved for other dynamic hdr format
|
||||
// RESERVED13 = 13, //reserved for other dynamic hdr format
|
||||
HDR_FORMAT_MAX,
|
||||
} HdrFormat;
|
||||
|
||||
typedef enum HdrPayloadFormat_e {
|
||||
STATIC = 0,
|
||||
DYNAMIC = 1,
|
||||
HDR_PAYLOAD_FORMAT_MAX,
|
||||
} HdrPayloadFormat;
|
||||
|
||||
typedef struct HdrStaticMeta_t {
|
||||
RK_U32 color_space;
|
||||
RK_U32 color_primaries;
|
||||
RK_U32 color_trc;
|
||||
RK_U32 red_x;
|
||||
RK_U32 red_y;
|
||||
RK_U32 green_x;
|
||||
RK_U32 green_y;
|
||||
RK_U32 blue_x;
|
||||
RK_U32 blue_y;
|
||||
RK_U32 white_point_x;
|
||||
RK_U32 white_point_y;
|
||||
RK_U32 min_luminance;
|
||||
RK_U32 max_luminance;
|
||||
RK_U32 max_cll;
|
||||
RK_U32 max_fall;
|
||||
RK_U32 reserved[4];
|
||||
} HdrStaticMeta;
|
||||
|
||||
/*
|
||||
* HDR metadata format from codec
|
||||
*
|
||||
* +----------+
|
||||
* | header1 |
|
||||
* +----------+
|
||||
* | |
|
||||
* | payload |
|
||||
* | |
|
||||
* +----------+
|
||||
* | header2 |
|
||||
* +----------+
|
||||
* | |
|
||||
* | payload |
|
||||
* | |
|
||||
* +----------+
|
||||
* | header3 |
|
||||
* +----------+
|
||||
* | |
|
||||
* | payload |
|
||||
* | |
|
||||
* +----------+
|
||||
*/
|
||||
typedef struct RkMetaHdrHeader_t {
|
||||
/* For transmission */
|
||||
RK_U16 magic; /* magic word for checking overwrite error */
|
||||
RK_U16 size; /* total header+payload length including header */
|
||||
RK_U16 message_total; /* total message count in current transmission */
|
||||
RK_U16 message_index; /* current message index in the transmission */
|
||||
|
||||
/* For payload identification */
|
||||
RK_U16 version; /* payload structure version */
|
||||
RK_U16 hdr_format; /* HDR protocol: HDR10, HLG, Dolby, HDRVivid ... */
|
||||
RK_U16 hdr_payload_type; /* HDR data type: static data, dynamic data ... */
|
||||
RK_U16 video_format; /* video format: H.264, H.265, AVS2 ... */
|
||||
|
||||
/* For extenstion usage */
|
||||
RK_U32 reserve[4];
|
||||
|
||||
/* payload data aligned to 32bits */
|
||||
RK_U32 payload[];
|
||||
} RkMetaHdrHeader;
|
||||
|
||||
void fill_hdr_meta_to_frame(MppFrame frame, HdrCodecType codec_type);
|
||||
|
||||
#endif
|
@@ -1,274 +0,0 @@
|
||||
/*
|
||||
* Copyright 2015 Rockchip Electronics Co. LTD
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __RK_MPI_H__
|
||||
#define __RK_MPI_H__
|
||||
|
||||
/**
|
||||
* @addtogroup rk_mpi
|
||||
* @brief Rockchip Media Process Interface
|
||||
* @details Media Process Platform(MPP) provides application programming
|
||||
* interface for the application layer, by which applications can
|
||||
* call hardware encode and decode. Current MPP fully supports
|
||||
* chipset RK3288/RK3228/RK3229/RK3399/RK3328/RV1108. Old chipset
|
||||
* like RK29xx/RK30xx/RK31XX/RK3368 is partly supported due to lack
|
||||
* of some hardware register generation module.
|
||||
*/
|
||||
|
||||
#include "rk_mpi_cmd.h"
|
||||
#include "mpp_task.h"
|
||||
|
||||
/**
|
||||
* @ingroup rk_mpi
|
||||
* @brief MPP main work function set
|
||||
* @details all api function are seperated into two sets: data io api set
|
||||
* and control api set
|
||||
*
|
||||
* (1). the data api set is for data input/output flow including:
|
||||
*
|
||||
* (1.1) simple data api set:
|
||||
*
|
||||
* decode : both send video stream packet to decoder and get video frame from
|
||||
* decoder at the same time.
|
||||
*
|
||||
* encode : both send video frame to encoder and get encoded video stream from
|
||||
* encoder at the same time.
|
||||
*
|
||||
* decode_put_packet: send video stream packet to decoder only, async interface
|
||||
*
|
||||
* decode_get_frame : get video frame from decoder only, async interface
|
||||
*
|
||||
* encode_put_frame : send video frame to encoder only, async interface
|
||||
*
|
||||
* encode_get_packet: get encoded video packet from encoder only, async interface
|
||||
*
|
||||
* (1.2) advanced task api set:
|
||||
*
|
||||
* poll : poll port for dequeue
|
||||
*
|
||||
* dequeue : pop a task from mpp task queue
|
||||
*
|
||||
* enqueue : push a task to mpp task queue
|
||||
*
|
||||
* (2). the control api set is for mpp context control including:
|
||||
*
|
||||
* control : similiar to ioctl in kernel driver, setup or get mpp internal parameter
|
||||
*
|
||||
* reset : clear all data in mpp context, discard all packet and frame,
|
||||
* reset all components to initialized status
|
||||
*/
|
||||
typedef struct MppApi_t {
|
||||
/**
|
||||
* @brief size of struct MppApi
|
||||
*/
|
||||
RK_U32 size;
|
||||
/**
|
||||
* @brief mpp api version, generated by Git
|
||||
*/
|
||||
RK_U32 version;
|
||||
|
||||
// simple data flow interface
|
||||
/**
|
||||
* @brief both send video stream packet to decoder and get video frame from
|
||||
* decoder at the same time
|
||||
* @param[in] ctx The context of mpp, created by mpp_create() and initiated
|
||||
* by mpp_init().
|
||||
* @param[in] packet The input video stream, its usage can refer mpp_packet.h.
|
||||
* @param[out] frame The output picture, its usage can refer mpp_frame.h.
|
||||
* @return 0 and positive for success, negative for failure. The return
|
||||
* value is an error code. For details, please refer mpp_err.h.
|
||||
*/
|
||||
MPP_RET (*decode)(MppCtx ctx, MppPacket packet, MppFrame *frame);
|
||||
/**
|
||||
* @brief send video stream packet to decoder only, async interface
|
||||
* @param[in] ctx The context of mpp, created by mpp_create() and initiated
|
||||
* by mpp_init().
|
||||
* @param[in] packet The input video stream, its usage can refer mpp_packet.h.
|
||||
* @return 0 and positive for success, negative for failure. The return
|
||||
* value is an error code. For details, please refer mpp_err.h.
|
||||
*/
|
||||
MPP_RET (*decode_put_packet)(MppCtx ctx, MppPacket packet);
|
||||
/**
|
||||
* @brief get video frame from decoder only, async interface
|
||||
* @param[in] ctx The context of mpp, created by mpp_create() and initiated
|
||||
* by mpp_init().
|
||||
* @param[out] frame The output picture, its usage can refer mpp_frame.h.
|
||||
* @return 0 and positive for success, negative for failure. The return
|
||||
* value is an error code. For details, please refer mpp_err.h.
|
||||
*/
|
||||
MPP_RET (*decode_get_frame)(MppCtx ctx, MppFrame *frame);
|
||||
/**
|
||||
* @brief both send video frame to encoder and get encoded video stream from
|
||||
* encoder at the same time
|
||||
* @param[in] ctx The context of mpp, created by mpp_create() and initiated
|
||||
* by mpp_init().
|
||||
* @param[in] frame The input video data, its usage can refer mpp_frame.h.
|
||||
* @param[out] packet The output compressed data, its usage can refer mpp_packet.h.
|
||||
* @return 0 and positive for success, negative for failure. The return
|
||||
* value is an error code. For details, please refer mpp_err.h.
|
||||
*/
|
||||
MPP_RET (*encode)(MppCtx ctx, MppFrame frame, MppPacket *packet);
|
||||
/**
|
||||
* @brief send video frame to encoder only, async interface
|
||||
* @param[in] ctx The context of mpp, created by mpp_create() and initiated
|
||||
* by mpp_init().
|
||||
* @param[in] frame The input video data, its usage can refer mpp_frame.h.
|
||||
* @return 0 and positive for success, negative for failure. The return
|
||||
* value is an error code. For details, please refer mpp_err.h.
|
||||
*/
|
||||
MPP_RET (*encode_put_frame)(MppCtx ctx, MppFrame frame);
|
||||
/**
|
||||
* @brief get encoded video packet from encoder only, async interface
|
||||
* @param[in] ctx The context of mpp, created by mpp_create() and initiated
|
||||
* by mpp_init().
|
||||
* @param[out] packet The output compressed data, its usage can refer mpp_packet.h.
|
||||
* @return 0 and positive for success, negative for failure. The return
|
||||
* value is an error code. For details, please refer mpp_err.h.
|
||||
*/
|
||||
MPP_RET (*encode_get_packet)(MppCtx ctx, MppPacket *packet);
|
||||
|
||||
/**
|
||||
* @brief ISP interface, will be supported in the future.
|
||||
*/
|
||||
MPP_RET (*isp)(MppCtx ctx, MppFrame dst, MppFrame src);
|
||||
/**
|
||||
* @brief ISP interface, will be supported in the future.
|
||||
*/
|
||||
MPP_RET (*isp_put_frame)(MppCtx ctx, MppFrame frame);
|
||||
/**
|
||||
* @brief ISP interface, will be supported in the future.
|
||||
*/
|
||||
MPP_RET (*isp_get_frame)(MppCtx ctx, MppFrame *frame);
|
||||
|
||||
// advance data flow interface
|
||||
/**
|
||||
* @brief poll port for dequeue
|
||||
* @param[in] ctx The context of mpp, created by mpp_create() and initiated
|
||||
* by mpp_init().
|
||||
* @param[in] type input port or output port which are both for data transaction
|
||||
* @param[in] timeout mpp poll type, its usage can refer mpp_task.h.
|
||||
* @return 0 and positive for success, negative for failure. The return
|
||||
* value is an error code. For details, please refer mpp_err.h.
|
||||
*/
|
||||
MPP_RET (*poll)(MppCtx ctx, MppPortType type, MppPollType timeout);
|
||||
/**
|
||||
* @brief dequeue MppTask, pop a task from mpp task queue
|
||||
* @param[in] ctx The context of mpp, created by mpp_create() and initiated
|
||||
* by mpp_init().
|
||||
* @param[in] type input port or output port which are both for data transaction
|
||||
* @param[out] task MppTask popped from mpp task queue, its usage can refer mpp_task.h.
|
||||
* @return 0 and positive for success, negative for failure. The return
|
||||
* value is an error code. For details, please refer mpp_err.h.
|
||||
*/
|
||||
MPP_RET (*dequeue)(MppCtx ctx, MppPortType type, MppTask *task);
|
||||
/**
|
||||
* @brief enqueue MppTask, push a task to mpp task queue
|
||||
* @param[in] ctx The context of mpp, created by mpp_create() and initiated
|
||||
* by mpp_init().
|
||||
* @param[in] type input port or output port which are both for data transaction
|
||||
* @param[in] task MppTask which is sent to mpp for process, its usage can refer mpp_task.h.
|
||||
* @return 0 and positive for success, negative for failure. The return
|
||||
* value is an error code. For details, please refer mpp_err.h.
|
||||
*/
|
||||
MPP_RET (*enqueue)(MppCtx ctx, MppPortType type, MppTask task);
|
||||
|
||||
// control interface
|
||||
/**
|
||||
* @brief discard all packet and frame, reset all component,
|
||||
* for both decoder and encoder
|
||||
* @param[in] ctx The context of mpp, created by mpp_create() and initiated
|
||||
* by mpp_init().
|
||||
* @return 0 for success, others for failure. The return value is an
|
||||
* error code. For details, please refer mpp_err.h.
|
||||
*/
|
||||
MPP_RET (*reset)(MppCtx ctx);
|
||||
/**
|
||||
* @brief control function for mpp property setting
|
||||
* @param[in] ctx The context of mpp, created by mpp_create() and initiated
|
||||
* by mpp_init().
|
||||
* @param[in] cmd The mpi command, its definition can refer rk_mpi_cmd.h.
|
||||
* @param[in,out] param The mpi command parameter
|
||||
* @return 0 for success, others for failure. The return value is an
|
||||
* error code. For details, please refer mpp_err.h.
|
||||
*/
|
||||
MPP_RET (*control)(MppCtx ctx, MpiCmd cmd, MppParam param);
|
||||
|
||||
/**
|
||||
* @brief The reserved segment, may be used in the future
|
||||
*/
|
||||
RK_U32 reserv[16];
|
||||
} MppApi;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @ingroup rk_mpi
|
||||
* @brief Create empty context structure and mpi function pointers.
|
||||
* Use functions in MppApi to access mpp services.
|
||||
* @param[in,out] ctx pointer of the mpp context, refer to MpiImpl_t.
|
||||
* @param[in,out] mpi pointer of mpi function, refer to MppApi.
|
||||
* @return 0 for success, others for failure. The return value is an
|
||||
* error code. For details, please refer mpp_err.h.
|
||||
* @note This interface creates base flow context, all function calls
|
||||
* are based on it.
|
||||
*/
|
||||
MPP_RET mpp_create(MppCtx *ctx, MppApi **mpi);
|
||||
/**
|
||||
* @ingroup rk_mpi
|
||||
* @brief Call after mpp_create to setup mpp type and video format.
|
||||
* This function will call internal context init function.
|
||||
* @param[in] ctx The context of mpp, created by mpp_create().
|
||||
* @param[in] type specify decoder or encoder, refer to MppCtxType.
|
||||
* @param[in] coding specify video compression coding, refer to MppCodingType.
|
||||
* @return 0 for success, others for failure. The return value is an
|
||||
* error code. For details, please refer mpp_err.h.
|
||||
*/
|
||||
MPP_RET mpp_init(MppCtx ctx, MppCtxType type, MppCodingType coding);
|
||||
/**
|
||||
* @ingroup rk_mpi
|
||||
* @brief Destroy mpp context and free both context and mpi structure,
|
||||
* it matches with mpp_init().
|
||||
* @param[in] ctx The context of mpp, created by mpp_create().
|
||||
* @return 0 for success, others for failure. The return value is an
|
||||
* error code. For details, please refer mpp_err.h.
|
||||
*/
|
||||
MPP_RET mpp_destroy(MppCtx ctx);
|
||||
/**
|
||||
* @ingroup rk_mpi
|
||||
* @brief judge given format is supported or not by MPP.
|
||||
* @param[in] type specify decoder or encoder, refer to MppCtxType.
|
||||
* @param[in] coding specify video compression coding, refer to MppCodingType.
|
||||
* @return 0 for support, -1 for unsupported.
|
||||
*/
|
||||
MPP_RET mpp_check_support_format(MppCtxType type, MppCodingType coding);
|
||||
/**
|
||||
* @ingroup rk_mpi
|
||||
* @brief List all formats supported by MPP
|
||||
* @param NULL no need to input parameter
|
||||
* @return No return value. This function just prints format information supported
|
||||
* by MPP on standard output.
|
||||
*/
|
||||
void mpp_show_support_format(void);
|
||||
void mpp_show_color_format(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*__RK_MPI_H__*/
|
@@ -1,209 +0,0 @@
|
||||
/*
|
||||
* Copyright 2015 Rockchip Electronics Co. LTD
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __RK_MPI_CMD_H__
|
||||
#define __RK_MPI_CMD_H__
|
||||
|
||||
/*
|
||||
* Command id bit usage is defined as follows:
|
||||
* bit 20 - 23 - module id
|
||||
* bit 16 - 19 - contex id
|
||||
* bit 0 - 15 - command id
|
||||
*/
|
||||
#define CMD_MODULE_ID_MASK (0x00F00000)
|
||||
#define CMD_MODULE_OSAL (0x00100000)
|
||||
#define CMD_MODULE_MPP (0x00200000)
|
||||
#define CMD_MODULE_CODEC (0x00300000)
|
||||
#define CMD_MODULE_HAL (0x00400000)
|
||||
|
||||
#define CMD_CTX_ID_MASK (0x000F0000)
|
||||
#define CMD_CTX_ID_DEC (0x00010000)
|
||||
#define CMD_CTX_ID_ENC (0x00020000)
|
||||
#define CMD_CTX_ID_ISP (0x00030000)
|
||||
|
||||
/* separate encoder / decoder control command to different segment */
|
||||
#define CMD_CFG_ID_MASK (0x0000FF00)
|
||||
|
||||
/* mpp status control command */
|
||||
#define CMD_STATE_OPS (0x00000100)
|
||||
|
||||
/* decoder control command */
|
||||
#define CMD_DEC_CFG_ALL (0x00000000)
|
||||
#define CMD_DEC_QUERY (0x00000100)
|
||||
#define CMD_DEC_CFG (0x00000200)
|
||||
|
||||
/* encoder control command */
|
||||
#define CMD_ENC_CFG_ALL (0x00000000)
|
||||
#define CMD_ENC_QUERY (0x00000100)
|
||||
#define CMD_ENC_CFG_RC_API (0x00000200)
|
||||
|
||||
#define CMD_ENC_CFG_MISC (0x00008000)
|
||||
#define CMD_ENC_CFG_SPLIT (0x00008100)
|
||||
#define CMD_ENC_CFG_REF (0x00008200)
|
||||
#define CMD_ENC_CFG_ROI (0x00008300)
|
||||
#define CMD_ENC_CFG_OSD (0x00008400)
|
||||
|
||||
typedef enum {
|
||||
MPP_OSAL_CMD_BASE = CMD_MODULE_OSAL,
|
||||
MPP_OSAL_CMD_END,
|
||||
|
||||
MPP_CMD_BASE = CMD_MODULE_MPP,
|
||||
MPP_ENABLE_DEINTERLACE,
|
||||
MPP_SET_INPUT_BLOCK, /* deprecated */
|
||||
MPP_SET_INTPUT_BLOCK_TIMEOUT, /* deprecated */
|
||||
MPP_SET_OUTPUT_BLOCK, /* deprecated */
|
||||
MPP_SET_OUTPUT_BLOCK_TIMEOUT, /* deprecated */
|
||||
/*
|
||||
* timeout setup, refer to MPP_TIMEOUT_XXX
|
||||
* zero - non block
|
||||
* negative - block with no timeout
|
||||
* positive - timeout in milisecond
|
||||
*/
|
||||
MPP_SET_INPUT_TIMEOUT, /* parameter type RK_S64 */
|
||||
MPP_SET_OUTPUT_TIMEOUT, /* parameter type RK_S64 */
|
||||
MPP_SET_DISABLE_THREAD, /* MPP no thread mode and use external thread to decode */
|
||||
|
||||
MPP_STATE_CMD_BASE = CMD_MODULE_MPP | CMD_STATE_OPS,
|
||||
MPP_START,
|
||||
MPP_STOP,
|
||||
MPP_PAUSE,
|
||||
MPP_RESUME,
|
||||
|
||||
MPP_CMD_END,
|
||||
|
||||
MPP_CODEC_CMD_BASE = CMD_MODULE_CODEC,
|
||||
MPP_CODEC_GET_FRAME_INFO,
|
||||
MPP_CODEC_CMD_END,
|
||||
|
||||
MPP_DEC_CMD_BASE = CMD_MODULE_CODEC | CMD_CTX_ID_DEC,
|
||||
MPP_DEC_SET_FRAME_INFO, /* vpu api legacy control for buffer slot dimension init */
|
||||
MPP_DEC_SET_EXT_BUF_GROUP, /* IMPORTANT: set external buffer group to mpp decoder */
|
||||
MPP_DEC_SET_INFO_CHANGE_READY,
|
||||
MPP_DEC_SET_PRESENT_TIME_ORDER, /* use input time order for output */
|
||||
MPP_DEC_SET_PARSER_SPLIT_MODE, /* Need to setup before init */
|
||||
MPP_DEC_SET_PARSER_FAST_MODE, /* Need to setup before init */
|
||||
MPP_DEC_GET_STREAM_COUNT,
|
||||
MPP_DEC_GET_VPUMEM_USED_COUNT,
|
||||
MPP_DEC_SET_VC1_EXTRA_DATA,
|
||||
MPP_DEC_SET_OUTPUT_FORMAT,
|
||||
MPP_DEC_SET_DISABLE_ERROR, /* When set it will disable sw/hw error (H.264 / H.265) */
|
||||
MPP_DEC_SET_IMMEDIATE_OUT,
|
||||
MPP_DEC_SET_ENABLE_DEINTERLACE, /* MPP enable deinterlace by default. Vpuapi can disable it */
|
||||
MPP_DEC_SET_ENABLE_FAST_PLAY, /* enable idr output immediately */
|
||||
MPP_DEC_SET_DISABLE_THREAD, /* MPP no thread mode and use external thread to decode */
|
||||
MPP_DEC_SET_MAX_USE_BUFFER_SIZE,
|
||||
MPP_DEC_SET_ENABLE_MVC, /* enable MVC decoding*/
|
||||
|
||||
MPP_DEC_CMD_QUERY = CMD_MODULE_CODEC | CMD_CTX_ID_DEC | CMD_DEC_QUERY,
|
||||
/* query decoder runtime information for decode stage */
|
||||
MPP_DEC_QUERY, /* set and get MppDecQueryCfg structure */
|
||||
|
||||
CMD_DEC_CMD_CFG = CMD_MODULE_CODEC | CMD_CTX_ID_DEC | CMD_DEC_CFG,
|
||||
MPP_DEC_SET_CFG, /* set MppDecCfg structure */
|
||||
MPP_DEC_GET_CFG, /* get MppDecCfg structure */
|
||||
|
||||
MPP_DEC_CMD_END,
|
||||
|
||||
MPP_ENC_CMD_BASE = CMD_MODULE_CODEC | CMD_CTX_ID_ENC,
|
||||
/* basic encoder setup control */
|
||||
MPP_ENC_SET_CFG, /* set MppEncCfg structure */
|
||||
MPP_ENC_GET_CFG, /* get MppEncCfg structure */
|
||||
MPP_ENC_SET_PREP_CFG, /* deprecated set MppEncPrepCfg structure, use MPP_ENC_SET_CFG instead */
|
||||
MPP_ENC_GET_PREP_CFG, /* deprecated get MppEncPrepCfg structure, use MPP_ENC_GET_CFG instead */
|
||||
MPP_ENC_SET_RC_CFG, /* deprecated set MppEncRcCfg structure, use MPP_ENC_SET_CFG instead */
|
||||
MPP_ENC_GET_RC_CFG, /* deprecated get MppEncRcCfg structure, use MPP_ENC_GET_CFG instead */
|
||||
MPP_ENC_SET_CODEC_CFG, /* deprecated set MppEncCodecCfg structure, use MPP_ENC_SET_CFG instead */
|
||||
MPP_ENC_GET_CODEC_CFG, /* deprecated get MppEncCodecCfg structure, use MPP_ENC_GET_CFG instead */
|
||||
/* runtime encoder setup control */
|
||||
MPP_ENC_SET_IDR_FRAME, /* next frame will be encoded as intra frame */
|
||||
MPP_ENC_SET_OSD_LEGACY_0, /* deprecated */
|
||||
MPP_ENC_SET_OSD_LEGACY_1, /* deprecated */
|
||||
MPP_ENC_SET_OSD_LEGACY_2, /* deprecated */
|
||||
MPP_ENC_GET_HDR_SYNC, /* get vps / sps / pps which has better sync behavior parameter is MppPacket */
|
||||
MPP_ENC_GET_EXTRA_INFO, /* deprecated */
|
||||
MPP_ENC_SET_SEI_CFG, /* SEI: Supplement Enhancemant Information, parameter is MppSeiMode */
|
||||
MPP_ENC_GET_SEI_DATA, /* SEI: Supplement Enhancemant Information, parameter is MppPacket */
|
||||
MPP_ENC_PRE_ALLOC_BUFF, /* deprecated */
|
||||
MPP_ENC_SET_QP_RANGE, /* used for adjusting qp range, the parameter can be 1 or 2 */
|
||||
MPP_ENC_SET_ROI_CFG, /* set MppEncROICfg structure */
|
||||
MPP_ENC_SET_CTU_QP, /* for H265 Encoder,set CTU's size and QP */
|
||||
|
||||
MPP_ENC_CMD_QUERY = CMD_MODULE_CODEC | CMD_CTX_ID_ENC | CMD_ENC_QUERY,
|
||||
/* query encoder runtime information for encode stage */
|
||||
MPP_ENC_QUERY, /* set and get MppEncQueryCfg structure */
|
||||
|
||||
/* User define rate control stategy API control */
|
||||
MPP_ENC_CFG_RC_API = CMD_MODULE_CODEC | CMD_CTX_ID_ENC | CMD_ENC_CFG_RC_API,
|
||||
/*
|
||||
* Get RcApiQueryAll structure
|
||||
* Get all available rate control stategy string and count
|
||||
*/
|
||||
MPP_ENC_GET_RC_API_ALL = MPP_ENC_CFG_RC_API + 1,
|
||||
/*
|
||||
* Get RcApiQueryType structure
|
||||
* Get available rate control stategy string with certain type
|
||||
*/
|
||||
MPP_ENC_GET_RC_API_BY_TYPE = MPP_ENC_CFG_RC_API + 2,
|
||||
/*
|
||||
* Set RcImplApi structure
|
||||
* Add new or update rate control stategy function pointers
|
||||
*/
|
||||
MPP_ENC_SET_RC_API_CFG = MPP_ENC_CFG_RC_API + 3,
|
||||
/*
|
||||
* Get RcApiBrief structure
|
||||
* Get current used rate control stategy brief information (type and name)
|
||||
*/
|
||||
MPP_ENC_GET_RC_API_CURRENT = MPP_ENC_CFG_RC_API + 4,
|
||||
/*
|
||||
* Set RcApiBrief structure
|
||||
* Set current used rate control stategy brief information (type and name)
|
||||
*/
|
||||
MPP_ENC_SET_RC_API_CURRENT = MPP_ENC_CFG_RC_API + 5,
|
||||
|
||||
MPP_ENC_CFG_MISC = CMD_MODULE_CODEC | CMD_CTX_ID_ENC | CMD_ENC_CFG_MISC,
|
||||
MPP_ENC_SET_HEADER_MODE, /* set MppEncHeaderMode */
|
||||
MPP_ENC_GET_HEADER_MODE, /* get MppEncHeaderMode */
|
||||
|
||||
MPP_ENC_CFG_SPLIT = CMD_MODULE_CODEC | CMD_CTX_ID_ENC | CMD_ENC_CFG_SPLIT,
|
||||
MPP_ENC_SET_SPLIT, /* set MppEncSliceSplit structure */
|
||||
MPP_ENC_GET_SPLIT, /* get MppEncSliceSplit structure */
|
||||
|
||||
MPP_ENC_CFG_REF = CMD_MODULE_CODEC | CMD_CTX_ID_ENC | CMD_ENC_CFG_REF,
|
||||
MPP_ENC_SET_REF_CFG, /* set MppEncRefCfg structure */
|
||||
|
||||
MPP_ENC_CFG_OSD = CMD_MODULE_CODEC | CMD_CTX_ID_ENC | CMD_ENC_CFG_OSD,
|
||||
MPP_ENC_SET_OSD_PLT_CFG, /* set OSD palette, parameter should be pointer to MppEncOSDPltCfg */
|
||||
MPP_ENC_GET_OSD_PLT_CFG, /* get OSD palette, parameter should be pointer to MppEncOSDPltCfg */
|
||||
MPP_ENC_SET_OSD_DATA_CFG, /* set OSD data with at most 8 regions, parameter should be pointer to MppEncOSDData */
|
||||
|
||||
MPP_ENC_CMD_END,
|
||||
|
||||
MPP_ISP_CMD_BASE = CMD_MODULE_CODEC | CMD_CTX_ID_ISP,
|
||||
MPP_ISP_CMD_END,
|
||||
|
||||
MPP_HAL_CMD_BASE = CMD_MODULE_HAL,
|
||||
MPP_HAL_CMD_END,
|
||||
|
||||
MPI_CMD_BUTT,
|
||||
} MpiCmd;
|
||||
|
||||
#include "rk_vdec_cmd.h"
|
||||
#include "rk_vdec_cfg.h"
|
||||
#include "rk_venc_cmd.h"
|
||||
#include "rk_venc_cfg.h"
|
||||
#include "rk_venc_ref.h"
|
||||
|
||||
#endif /*__RK_MPI_CMD_H__*/
|
@@ -1,142 +0,0 @@
|
||||
/*
|
||||
* Copyright 2015 Rockchip Electronics Co. LTD
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __RK_TYPE_H__
|
||||
#define __RK_TYPE_H__
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#if defined(_WIN32) && !defined(__MINGW32CE__)
|
||||
|
||||
typedef unsigned char RK_U8;
|
||||
typedef unsigned short RK_U16;
|
||||
typedef unsigned int RK_U32;
|
||||
typedef unsigned long RK_ULONG;
|
||||
typedef unsigned __int64 RK_U64;
|
||||
|
||||
typedef signed char RK_S8;
|
||||
typedef signed short RK_S16;
|
||||
typedef signed int RK_S32;
|
||||
typedef signed long RK_LONG;
|
||||
typedef signed __int64 RK_S64;
|
||||
|
||||
#else
|
||||
|
||||
typedef unsigned char RK_U8;
|
||||
typedef unsigned short RK_U16;
|
||||
typedef unsigned int RK_U32;
|
||||
typedef unsigned long RK_ULONG;
|
||||
typedef unsigned long long int RK_U64;
|
||||
|
||||
|
||||
typedef signed char RK_S8;
|
||||
typedef signed short RK_S16;
|
||||
typedef signed int RK_S32;
|
||||
typedef signed long RK_LONG;
|
||||
typedef signed long long int RK_S64;
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef MODULE_TAG
|
||||
#define MODULE_TAG NULL
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @ingroup rk_mpi
|
||||
* @brief The type of mpp context
|
||||
* @details This type is used when calling mpp_init(), which including decoder,
|
||||
* encoder and Image Signal Process(ISP). So far decoder and encoder
|
||||
* are supported perfectly, and ISP will be supported in the future.
|
||||
*/
|
||||
typedef enum {
|
||||
MPP_CTX_DEC, /**< decoder */
|
||||
MPP_CTX_ENC, /**< encoder */
|
||||
MPP_CTX_ISP, /**< isp */
|
||||
MPP_CTX_BUTT, /**< undefined */
|
||||
} MppCtxType;
|
||||
|
||||
/**
|
||||
* @ingroup rk_mpi
|
||||
* @brief Enumeration used to define the possible video compression codings.
|
||||
* sync with the omx_video.h
|
||||
*
|
||||
* @note This essentially refers to file extensions. If the coding is
|
||||
* being used to specify the ENCODE type, then additional work
|
||||
* must be done to configure the exact flavor of the compression
|
||||
* to be used. For decode cases where the user application can
|
||||
* not differentiate between MPEG-4 and H.264 bit streams, it is
|
||||
* up to the codec to handle this.
|
||||
*/
|
||||
typedef enum {
|
||||
MPP_VIDEO_CodingUnused, /**< Value when coding is N/A */
|
||||
MPP_VIDEO_CodingAutoDetect, /**< Autodetection of coding type */
|
||||
MPP_VIDEO_CodingMPEG2, /**< AKA: H.262 */
|
||||
MPP_VIDEO_CodingH263, /**< H.263 */
|
||||
MPP_VIDEO_CodingMPEG4, /**< MPEG-4 */
|
||||
MPP_VIDEO_CodingWMV, /**< Windows Media Video (WMV1,WMV2,WMV3)*/
|
||||
MPP_VIDEO_CodingRV, /**< all versions of Real Video */
|
||||
MPP_VIDEO_CodingAVC, /**< H.264/AVC */
|
||||
MPP_VIDEO_CodingMJPEG, /**< Motion JPEG */
|
||||
MPP_VIDEO_CodingVP8, /**< VP8 */
|
||||
MPP_VIDEO_CodingVP9, /**< VP9 */
|
||||
MPP_VIDEO_CodingVC1 = 0x01000000, /**< Windows Media Video (WMV1,WMV2,WMV3)*/
|
||||
MPP_VIDEO_CodingFLV1, /**< Sorenson H.263 */
|
||||
MPP_VIDEO_CodingDIVX3, /**< DIVX3 */
|
||||
MPP_VIDEO_CodingVP6,
|
||||
MPP_VIDEO_CodingHEVC, /**< H.265/HEVC */
|
||||
MPP_VIDEO_CodingAVSPLUS, /**< AVS+ */
|
||||
MPP_VIDEO_CodingAVS, /**< AVS profile=0x20 */
|
||||
MPP_VIDEO_CodingAVS2, /**< AVS2 */
|
||||
MPP_VIDEO_CodingAV1, /**< av1 */
|
||||
MPP_VIDEO_CodingKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
|
||||
MPP_VIDEO_CodingVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
|
||||
MPP_VIDEO_CodingMax = 0x7FFFFFFF
|
||||
} MppCodingType;
|
||||
|
||||
/*
|
||||
* All external interface object list here.
|
||||
* The interface object is defined as void * for expandability
|
||||
* The cross include between these objects will introduce extra
|
||||
* compiling difficulty. So we move them together in this header.
|
||||
*
|
||||
* Object interface header list:
|
||||
*
|
||||
* MppCtx - rk_mpi.h
|
||||
* MppParam - rk_mpi.h
|
||||
*
|
||||
* MppFrame - mpp_frame.h
|
||||
* MppPacket - mpp_packet.h
|
||||
*
|
||||
* MppBuffer - mpp_buffer.h
|
||||
* MppBufferGroup - mpp_buffer.h
|
||||
*
|
||||
* MppTask - mpp_task.h
|
||||
* MppMeta - mpp_meta.h
|
||||
*/
|
||||
|
||||
typedef void* MppCtx;
|
||||
typedef void* MppParam;
|
||||
|
||||
typedef void* MppFrame;
|
||||
typedef void* MppPacket;
|
||||
|
||||
typedef void* MppBuffer;
|
||||
typedef void* MppBufferGroup;
|
||||
|
||||
typedef void* MppTask;
|
||||
typedef void* MppMeta;
|
||||
|
||||
#endif /*__RK_TYPE_H__*/
|
@@ -1,50 +0,0 @@
|
||||
/*
|
||||
* Copyright 2020 Rockchip Electronics Co. LTD
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __RK_VDEC_CFG_H__
|
||||
#define __RK_VDEC_CFG_H__
|
||||
|
||||
#include "rk_type.h"
|
||||
#include "mpp_err.h"
|
||||
|
||||
typedef void* MppDecCfg;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
MPP_RET mpp_dec_cfg_init(MppDecCfg *cfg);
|
||||
MPP_RET mpp_dec_cfg_deinit(MppDecCfg cfg);
|
||||
|
||||
MPP_RET mpp_dec_cfg_set_s32(MppDecCfg cfg, const char *name, RK_S32 val);
|
||||
MPP_RET mpp_dec_cfg_set_u32(MppDecCfg cfg, const char *name, RK_U32 val);
|
||||
MPP_RET mpp_dec_cfg_set_s64(MppDecCfg cfg, const char *name, RK_S64 val);
|
||||
MPP_RET mpp_dec_cfg_set_u64(MppDecCfg cfg, const char *name, RK_U64 val);
|
||||
MPP_RET mpp_dec_cfg_set_ptr(MppDecCfg cfg, const char *name, void *val);
|
||||
|
||||
MPP_RET mpp_dec_cfg_get_s32(MppDecCfg cfg, const char *name, RK_S32 *val);
|
||||
MPP_RET mpp_dec_cfg_get_u32(MppDecCfg cfg, const char *name, RK_U32 *val);
|
||||
MPP_RET mpp_dec_cfg_get_s64(MppDecCfg cfg, const char *name, RK_S64 *val);
|
||||
MPP_RET mpp_dec_cfg_get_u64(MppDecCfg cfg, const char *name, RK_U64 *val);
|
||||
MPP_RET mpp_dec_cfg_get_ptr(MppDecCfg cfg, const char *name, void **val);
|
||||
|
||||
void mpp_dec_cfg_show(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*__RK_VDEC_CFG_H__*/
|
@@ -1,69 +0,0 @@
|
||||
/*
|
||||
* Copyright 2015 Rockchip Electronics Co. LTD
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __RK_VDEC_CMD_H__
|
||||
#define __RK_VDEC_CMD_H__
|
||||
|
||||
#include "rk_type.h"
|
||||
#include "mpp_err.h"
|
||||
|
||||
/*
|
||||
* decoder query interface is only for debug usage
|
||||
*/
|
||||
#define MPP_DEC_QUERY_STATUS (0x00000001)
|
||||
#define MPP_DEC_QUERY_WAIT (0x00000002)
|
||||
#define MPP_DEC_QUERY_FPS (0x00000004)
|
||||
#define MPP_DEC_QUERY_BPS (0x00000008)
|
||||
#define MPP_DEC_QUERY_DEC_IN_PKT (0x00000010)
|
||||
#define MPP_DEC_QUERY_DEC_WORK (0x00000020)
|
||||
#define MPP_DEC_QUERY_DEC_OUT_FRM (0x00000040)
|
||||
|
||||
#define MPP_DEC_QUERY_ALL (MPP_DEC_QUERY_STATUS | \
|
||||
MPP_DEC_QUERY_WAIT | \
|
||||
MPP_DEC_QUERY_FPS | \
|
||||
MPP_DEC_QUERY_BPS | \
|
||||
MPP_DEC_QUERY_DEC_IN_PKT | \
|
||||
MPP_DEC_QUERY_DEC_WORK | \
|
||||
MPP_DEC_QUERY_DEC_OUT_FRM)
|
||||
|
||||
typedef struct MppDecQueryCfg_t {
|
||||
/*
|
||||
* 32 bit query flag for query data check
|
||||
* Each bit represent a query data switch.
|
||||
* bit 0 - for querying decoder runtime status
|
||||
* bit 1 - for querying decoder runtime waiting status
|
||||
* bit 2 - for querying decoder realtime decode fps
|
||||
* bit 3 - for querying decoder realtime input bps
|
||||
* bit 4 - for querying decoder input packet count
|
||||
* bit 5 - for querying decoder start hardware times
|
||||
* bit 6 - for querying decoder output frame count
|
||||
*/
|
||||
RK_U32 query_flag;
|
||||
|
||||
/* 64 bit query data output */
|
||||
RK_U32 rt_status;
|
||||
RK_U32 rt_wait;
|
||||
RK_U32 rt_fps;
|
||||
RK_U32 rt_bps;
|
||||
RK_U32 dec_in_pkt_cnt;
|
||||
RK_U32 dec_hw_run_cnt;
|
||||
RK_U32 dec_out_frm_cnt;
|
||||
} MppDecQueryCfg;
|
||||
|
||||
typedef void* MppExtCbCtx;
|
||||
typedef MPP_RET (*MppExtCbFunc)(MppExtCbCtx cb_ctx, MppCtx mpp, RK_S32 cmd, void *arg);
|
||||
|
||||
#endif /*__RK_VDEC_CMD_H__*/
|
@@ -1,52 +0,0 @@
|
||||
/*
|
||||
* Copyright 2015 Rockchip Electronics Co. LTD
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __RK_VENC_CFG_H__
|
||||
#define __RK_VENC_CFG_H__
|
||||
|
||||
#include "rk_type.h"
|
||||
#include "mpp_err.h"
|
||||
|
||||
typedef void* MppEncCfg;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
MPP_RET mpp_enc_cfg_init(MppEncCfg *cfg);
|
||||
MPP_RET mpp_enc_cfg_deinit(MppEncCfg cfg);
|
||||
|
||||
MPP_RET mpp_enc_cfg_set_s32(MppEncCfg cfg, const char *name, RK_S32 val);
|
||||
MPP_RET mpp_enc_cfg_set_u32(MppEncCfg cfg, const char *name, RK_U32 val);
|
||||
MPP_RET mpp_enc_cfg_set_s64(MppEncCfg cfg, const char *name, RK_S64 val);
|
||||
MPP_RET mpp_enc_cfg_set_u64(MppEncCfg cfg, const char *name, RK_U64 val);
|
||||
MPP_RET mpp_enc_cfg_set_ptr(MppEncCfg cfg, const char *name, void *val);
|
||||
MPP_RET mpp_enc_cfg_set_st(MppEncCfg cfg, const char *name, void *val);
|
||||
|
||||
MPP_RET mpp_enc_cfg_get_s32(MppEncCfg cfg, const char *name, RK_S32 *val);
|
||||
MPP_RET mpp_enc_cfg_get_u32(MppEncCfg cfg, const char *name, RK_U32 *val);
|
||||
MPP_RET mpp_enc_cfg_get_s64(MppEncCfg cfg, const char *name, RK_S64 *val);
|
||||
MPP_RET mpp_enc_cfg_get_u64(MppEncCfg cfg, const char *name, RK_U64 *val);
|
||||
MPP_RET mpp_enc_cfg_get_ptr(MppEncCfg cfg, const char *name, void **val);
|
||||
MPP_RET mpp_enc_cfg_get_st(MppEncCfg cfg, const char *name, void *val);
|
||||
|
||||
void mpp_enc_cfg_show(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*__RK_VENC_CFG_H__*/
|
File diff suppressed because it is too large
Load Diff
@@ -1,66 +0,0 @@
|
||||
/*
|
||||
* Copyright 2015 Rockchip Electronics Co. LTD
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __RK_VENC_RC_H__
|
||||
#define __RK_VENC_RC_H__
|
||||
|
||||
#include "rk_type.h"
|
||||
|
||||
#define MPP_ENC_MIN_BPS (SZ_1K)
|
||||
#define MPP_ENC_MAX_BPS (SZ_1M * 200)
|
||||
|
||||
/* Rate control parameter */
|
||||
typedef enum MppEncRcMode_e {
|
||||
MPP_ENC_RC_MODE_VBR,
|
||||
MPP_ENC_RC_MODE_CBR,
|
||||
MPP_ENC_RC_MODE_FIXQP,
|
||||
MPP_ENC_RC_MODE_AVBR,
|
||||
MPP_ENC_RC_MODE_BUTT
|
||||
} MppEncRcMode;
|
||||
|
||||
typedef enum MppEncRcPriority_e {
|
||||
MPP_ENC_RC_BY_BITRATE_FIRST,
|
||||
MPP_ENC_RC_BY_FRM_SIZE_FIRST,
|
||||
MPP_ENC_RC_PRIORITY_BUTT
|
||||
} MppEncRcPriority;
|
||||
|
||||
typedef enum MppEncRcDropFrmMode_e {
|
||||
MPP_ENC_RC_DROP_FRM_DISABLED,
|
||||
MPP_ENC_RC_DROP_FRM_NORMAL,
|
||||
MPP_ENC_RC_DROP_FRM_PSKIP,
|
||||
MPP_ENC_RC_DROP_FRM_BUTT
|
||||
} MppEncRcDropFrmMode;
|
||||
|
||||
typedef enum MppEncRcSuperFrameMode_t {
|
||||
MPP_ENC_RC_SUPER_FRM_NONE,
|
||||
MPP_ENC_RC_SUPER_FRM_DROP,
|
||||
MPP_ENC_RC_SUPER_FRM_REENC,
|
||||
MPP_ENC_RC_SUPER_FRM_BUTT
|
||||
} MppEncRcSuperFrameMode;
|
||||
|
||||
typedef enum MppEncRcGopMode_e {
|
||||
MPP_ENC_RC_NORMAL_P,
|
||||
MPP_ENC_RC_SMART_P,
|
||||
MPP_ENC_RC_GOP_MODE_BUTT,
|
||||
} MppEncRcGopMode;
|
||||
|
||||
typedef enum MppEncRcIntraRefreshMode_e {
|
||||
MPP_ENC_RC_INTRA_REFRESH_ROW = 0,
|
||||
MPP_ENC_RC_INTRA_REFRESH_COL,
|
||||
MPP_ENC_RC_INTRA_REFRESH_BUTT
|
||||
} MppEncRcRefreshMode;
|
||||
|
||||
#endif /*__RK_VENC_RC_H__*/
|
@@ -1,242 +0,0 @@
|
||||
/*
|
||||
* Copyright 2015 Rockchip Electronics Co. LTD
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __RK_VENC_REF_H__
|
||||
#define __RK_VENC_REF_H__
|
||||
|
||||
#include "rk_type.h"
|
||||
#include "mpp_err.h"
|
||||
|
||||
/*
|
||||
* MPP reference management system follows the model of H.264/H.265 reference
|
||||
* frame mangement.
|
||||
*
|
||||
* The reference frame is defined into two type: long-term reference frame and
|
||||
* short-refernce frame (lt_ref and st_ref).
|
||||
*
|
||||
* The lt_ref can be only indexed by long-term reference frame index (lt_idx).
|
||||
* The st_ref can be indexed by its temporal id (tid) and previous count.
|
||||
*
|
||||
* MppEncRefMode defined the way for user to reference the required frame.
|
||||
*
|
||||
* Normal reference mode without argument
|
||||
* REF_TO_PREV_REF_FRM - refer to previous reference frame in encode order (No matter Lt or St)
|
||||
* REF_TO_PREV_ST_REF - refer to previous short-term reference frame
|
||||
* REF_TO_PREV_LT_REF - refer to previous long-term reference frame
|
||||
* REF_TO_PREV_INTRA - refer to previous Intra / IDR frame
|
||||
* REF_TO_ST_REF_SETUP - refer to refernce frame defined in StRefSetup
|
||||
*
|
||||
* Normal reference mode with argument
|
||||
* REF_TO_TEMPORAL_LAYER - refer to previous reference frame with temporal id argument
|
||||
* REF_TO_LT_REF_IDX - refer to long-term reference frame with lt_ref_idx argument
|
||||
* REF_TO_ST_PREV_N_REF - refer to short-term reference frame with diff frame_num argument
|
||||
*
|
||||
* Long-term reference only mode
|
||||
* REF_TO_ST_REF_SETUP - use corresponding mode of original short-term reference frame
|
||||
*
|
||||
* Short-term reference only mode
|
||||
* REF_TO_LT_REF_SETUP - indicate that this frame will be overwrited by long-term config
|
||||
*
|
||||
* By combining frames with these modes user can define many kinds of reference hierarchy
|
||||
* structure. But normally user should use simplified preset hierarchy pattern.
|
||||
*
|
||||
* The rules for virtual cpb management is similiar to H.264/H.265
|
||||
* 1. When one frame is marked as long-term reference frame it will be kept in cpb until
|
||||
* it is replaced by other frame with the same lt_idx or IDR frame.
|
||||
* 2. When one frame is marked as short-term reference frame it will be inert into cpb when
|
||||
* there is enough storage space. When the number of total sum of long-term and short-term
|
||||
* reference frame excess the cpb size limit the oldest short-term frame will be removed.
|
||||
* This is call sliding window in H.264.
|
||||
*/
|
||||
|
||||
/* max 4 temporal layer */
|
||||
#define MPP_ENC_MAX_TEMPORAL_LAYER_NUM 4
|
||||
/* max 4 long-term reference frame */
|
||||
#define MPP_ENC_MAX_LT_REF_NUM 16
|
||||
|
||||
/*
|
||||
* Group Of Picture (GOP) config is separated into three parts:
|
||||
*
|
||||
* 1. Intra / IDR frame config
|
||||
* igop - the interval of two intra / IDR frames
|
||||
*
|
||||
* 2. Long-term reference config (MppEncRefLtFrmCfg)
|
||||
*
|
||||
* Setup long-term reference index max lt_idx, loop interval and reference
|
||||
* mode for auto long-term reference frame generation. The encoder will
|
||||
* mark frame to be long-term reference frame with given interval.
|
||||
*
|
||||
* 2.1 lt_idx
|
||||
* The long-term reference frame index is unique identifier for a long-term
|
||||
* reference frame.
|
||||
* The max long-term reference frame index should NOT larger than
|
||||
* max_num_ref_frames in sps.
|
||||
*
|
||||
* 2.2 lt_gap
|
||||
* When lt_gap is zero the long-term reference frame generation is disabled.
|
||||
* When lt_gap is non-zero (usually 2~3 second interval) then the long-term
|
||||
* reference frame will be generated for error recovery or smart hierarchy.
|
||||
*
|
||||
* 2.2 lt_delay
|
||||
* The lt_delay is the delay time for generation of long-term reference frame.
|
||||
* The start point of lt_delay is the IDR/intra frame genertaed by igop.
|
||||
*
|
||||
* 2.4 ref_mode: Long-term refernce frame reference mode
|
||||
* NOTE: temporal id of longterm reference frame is always zero.
|
||||
*
|
||||
* Examples:
|
||||
* Sequence has only one lt_ref 0 and setup one long-term reference frame
|
||||
* every 300 frame.
|
||||
* {
|
||||
* .lt_idx = 0,
|
||||
* .lt_gap = 300,
|
||||
* .lt_delay = 0,
|
||||
* }
|
||||
* result:
|
||||
* frame 0 ...... 299 300 301 ...... 599 600 601
|
||||
* lt_idx 0 xxxxxx x 0 x xxxxxx x 0 x
|
||||
*
|
||||
* Sequence has lt_ref from 0 to 2 and setup a long-term reference frame
|
||||
* every 100 frame.
|
||||
* {
|
||||
* .lt_idx = 0,
|
||||
* .lt_gap = 300,
|
||||
* .lt_delay = 0,
|
||||
* }
|
||||
* {
|
||||
* .lt_idx = 1,
|
||||
* .lt_gap = 300,
|
||||
* .lt_delay = 100,
|
||||
* }
|
||||
* {
|
||||
* .lt_idx = 2,
|
||||
* .lt_gap = 300,
|
||||
* .lt_delay = 200,
|
||||
* }
|
||||
* result:
|
||||
* frame 0 ... 99 100 101 ... 199 200 201 ... 299 300 301
|
||||
* lt_idx 0 xxx x 1 x xxx x 2 x xxx x 0 x
|
||||
*
|
||||
* 3. Short-term reference config (MppEncStRefSetup)
|
||||
*
|
||||
* 3.1 is_non_ref
|
||||
* The is_non_ref indicated the current frame is reference frame or not.
|
||||
*
|
||||
* 3.2 temporal_id
|
||||
* The temporal id of the current frame configure.
|
||||
*
|
||||
* 3.3 ref_mode: short-term refernce frame reference mode
|
||||
*
|
||||
* 3.4 repeat
|
||||
* The repeat time of the short-term reference frame configure.
|
||||
* The overall frame count with the same config is repeat + 1.
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
*/
|
||||
|
||||
#define REF_MODE_MODE_MASK (0x1F)
|
||||
#define REF_MODE_ARG_MASK (0xFFFF0000)
|
||||
|
||||
typedef enum MppEncRefMode_e {
|
||||
/* max 32 mode in 32-bit */
|
||||
/* for default ref global config */
|
||||
REF_MODE_GLOBAL,
|
||||
REF_TO_PREV_REF_FRM = REF_MODE_GLOBAL,
|
||||
REF_TO_PREV_ST_REF,
|
||||
REF_TO_PREV_LT_REF,
|
||||
REF_TO_PREV_INTRA,
|
||||
|
||||
/* for global config with args */
|
||||
REF_MODE_GLOBAL_WITH_ARG = 0x4,
|
||||
/* with ref arg as temporal layer id */
|
||||
REF_TO_TEMPORAL_LAYER = REF_MODE_GLOBAL_WITH_ARG,
|
||||
/* with ref arg as long-term reference picture index */
|
||||
REF_TO_LT_REF_IDX,
|
||||
/* with ref arg as short-term reference picture difference frame_num */
|
||||
REF_TO_ST_PREV_N_REF,
|
||||
REF_MODE_GLOBAL_BUTT,
|
||||
|
||||
/* for lt-ref */
|
||||
REF_MODE_LT = 0x18,
|
||||
REF_TO_ST_REF_SETUP,
|
||||
REF_MODE_LT_BUTT,
|
||||
|
||||
/* for st-ref */
|
||||
REF_MODE_ST = 0x1C,
|
||||
REF_TO_LT_REF_SETUP,
|
||||
REF_MODE_ST_BUTT,
|
||||
} MppEncRefMode;
|
||||
|
||||
typedef struct MppEncRefLtFrmCfg_t {
|
||||
RK_S32 lt_idx; /* lt_idx of the reference frame */
|
||||
RK_S32 temporal_id; /* temporal_id of the reference frame */
|
||||
MppEncRefMode ref_mode;
|
||||
RK_S32 ref_arg;
|
||||
RK_S32 lt_gap; /* gap between two lt-ref with same lt_idx */
|
||||
RK_S32 lt_delay; /* delay offset to igop start frame */
|
||||
} MppEncRefLtFrmCfg;
|
||||
|
||||
typedef struct MppEncRefStFrmCfg_t {
|
||||
RK_S32 is_non_ref;
|
||||
RK_S32 temporal_id;
|
||||
MppEncRefMode ref_mode;
|
||||
RK_S32 ref_arg;
|
||||
RK_S32 repeat; /* repeat times */
|
||||
} MppEncRefStFrmCfg;
|
||||
|
||||
typedef struct MppEncRefPreset_t {
|
||||
/* input parameter for query */
|
||||
const char *name;
|
||||
RK_S32 max_lt_cnt;
|
||||
RK_S32 max_st_cnt;
|
||||
MppEncRefLtFrmCfg *lt_cfg;
|
||||
MppEncRefStFrmCfg *st_cfg;
|
||||
|
||||
/* output parameter */
|
||||
RK_S32 lt_cnt;
|
||||
RK_S32 st_cnt;
|
||||
} MppEncRefPreset;
|
||||
|
||||
typedef void* MppEncRefCfg;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
MPP_RET mpp_enc_ref_cfg_init(MppEncRefCfg *ref);
|
||||
MPP_RET mpp_enc_ref_cfg_deinit(MppEncRefCfg *ref);
|
||||
|
||||
MPP_RET mpp_enc_ref_cfg_reset(MppEncRefCfg ref);
|
||||
MPP_RET mpp_enc_ref_cfg_set_cfg_cnt(MppEncRefCfg ref, RK_S32 lt_cnt, RK_S32 st_cnt);
|
||||
MPP_RET mpp_enc_ref_cfg_add_lt_cfg(MppEncRefCfg ref, RK_S32 cnt, MppEncRefLtFrmCfg *frm);
|
||||
MPP_RET mpp_enc_ref_cfg_add_st_cfg(MppEncRefCfg ref, RK_S32 cnt, MppEncRefStFrmCfg *frm);
|
||||
MPP_RET mpp_enc_ref_cfg_check(MppEncRefCfg ref);
|
||||
|
||||
/*
|
||||
* A new reference configure will restart a new gop and clear cpb by default.
|
||||
* The keep cpb function will let encoder keeps the current cpb status and do NOT
|
||||
* reset all the reference frame in cpb.
|
||||
*/
|
||||
MPP_RET mpp_enc_ref_cfg_set_keep_cpb(MppEncRefCfg ref, RK_S32 keep);
|
||||
MPP_RET mpp_enc_ref_cfg_get_preset(MppEncRefPreset *preset);
|
||||
MPP_RET mpp_enc_ref_cfg_show(MppEncRefCfg ref);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*__RK_VENC_REF_H__*/
|
@@ -1,123 +0,0 @@
|
||||
/*
|
||||
* Copyright 2015 Rockchip Electronics Co. LTD
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __VPU_H__
|
||||
#define __VPU_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "rk_type.h"
|
||||
|
||||
#define VPU_SUCCESS (0)
|
||||
#define VPU_FAILURE (-1)
|
||||
|
||||
#define VPU_HW_WAIT_OK VPU_SUCCESS
|
||||
#define VPU_HW_WAIT_ERROR VPU_FAILURE
|
||||
#define VPU_HW_WAIT_TIMEOUT 1
|
||||
|
||||
// vpu decoder 60 registers, size 240B
|
||||
#define VPU_REG_NUM_DEC (60)
|
||||
// vpu post processor 41 registers, size 164B
|
||||
#define VPU_REG_NUM_PP (41)
|
||||
// vpu decoder + post processor 101 registers, size 404B
|
||||
#define VPU_REG_NUM_DEC_PP (VPU_REG_NUM_DEC+VPU_REG_NUM_PP)
|
||||
// vpu encoder 96 registers, size 384B
|
||||
#define VPU_REG_NUM_ENC (96)
|
||||
|
||||
typedef enum {
|
||||
VPU_ENC = 0x0,
|
||||
VPU_DEC = 0x1,
|
||||
VPU_PP = 0x2,
|
||||
VPU_DEC_PP = 0x3,
|
||||
VPU_DEC_HEVC = 0x4,
|
||||
VPU_DEC_RKV = 0x5,
|
||||
VPU_ENC_RKV = 0x6,
|
||||
VPU_DEC_AVSPLUS = 0x7,
|
||||
VPU_ENC_VEPU22 = 0x8,
|
||||
VPU_TYPE_BUTT ,
|
||||
} VPU_CLIENT_TYPE;
|
||||
|
||||
/* Hardware decoder configuration description */
|
||||
|
||||
typedef struct VPUHwDecConfig {
|
||||
RK_U32 maxDecPicWidth; /* Maximum video decoding width supported */
|
||||
RK_U32 maxPpOutPicWidth; /* Maximum output width of Post-Processor */
|
||||
RK_U32 h264Support; /* HW supports h.264 */
|
||||
RK_U32 jpegSupport; /* HW supports JPEG */
|
||||
RK_U32 mpeg4Support; /* HW supports MPEG-4 */
|
||||
RK_U32 customMpeg4Support; /* HW supports custom MPEG-4 features */
|
||||
RK_U32 vc1Support; /* HW supports VC-1 Simple */
|
||||
RK_U32 mpeg2Support; /* HW supports MPEG-2 */
|
||||
RK_U32 ppSupport; /* HW supports post-processor */
|
||||
RK_U32 ppConfig; /* HW post-processor functions bitmask */
|
||||
RK_U32 sorensonSparkSupport; /* HW supports Sorenson Spark */
|
||||
RK_U32 refBufSupport; /* HW supports reference picture buffering */
|
||||
RK_U32 vp6Support; /* HW supports VP6 */
|
||||
RK_U32 vp7Support; /* HW supports VP7 */
|
||||
RK_U32 vp8Support; /* HW supports VP8 */
|
||||
RK_U32 avsSupport; /* HW supports AVS */
|
||||
RK_U32 jpegESupport; /* HW supports JPEG extensions */
|
||||
RK_U32 rvSupport; /* HW supports REAL */
|
||||
RK_U32 mvcSupport; /* HW supports H264 MVC extension */
|
||||
} VPUHwDecConfig_t;
|
||||
|
||||
/* Hardware encoder configuration description */
|
||||
|
||||
typedef struct VPUHwEndConfig {
|
||||
RK_U32 maxEncodedWidth; /* Maximum supported width for video encoding (not JPEG) */
|
||||
RK_U32 h264Enabled; /* HW supports H.264 */
|
||||
RK_U32 jpegEnabled; /* HW supports JPEG */
|
||||
RK_U32 mpeg4Enabled; /* HW supports MPEG-4 */
|
||||
RK_U32 vsEnabled; /* HW supports video stabilization */
|
||||
RK_U32 rgbEnabled; /* HW supports RGB input */
|
||||
RK_U32 reg_size; /* HW bus type in use */
|
||||
RK_U32 reserv[2];
|
||||
} VPUHwEncConfig_t;
|
||||
|
||||
typedef enum {
|
||||
// common command
|
||||
VPU_CMD_REGISTER ,
|
||||
VPU_CMD_REGISTER_ACK_OK ,
|
||||
VPU_CMD_REGISTER_ACK_FAIL ,
|
||||
VPU_CMD_UNREGISTER ,
|
||||
|
||||
VPU_SEND_CONFIG ,
|
||||
VPU_SEND_CONFIG_ACK_OK ,
|
||||
VPU_SEND_CONFIG_ACK_FAIL ,
|
||||
|
||||
VPU_GET_HW_INFO ,
|
||||
VPU_GET_HW_INFO_ACK_OK ,
|
||||
VPU_GET_HW_INFO_ACK_FAIL ,
|
||||
|
||||
VPU_CMD_BUTT ,
|
||||
} VPU_CMD_TYPE;
|
||||
|
||||
int VPUClientInit(VPU_CLIENT_TYPE type);
|
||||
RK_S32 VPUClientRelease(int socket);
|
||||
RK_S32 VPUClientSendReg(int socket, RK_U32 *regs, RK_U32 nregs);
|
||||
RK_S32 VPUClientSendReg2(RK_S32 socket, RK_S32 offset, RK_S32 size, void *param);
|
||||
RK_S32 VPUClientWaitResult(int socket, RK_U32 *regs, RK_U32 nregs, VPU_CMD_TYPE *cmd, RK_S32 *len);
|
||||
RK_S32 VPUClientGetHwCfg(int socket, RK_U32 *cfg, RK_U32 cfg_size);
|
||||
RK_S32 VPUClientGetIOMMUStatus();
|
||||
RK_U32 VPUCheckSupportWidth();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __VPU_H__ */
|
@@ -1,516 +0,0 @@
|
||||
/*
|
||||
* Copyright 2015 Rockchip Electronics Co. LTD
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __VPU_API_H__
|
||||
#define __VPU_API_H__
|
||||
|
||||
#include "rk_type.h"
|
||||
#include "mpp_err.h"
|
||||
|
||||
/**
|
||||
* @brief rockchip media process interface
|
||||
*/
|
||||
|
||||
#define VPU_API_NOPTS_VALUE (0x8000000000000000LL)
|
||||
|
||||
/*
|
||||
* bit definition of ColorType in structure VPU_FRAME
|
||||
*/
|
||||
#define VPU_OUTPUT_FORMAT_TYPE_MASK (0x0000ffff)
|
||||
#define VPU_OUTPUT_FORMAT_ARGB8888 (0x00000000)
|
||||
#define VPU_OUTPUT_FORMAT_ABGR8888 (0x00000001)
|
||||
#define VPU_OUTPUT_FORMAT_RGB888 (0x00000002)
|
||||
#define VPU_OUTPUT_FORMAT_RGB565 (0x00000003)
|
||||
#define VPU_OUTPUT_FORMAT_RGB555 (0x00000004)
|
||||
#define VPU_OUTPUT_FORMAT_YUV420_SEMIPLANAR (0x00000005)
|
||||
#define VPU_OUTPUT_FORMAT_YUV420_PLANAR (0x00000006)
|
||||
#define VPU_OUTPUT_FORMAT_YUV422 (0x00000007)
|
||||
#define VPU_OUTPUT_FORMAT_YUV444 (0x00000008)
|
||||
#define VPU_OUTPUT_FORMAT_YCH420 (0x00000009)
|
||||
#define VPU_OUTPUT_FORMAT_BIT_MASK (0x000f0000)
|
||||
#define VPU_OUTPUT_FORMAT_BIT_8 (0x00000000)
|
||||
#define VPU_OUTPUT_FORMAT_BIT_10 (0x00010000)
|
||||
#define VPU_OUTPUT_FORMAT_BIT_12 (0x00020000)
|
||||
#define VPU_OUTPUT_FORMAT_BIT_14 (0x00030000)
|
||||
#define VPU_OUTPUT_FORMAT_BIT_16 (0x00040000)
|
||||
#define VPU_OUTPUT_FORMAT_FBC_MASK (0x00f00000)
|
||||
#define VPU_OUTPUT_FORMAT_FBC_AFBC_V1 (0x00100000)
|
||||
#define VPU_OUTPUT_FORMAT_FBC_AFBC_V2 (0x00200000)
|
||||
#define VPU_OUTPUT_FORMAT_DYNCRANGE_MASK (0x0f000000)
|
||||
#define VPU_OUTPUT_FORMAT_DYNCRANGE_SDR (0x00000000)
|
||||
#define VPU_OUTPUT_FORMAT_DYNCRANGE_HDR10 (0x01000000)
|
||||
#define VPU_OUTPUT_FORMAT_DYNCRANGE_HDR_HLG (0x02000000)
|
||||
#define VPU_OUTPUT_FORMAT_DYNCRANGE_HDR_DOLBY (0x03000000)
|
||||
|
||||
/**
|
||||
* @brief input picture type
|
||||
*/
|
||||
typedef enum {
|
||||
ENC_INPUT_YUV420_PLANAR = 0, /**< YYYY... UUUU... VVVV */
|
||||
ENC_INPUT_YUV420_SEMIPLANAR = 1, /**< YYYY... UVUVUV... */
|
||||
ENC_INPUT_YUV422_INTERLEAVED_YUYV = 2, /**< YUYVYUYV... */
|
||||
ENC_INPUT_YUV422_INTERLEAVED_UYVY = 3, /**< UYVYUYVY... */
|
||||
ENC_INPUT_RGB565 = 4, /**< 16-bit RGB */
|
||||
ENC_INPUT_BGR565 = 5, /**< 16-bit RGB */
|
||||
ENC_INPUT_RGB555 = 6, /**< 15-bit RGB */
|
||||
ENC_INPUT_BGR555 = 7, /**< 15-bit RGB */
|
||||
ENC_INPUT_RGB444 = 8, /**< 12-bit RGB */
|
||||
ENC_INPUT_BGR444 = 9, /**< 12-bit RGB */
|
||||
ENC_INPUT_RGB888 = 10, /**< 24-bit RGB */
|
||||
ENC_INPUT_BGR888 = 11, /**< 24-bit RGB */
|
||||
ENC_INPUT_RGB101010 = 12, /**< 30-bit RGB */
|
||||
ENC_INPUT_BGR101010 = 13 /**< 30-bit RGB */
|
||||
} EncInputPictureType;
|
||||
|
||||
typedef enum VPU_API_CMD {
|
||||
VPU_API_ENC_SETCFG,
|
||||
VPU_API_ENC_GETCFG,
|
||||
VPU_API_ENC_SETFORMAT,
|
||||
VPU_API_ENC_SETIDRFRAME,
|
||||
|
||||
VPU_API_ENABLE_DEINTERLACE,
|
||||
VPU_API_SET_VPUMEM_CONTEXT,
|
||||
VPU_API_USE_PRESENT_TIME_ORDER,
|
||||
VPU_API_SET_DEFAULT_WIDTH_HEIGH,
|
||||
VPU_API_SET_INFO_CHANGE,
|
||||
VPU_API_USE_FAST_MODE,
|
||||
VPU_API_DEC_GET_STREAM_COUNT,
|
||||
VPU_API_GET_VPUMEM_USED_COUNT,
|
||||
VPU_API_GET_FRAME_INFO,
|
||||
VPU_API_SET_OUTPUT_BLOCK,
|
||||
VPU_API_GET_EOS_STATUS,
|
||||
VPU_API_SET_OUTPUT_MODE,
|
||||
|
||||
/* get sps/pps header */
|
||||
VPU_API_GET_EXTRA_INFO = 0x200,
|
||||
|
||||
VPU_API_SET_IMMEDIATE_OUT = 0x1000,
|
||||
VPU_API_SET_PARSER_SPLIT_MODE, /* NOTE: should control before init */
|
||||
VPU_API_DEC_OUT_FRM_STRUCT_TYPE,
|
||||
VPU_API_DEC_EN_THUMBNAIL,
|
||||
VPU_API_DEC_EN_HDR_META,
|
||||
VPU_API_DEC_EN_MVC,
|
||||
VPU_API_DEC_EN_FBC_HDR_256_ODD,
|
||||
VPU_API_SET_INPUT_BLOCK,
|
||||
|
||||
/* set pkt/frm ready callback */
|
||||
VPU_API_SET_PKT_RDY_CB = 0x1100,
|
||||
VPU_API_SET_FRM_RDY_CB,
|
||||
|
||||
VPU_API_ENC_VEPU22_START = 0x2000,
|
||||
VPU_API_ENC_SET_VEPU22_CFG,
|
||||
VPU_API_ENC_GET_VEPU22_CFG,
|
||||
VPU_API_ENC_SET_VEPU22_CTU_QP,
|
||||
VPU_API_ENC_SET_VEPU22_ROI,
|
||||
|
||||
VPU_API_ENC_MPP = 0x3000,
|
||||
VPU_API_ENC_MPP_SETCFG,
|
||||
VPU_API_ENC_MPP_GETCFG,
|
||||
|
||||
/* mlvec dynamic configure */
|
||||
VPU_API_ENC_MLVEC_CFG = 0x4000,
|
||||
VPU_API_ENC_SET_MAX_TID,
|
||||
VPU_API_ENC_SET_MARK_LTR,
|
||||
VPU_API_ENC_SET_USE_LTR,
|
||||
VPU_API_ENC_SET_FRAME_QP,
|
||||
VPU_API_ENC_SET_BASE_LAYER_PID,
|
||||
} VPU_API_CMD;
|
||||
|
||||
typedef struct {
|
||||
RK_U32 TimeLow;
|
||||
RK_U32 TimeHigh;
|
||||
} TIME_STAMP;
|
||||
|
||||
typedef struct {
|
||||
RK_U32 CodecType;
|
||||
RK_U32 ImgWidth;
|
||||
RK_U32 ImgHeight;
|
||||
RK_U32 ImgHorStride;
|
||||
RK_U32 ImgVerStride;
|
||||
RK_U32 BufSize;
|
||||
} VPU_GENERIC;
|
||||
|
||||
typedef struct VPUMem {
|
||||
RK_U32 phy_addr;
|
||||
RK_U32 *vir_addr;
|
||||
RK_U32 size;
|
||||
RK_U32 *offset;
|
||||
} VPUMemLinear_t;
|
||||
|
||||
typedef struct tVPU_FRAME {
|
||||
RK_U32 FrameBusAddr[2]; // 0: Y address; 1: UV address;
|
||||
RK_U32 FrameWidth; // buffer horizontal stride
|
||||
RK_U32 FrameHeight; // buffer vertical stride
|
||||
RK_U32 OutputWidth; // deprecated
|
||||
RK_U32 OutputHeight; // deprecated
|
||||
RK_U32 DisplayWidth; // valid width for display
|
||||
RK_U32 DisplayHeight; // valid height for display
|
||||
RK_U32 CodingType;
|
||||
RK_U32 FrameType; // frame; top_field_first; bot_field_first
|
||||
RK_U32 ColorType;
|
||||
RK_U32 DecodeFrmNum;
|
||||
TIME_STAMP ShowTime;
|
||||
RK_U32 ErrorInfo; // error information
|
||||
RK_U32 employ_cnt;
|
||||
VPUMemLinear_t vpumem;
|
||||
struct tVPU_FRAME *next_frame;
|
||||
union {
|
||||
struct {
|
||||
RK_U32 Res0[2];
|
||||
struct {
|
||||
RK_U32 ColorPrimaries : 8;
|
||||
RK_U32 ColorTransfer : 8;
|
||||
RK_U32 ColorCoeffs : 8;
|
||||
RK_U32 ColorRange : 1;
|
||||
RK_U32 Res1 : 7;
|
||||
};
|
||||
|
||||
RK_U32 Res2;
|
||||
};
|
||||
|
||||
RK_U32 Res[4];
|
||||
};
|
||||
} VPU_FRAME;
|
||||
|
||||
typedef struct FrameThumbInfo {
|
||||
RK_U32 enable;
|
||||
RK_U32 yOffset;
|
||||
RK_U32 uvOffset;
|
||||
} FrameThumbInfo_t;
|
||||
|
||||
typedef struct FrameHdrInfo {
|
||||
RK_U32 isHdr;
|
||||
RK_U32 offset;
|
||||
RK_U32 size;
|
||||
} FrameHdrInfo_t;
|
||||
|
||||
typedef struct VideoFrame {
|
||||
VPU_FRAME vpuFrame;
|
||||
FrameThumbInfo_t thumbInfo;
|
||||
FrameHdrInfo_t hdrInfo;
|
||||
RK_U32 viewId;
|
||||
RK_U32 reserved[16];
|
||||
} VideoFrame_t;
|
||||
|
||||
typedef struct VideoPacket {
|
||||
RK_S64 pts; /* with unit of us*/
|
||||
RK_S64 dts; /* with unit of us*/
|
||||
RK_U8 *data;
|
||||
RK_S32 size;
|
||||
RK_U32 capability;
|
||||
RK_U32 nFlags;
|
||||
} VideoPacket_t;
|
||||
|
||||
typedef struct DecoderOut {
|
||||
RK_U8 *data;
|
||||
RK_U32 size;
|
||||
RK_S64 timeUs;
|
||||
RK_S32 nFlags;
|
||||
} DecoderOut_t;
|
||||
|
||||
typedef struct ParserOut {
|
||||
RK_U8 *data;
|
||||
RK_U32 size;
|
||||
RK_S64 timeUs;
|
||||
RK_U32 nFlags;
|
||||
RK_U32 width;
|
||||
RK_U32 height;
|
||||
} ParserOut_t;
|
||||
|
||||
typedef struct EncInputStream {
|
||||
RK_U8 *buf;
|
||||
RK_S32 size;
|
||||
RK_U32 bufPhyAddr;
|
||||
RK_S64 timeUs;
|
||||
RK_U32 nFlags;
|
||||
} EncInputStream_t;
|
||||
|
||||
typedef struct EncoderOut {
|
||||
RK_U8 *data;
|
||||
RK_S32 size;
|
||||
RK_S64 timeUs;
|
||||
RK_S32 keyFrame;
|
||||
|
||||
} EncoderOut_t;
|
||||
|
||||
typedef RK_S32 (*VpuFrmRdyCbFunc)(void *cb_ctx);
|
||||
|
||||
typedef struct {
|
||||
VpuFrmRdyCbFunc cb;
|
||||
void *cbCtx;
|
||||
} FrameRdyCB;
|
||||
|
||||
/*
|
||||
* @brief Enumeration used to define the possible video compression codings.
|
||||
* @note This essentially refers to file extensions. If the coding is
|
||||
* being used to specify the ENCODE type, then additional work
|
||||
* must be done to configure the exact flavor of the compression
|
||||
* to be used. For decode cases where the user application can
|
||||
* not differentiate between MPEG-4 and H.264 bit streams, it is
|
||||
* up to the codec to handle this.
|
||||
*
|
||||
* sync with the omx_video.h
|
||||
*/
|
||||
typedef enum OMX_RK_VIDEO_CODINGTYPE {
|
||||
OMX_RK_VIDEO_CodingUnused, /**< Value when coding is N/A */
|
||||
OMX_RK_VIDEO_CodingAutoDetect, /**< Autodetection of coding type */
|
||||
OMX_RK_VIDEO_CodingMPEG2, /**< AKA: H.262 */
|
||||
OMX_RK_VIDEO_CodingH263, /**< H.263 */
|
||||
OMX_RK_VIDEO_CodingMPEG4, /**< MPEG-4 */
|
||||
OMX_RK_VIDEO_CodingWMV, /**< Windows Media Video (WMV1,WMV2,WMV3)*/
|
||||
OMX_RK_VIDEO_CodingRV, /**< all versions of Real Video */
|
||||
OMX_RK_VIDEO_CodingAVC, /**< H.264/AVC */
|
||||
OMX_RK_VIDEO_CodingMJPEG, /**< Motion JPEG */
|
||||
OMX_RK_VIDEO_CodingVP8, /**< VP8 */
|
||||
OMX_RK_VIDEO_CodingVP9, /**< VP9 */
|
||||
OMX_RK_VIDEO_CodingVC1 = 0x01000000, /**< Windows Media Video (WMV1,WMV2,WMV3)*/
|
||||
OMX_RK_VIDEO_CodingFLV1, /**< Sorenson H.263 */
|
||||
OMX_RK_VIDEO_CodingDIVX3, /**< DIVX3 */
|
||||
OMX_RK_VIDEO_CodingVP6,
|
||||
OMX_RK_VIDEO_CodingHEVC, /**< H.265/HEVC */
|
||||
OMX_RK_VIDEO_CodingAVSPLUS, /**< AVS+ profile 0x48 */
|
||||
OMX_RK_VIDEO_CodingAVS, /**< AVS profile 0x20 */
|
||||
OMX_RK_VIDEO_CodingAVS2, /**< AVS2 */
|
||||
OMX_RK_VIDEO_CodingAV1, /**< av1 */
|
||||
OMX_RK_VIDEO_CodingKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */
|
||||
OMX_RK_VIDEO_CodingVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
|
||||
OMX_RK_VIDEO_CodingMax = 0x7FFFFFFF
|
||||
} OMX_RK_VIDEO_CODINGTYPE;
|
||||
|
||||
typedef enum CODEC_TYPE {
|
||||
CODEC_NONE,
|
||||
CODEC_DECODER,
|
||||
CODEC_ENCODER,
|
||||
CODEC_BUTT,
|
||||
} CODEC_TYPE;
|
||||
|
||||
typedef enum VPU_API_ERR {
|
||||
VPU_API_OK = 0,
|
||||
VPU_API_ERR_UNKNOW = -1,
|
||||
VPU_API_ERR_BASE = -1000,
|
||||
VPU_API_ERR_LIST_STREAM = VPU_API_ERR_BASE - 1,
|
||||
VPU_API_ERR_INIT = VPU_API_ERR_BASE - 2,
|
||||
VPU_API_ERR_VPU_CODEC_INIT = VPU_API_ERR_BASE - 3,
|
||||
VPU_API_ERR_STREAM = VPU_API_ERR_BASE - 4,
|
||||
VPU_API_ERR_FATAL_THREAD = VPU_API_ERR_BASE - 5,
|
||||
VPU_API_EOS_STREAM_REACHED = VPU_API_ERR_BASE - 11,
|
||||
|
||||
VPU_API_ERR_BUTT,
|
||||
} VPU_API_ERR;
|
||||
|
||||
typedef enum VPU_FRAME_ERR {
|
||||
VPU_FRAME_ERR_UNKNOW = 0x0001,
|
||||
VPU_FRAME_ERR_UNSUPPORT = 0x0002,
|
||||
|
||||
} VPU_FRAME_ERR;
|
||||
|
||||
typedef struct EncParameter {
|
||||
RK_S32 width;
|
||||
RK_S32 height;
|
||||
RK_S32 rc_mode; /* 0 - CQP mode; 1 - CBR mode; 2 - FIXQP mode*/
|
||||
RK_S32 bitRate; /* target bitrate */
|
||||
RK_S32 framerate;
|
||||
RK_S32 qp;
|
||||
RK_S32 enableCabac;
|
||||
RK_S32 cabacInitIdc;
|
||||
RK_S32 format;
|
||||
RK_S32 intraPicRate;
|
||||
RK_S32 framerateout;
|
||||
RK_S32 profileIdc;
|
||||
RK_S32 levelIdc;
|
||||
RK_S32 reserved[3];
|
||||
} EncParameter_t;
|
||||
|
||||
typedef struct EXtraCfg {
|
||||
RK_S32 vc1extra_size;
|
||||
RK_S32 vp6codeid;
|
||||
RK_S32 tsformat;
|
||||
RK_U32 ori_vpu; /* use origin vpu framework */
|
||||
/* below used in decode */
|
||||
RK_U32 mpp_mode; /* use mpp framework */
|
||||
RK_U32 bit_depth; /* 8 or 10 bit */
|
||||
RK_U32 yuv_format; /* 0:420 1:422 2:444 */
|
||||
RK_U32 reserved[16];
|
||||
} EXtraCfg_t;
|
||||
|
||||
/**
|
||||
* @brief vpu function interface
|
||||
*/
|
||||
typedef struct VpuCodecContext {
|
||||
void* vpuApiObj;
|
||||
|
||||
CODEC_TYPE codecType;
|
||||
OMX_RK_VIDEO_CODINGTYPE videoCoding;
|
||||
|
||||
RK_U32 width;
|
||||
RK_U32 height;
|
||||
void *extradata;
|
||||
RK_S32 extradata_size;
|
||||
|
||||
RK_U8 enableparsing;
|
||||
|
||||
RK_S32 no_thread;
|
||||
EXtraCfg_t extra_cfg;
|
||||
|
||||
void* private_data;
|
||||
|
||||
/*
|
||||
** 1: error state(not working) 0: working
|
||||
*/
|
||||
RK_S32 decoder_err;
|
||||
|
||||
|
||||
/**
|
||||
* Allocate and initialize an VpuCodecContext.
|
||||
*
|
||||
* @param ctx The context of vpu api, allocated in this function.
|
||||
* @param extraData The extra data of codec, some codecs need / can
|
||||
* use extradata like Huffman tables, also live VC1 codec can
|
||||
* use extradata to initialize itself.
|
||||
* @param extra_size The size of extra data.
|
||||
*
|
||||
* @return 0 for init success, others for failure.
|
||||
* @note check whether ctx has been allocated success after you do init.
|
||||
*/
|
||||
RK_S32 (*init)(struct VpuCodecContext *ctx, RK_U8 *extraData, RK_U32 extra_size);
|
||||
/**
|
||||
* @brief both send video stream packet to decoder and get video frame from
|
||||
* decoder at the same time
|
||||
* @param ctx The context of vpu codec
|
||||
* @param pkt[in] Stream to be decoded
|
||||
* @param aDecOut[out] Decoding frame
|
||||
* @return 0 for decode success, others for failure.
|
||||
*/
|
||||
RK_S32 (*decode)(struct VpuCodecContext *ctx, VideoPacket_t *pkt, DecoderOut_t *aDecOut);
|
||||
/**
|
||||
* @brief both send video frame to encoder and get encoded video stream from
|
||||
* encoder at the same time.
|
||||
* @param ctx The context of vpu codec
|
||||
* @param aEncInStrm[in] Frame to be encoded
|
||||
* @param aEncOut[out] Encoding stream
|
||||
* @return 0 for encode success, others for failure.
|
||||
*/
|
||||
RK_S32 (*encode)(struct VpuCodecContext *ctx, EncInputStream_t *aEncInStrm, EncoderOut_t *aEncOut);
|
||||
/**
|
||||
* @brief flush codec while do fast forward playing.
|
||||
* @param ctx The context of vpu codec
|
||||
* @return 0 for flush success, others for failure.
|
||||
*/
|
||||
RK_S32 (*flush)(struct VpuCodecContext *ctx);
|
||||
RK_S32 (*control)(struct VpuCodecContext *ctx, VPU_API_CMD cmdType, void* param);
|
||||
/**
|
||||
* @brief send video stream packet to decoder only, async interface
|
||||
* @param ctx The context of vpu codec
|
||||
* @param pkt Stream to be decoded
|
||||
* @return 0 for success, others for failure.
|
||||
*/
|
||||
RK_S32 (*decode_sendstream)(struct VpuCodecContext *ctx, VideoPacket_t *pkt);
|
||||
/**
|
||||
* @brief get video frame from decoder only, async interface
|
||||
* @param ctx The context of vpu codec
|
||||
* @param aDecOut Decoding frame
|
||||
* @return 0 for success, others for failure.
|
||||
*/
|
||||
RK_S32 (*decode_getframe)(struct VpuCodecContext *ctx, DecoderOut_t *aDecOut);
|
||||
/**
|
||||
* @brief send video frame to encoder only, async interface
|
||||
* @param ctx The context of vpu codec
|
||||
* @param aEncInStrm Frame to be encoded
|
||||
* @return 0 for success, others for failure.
|
||||
*/
|
||||
RK_S32 (*encoder_sendframe)(struct VpuCodecContext *ctx, EncInputStream_t *aEncInStrm);
|
||||
/**
|
||||
* @brief get encoded video packet from encoder only, async interface
|
||||
* @param ctx The context of vpu codec
|
||||
* @param aEncOut Encoding stream
|
||||
* @return 0 for success, others for failure.
|
||||
*/
|
||||
RK_S32 (*encoder_getstream)(struct VpuCodecContext *ctx, EncoderOut_t *aEncOut);
|
||||
} VpuCodecContext_t;
|
||||
|
||||
/* allocated vpu codec context */
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief open context of vpu
|
||||
* @param ctx pointer of vpu codec context
|
||||
*/
|
||||
RK_S32 vpu_open_context(struct VpuCodecContext **ctx);
|
||||
/**
|
||||
* @brief close context of vpu
|
||||
* @param ctx pointer of vpu codec context
|
||||
*/
|
||||
RK_S32 vpu_close_context(struct VpuCodecContext **ctx);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* vpu_mem api
|
||||
*/
|
||||
#define vpu_display_mem_pool_FIELDS \
|
||||
RK_S32 (*commit_hdl)(vpu_display_mem_pool *p, RK_S32 hdl, RK_S32 size); \
|
||||
void* (*get_free)(vpu_display_mem_pool *p); \
|
||||
RK_S32 (*inc_used)(vpu_display_mem_pool *p, void *hdl); \
|
||||
RK_S32 (*put_used)(vpu_display_mem_pool *p, void *hdl); \
|
||||
RK_S32 (*reset)(vpu_display_mem_pool *p); \
|
||||
RK_S32 (*get_unused_num)(vpu_display_mem_pool *p); \
|
||||
RK_S32 buff_size;\
|
||||
float version; \
|
||||
RK_S32 res[18];
|
||||
|
||||
typedef struct vpu_display_mem_pool vpu_display_mem_pool;
|
||||
|
||||
struct vpu_display_mem_pool {
|
||||
vpu_display_mem_pool_FIELDS
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/*
|
||||
* vpu memory handle interface
|
||||
*/
|
||||
RK_S32 VPUMemJudgeIommu(void);
|
||||
RK_S32 VPUMallocLinear(VPUMemLinear_t *p, RK_U32 size);
|
||||
RK_S32 VPUFreeLinear(VPUMemLinear_t *p);
|
||||
RK_S32 VPUMemDuplicate(VPUMemLinear_t *dst, VPUMemLinear_t *src);
|
||||
RK_S32 VPUMemLink(VPUMemLinear_t *p);
|
||||
RK_S32 VPUMemFlush(VPUMemLinear_t *p);
|
||||
RK_S32 VPUMemClean(VPUMemLinear_t *p);
|
||||
RK_S32 VPUMemInvalidate(VPUMemLinear_t *p);
|
||||
RK_S32 VPUMemGetFD(VPUMemLinear_t *p);
|
||||
RK_S32 VPUMallocLinearFromRender(VPUMemLinear_t *p, RK_U32 size, void *ctx);
|
||||
|
||||
/*
|
||||
* vpu memory allocator and manager interface
|
||||
*/
|
||||
vpu_display_mem_pool* open_vpu_memory_pool(void);
|
||||
void close_vpu_memory_pool(vpu_display_mem_pool *p);
|
||||
int create_vpu_memory_pool_allocator(vpu_display_mem_pool **ipool, int num, int size);
|
||||
void release_vpu_memory_pool_allocator(vpu_display_mem_pool *ipool);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*__VPU_API_H__*/
|
94
err.go
Normal file
94
err.go
Normal file
@@ -0,0 +1,94 @@
|
||||
package rkcodec
|
||||
|
||||
//#include <rockchip/mpp_err.h>
|
||||
import "C"
|
||||
|
||||
type MppRet = C.int
|
||||
|
||||
const (
|
||||
MppSuccess = MppRet(C.MPP_SUCCESS)
|
||||
MppOK = MppRet(C.MPP_OK)
|
||||
|
||||
MppNOK = MppRet(C.MPP_NOK)
|
||||
MppErrUnknow = MppRet(C.MPP_ERR_UNKNOW)
|
||||
MppErrNullPtr = MppRet(C.MPP_ERR_NULL_PTR)
|
||||
MppErrMalloc = MppRet(C.MPP_ERR_MALLOC)
|
||||
MppErrOpenFile = MppRet(C.MPP_ERR_OPEN_FILE)
|
||||
MppErrValue = MppRet(C.MPP_ERR_VALUE)
|
||||
MppErrReadBit = MppRet(C.MPP_ERR_READ_BIT)
|
||||
MppErrTimeout = MppRet(C.MPP_ERR_TIMEOUT)
|
||||
MppErrPerm = MppRet(C.MPP_ERR_PERM)
|
||||
|
||||
MppErrBase = MppRet(C.MPP_ERR_BASE)
|
||||
|
||||
/* The error in stream processing */
|
||||
MppErrListStream = MppRet(C.MPP_ERR_LIST_STREAM)
|
||||
MppErrInit = MppRet(C.MPP_ERR_INIT)
|
||||
MppErrVpuCodecInit = MppRet(C.MPP_ERR_VPU_CODEC_INIT)
|
||||
MppErrStream = MppRet(C.MPP_ERR_STREAM)
|
||||
MppErrFatalThread = MppRet(C.MPP_ERR_FATAL_THREAD)
|
||||
MppErrNoMem = MppRet(C.MPP_ERR_NOMEM)
|
||||
MppErrProtol = MppRet(C.MPP_ERR_PROTOL)
|
||||
MppFailSplitFrame = MppRet(C.MPP_FAIL_SPLIT_FRAME)
|
||||
MppErrVpuHW = MppRet(C.MPP_ERR_VPUHW)
|
||||
MppEosStreamReached = MppRet(C.MPP_EOS_STREAM_REACHED)
|
||||
MppErrBufferFull = MppRet(C.MPP_ERR_BUFFER_FULL)
|
||||
MppErrDisplayFull = MppRet(C.MPP_ERR_DISPLAY_FULL)
|
||||
)
|
||||
|
||||
func (r MppRet) String() string {
|
||||
switch MppRet(r) {
|
||||
case MppSuccess: // MppOK
|
||||
return "MPP_SUCCESS" // "MPP_OK"
|
||||
case MppNOK:
|
||||
return "MPP_NOK"
|
||||
case MppErrUnknow:
|
||||
return "MPP_ERR_UNKNOW"
|
||||
case MppErrNullPtr:
|
||||
return "MPP_ERR_NULL_PTR"
|
||||
case MppErrMalloc:
|
||||
return "MPP_ERR_MALLOC"
|
||||
case MppErrOpenFile:
|
||||
return "MPP_ERR_OPEN_FILE"
|
||||
case MppErrValue:
|
||||
return "MPP_ERR_VALUE"
|
||||
case MppErrReadBit:
|
||||
return "MPP_ERR_READ_BIT"
|
||||
case MppErrTimeout:
|
||||
return "MPP_ERR_TIMEOUT"
|
||||
case MppErrPerm:
|
||||
return "MPP_ERR_PERM"
|
||||
case MppErrBase:
|
||||
return "MPP_ERR_BASE"
|
||||
case MppErrListStream:
|
||||
return "MPP_ERR_LIST_STREAM"
|
||||
case MppErrInit:
|
||||
return "MPP_ERR_INIT"
|
||||
case MppErrVpuCodecInit:
|
||||
return "MPP_ERR_VPU_CODEC_INIT"
|
||||
case MppErrStream:
|
||||
return "MPP_ERR_STREAM"
|
||||
case MppErrFatalThread:
|
||||
return "MPP_ERR_FATAL_THREAD"
|
||||
case MppErrNoMem:
|
||||
return "MPP_ERR_NOMEM"
|
||||
case MppErrProtol:
|
||||
return "MPP_ERR_PROTOL"
|
||||
case MppFailSplitFrame:
|
||||
return "MPP_FAIL_SPLIT_FRAME"
|
||||
case MppErrVpuHW:
|
||||
return "MPP_ERR_VPUHW"
|
||||
case MppEosStreamReached:
|
||||
return "MPP_EOS_STREAM_REACHED"
|
||||
case MppErrBufferFull:
|
||||
return "MPP_ERR_BUFFER_FULL"
|
||||
case MppErrDisplayFull:
|
||||
return "MPP_ERR_DISPLAY_FULL"
|
||||
default:
|
||||
return "MPP_ERR_UNKNOWN"
|
||||
}
|
||||
}
|
||||
|
||||
func (r MppRet) Error() string {
|
||||
return r.String()
|
||||
}
|
641
frame.go
Normal file
641
frame.go
Normal file
@@ -0,0 +1,641 @@
|
||||
package rkcodec
|
||||
|
||||
//#include <rockchip/mpp_frame.h>
|
||||
import "C"
|
||||
|
||||
// bit definition for mode flag in MppFrame
|
||||
const MppFrameFlagFrame = C.MPP_FRAME_FLAG_FRAME // progressive frame
|
||||
const MppFrameFlagTopField = C.MPP_FRAME_FLAG_TOP_FIELD // top field only
|
||||
const MppFrameFlagBotField = C.MPP_FRAME_FLAG_BOT_FIELD // bottom field only
|
||||
const MppFrameFlagPairedField = C.MPP_FRAME_FLAG_PAIRED_FIELD // paired field
|
||||
const MppFrameFlagTopFirst = C.MPP_FRAME_FLAG_TOP_FIRST // paired field with field order of top first
|
||||
const MppFrameFlagBotFirst = C.MPP_FRAME_FLAG_BOT_FIRST // paired field with field order of bottom first
|
||||
const MppFrameFlagDeinterlaced = C.MPP_FRAME_FLAG_DEINTERLACED // paired field with unknown field order (MBAFF)
|
||||
const MppFrameFlagFieldOrderMask = C.MPP_FRAME_FLAG_FIELD_ORDER_MASK // field order mask
|
||||
const MppFrameFlagViewIdMask = C.MPP_FRAME_FLAG_VIEW_ID_MASK // view id mask
|
||||
const MppFrameFlagIepDeiMask = C.MPP_FRAME_FLAG_IEP_DEI_MASK // iep dei mask
|
||||
const MppFrameFlagIepDeiI2O1 = C.MPP_FRAME_FLAG_IEP_DEI_I2O1 // iep dei i2o1
|
||||
const MppFrameFlagIepDeiI4O2 = C.MPP_FRAME_FLAG_IEP_DEI_I4O2 // iep dei i4o2
|
||||
const MppFrameFlagIepDeiI4O1 = C.MPP_FRAME_FLAG_IEP_DEI_I4O1 // iep dei i4o1
|
||||
|
||||
// MPEG vs JPEG YUV range
|
||||
type MppFrameColorRange = C.int
|
||||
|
||||
const (
|
||||
MppFrameRangeUnspecified = MppFrameColorRange(C.MPP_FRAME_RANGE_UNSPECIFIED)
|
||||
MppFrameRangeMpeg = MppFrameColorRange(C.MPP_FRAME_RANGE_MPEG)
|
||||
MppFrameRangeJpeg = MppFrameColorRange(C.MPP_FRAME_RANGE_JPEG)
|
||||
MppFrameRangeNB = MppFrameColorRange(C.MPP_FRAME_RANGE_NB)
|
||||
)
|
||||
|
||||
type MppFrameChromaDownSampleMode = C.int
|
||||
|
||||
const (
|
||||
MppFrameChromaDownSampleModeNone = MppFrameChromaDownSampleMode(C.MPP_FRAME_CHROMA_DOWN_SAMPLE_MODE_NONE)
|
||||
MppFrameChromaDownSampleModeAverage = MppFrameChromaDownSampleMode(C.MPP_FRAME_CHORMA_DOWN_SAMPLE_MODE_AVERAGE)
|
||||
MppFrameChromaDownSampleModeDiscard = MppFrameChromaDownSampleMode(C.MPP_FRAME_CHORMA_DOWN_SAMPLE_MODE_DISCARD)
|
||||
)
|
||||
|
||||
type MppFrameVideoFormat = C.int
|
||||
|
||||
const (
|
||||
MppFrameVideoFmtComponent = MppFrameVideoFormat(C.MPP_FRAME_VIDEO_FMT_COMPONEMT)
|
||||
MppFrameVideoFmtPal = MppFrameVideoFormat(C.MPP_FRAME_VIDEO_FMT_PAL)
|
||||
MppFrameVideoFmtNtsc = MppFrameVideoFormat(C.MPP_FRAME_VIDEO_FMT_NTSC)
|
||||
MppFrameVideoFmtSecam = MppFrameVideoFormat(C.MPP_FRAME_VIDEO_FMT_SECAM)
|
||||
MppFrameVideoFmtMac = MppFrameVideoFormat(C.MPP_FRAME_VIDEO_FMT_MAC)
|
||||
MppFrameVideoFmtUnspecified = MppFrameVideoFormat(C.MPP_FRAME_VIDEO_FMT_UNSPECIFIED)
|
||||
MppFrameVideoFmtReserved0 = MppFrameVideoFormat(C.MPP_FRAME_VIDEO_FMT_RESERVED0)
|
||||
MppFrameVideoFmtReserved1 = MppFrameVideoFormat(C.MPP_FRAME_VIDEO_FMT_RESERVED1)
|
||||
)
|
||||
|
||||
// Chromaticity coordinates of the source primaries.
|
||||
type MppFrameColorPrimaries = C.MppFrameColorPrimaries
|
||||
|
||||
const (
|
||||
MppFramePrimariesReserved0 = MppFrameColorPrimaries(C.MPP_FRAME_PRI_RESERVED0)
|
||||
MppFramePrimariesBt709 = MppFrameColorPrimaries(C.MPP_FRAME_PRI_BT709) // also ITU-R BT1361 / IEC 61966-2-4 / SMPTE RP177 Annex B
|
||||
MppFramePrimariesUnspecified = MppFrameColorPrimaries(C.MPP_FRAME_PRI_UNSPECIFIED)
|
||||
MppFramePrimariesReserved = MppFrameColorPrimaries(C.MPP_FRAME_PRI_RESERVED)
|
||||
MppFramePrimariesBt470M = MppFrameColorPrimaries(C.MPP_FRAME_PRI_BT470M) // also FCC Title 47 Code of Federal Regulations 73.682 (a)(20)
|
||||
|
||||
MppFramePrimariesBt470BG = MppFrameColorPrimaries(C.MPP_FRAME_PRI_BT470BG) // also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM
|
||||
MppFramePrimariesSmpte170M = MppFrameColorPrimaries(C.MPP_FRAME_PRI_SMPTE170M) // also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC/SMPTE ST 170 (2004)
|
||||
MppFramePrimariesSmpte240M = MppFrameColorPrimaries(C.MPP_FRAME_PRI_SMPTE240M) // functionally identical to above/SMPTE ST 240
|
||||
MppFramePrimariesFilm = MppFrameColorPrimaries(C.MPP_FRAME_PRI_FILM) // colour filters using Illuminant C
|
||||
MppFramePrimariesBt2020 = MppFrameColorPrimaries(C.MPP_FRAME_PRI_BT2020) // ITU-R BT2020 / ITU-R BT.2100-2
|
||||
MppFramePrimariesSmpte428_1 = MppFrameColorPrimaries(C.MPP_FRAME_PRI_SMPTEST428_1) // SMPTE ST 428-1 (CIE 1931 XYZ)
|
||||
MppFramePrimariesSmpte431 = MppFrameColorPrimaries(C.MPP_FRAME_PRI_SMPTE431) // SMPTE ST 431-2 (2011) / DCI P3
|
||||
MppFramePrimariesSmpte432 = MppFrameColorPrimaries(C.MPP_FRAME_PRI_SMPTE432) // SMPTE ST 432-1 (2010) / P3 D65 / Display P3
|
||||
MppFramePrimariesJedecP22 = MppFrameColorPrimaries(C.MPP_FRAME_PRI_JEDEC_P22) // JEDEC P22 phosphors
|
||||
MppFramePrimariesNB = MppFrameColorPrimaries(C.MPP_FRAME_PRI_NB) // Not part of ABI
|
||||
)
|
||||
|
||||
// Color Transfer Characteristic
|
||||
type MppFrameColorTransferCharacteristic = C.MppFrameColorTransferCharacteristic
|
||||
|
||||
const (
|
||||
MppFrameTrcReserved0 = MppFrameColorTransferCharacteristic(C.MPP_FRAME_TRC_RESERVED0)
|
||||
MppFrameTrcBt709 = MppFrameColorTransferCharacteristic(C.MPP_FRAME_TRC_BT709) // also ITU-R BT1361
|
||||
MppFrameTrcUnspecified = MppFrameColorTransferCharacteristic(C.MPP_FRAME_TRC_UNSPECIFIED)
|
||||
MppFrameTrcReserved = MppFrameColorTransferCharacteristic(C.MPP_FRAME_TRC_RESERVED)
|
||||
MppFrameTrcGamma22 = MppFrameColorTransferCharacteristic(C.MPP_FRAME_TRC_GAMMA22) // also ITU-R BT470M / ITU-R BT1700 625 PAL & SECAM
|
||||
MppFrameTrcGamma28 = MppFrameColorTransferCharacteristic(C.MPP_FRAME_TRC_GAMMA28) // also ITU-R BT470BG
|
||||
MppFrameTrcSmpte170M = MppFrameColorTransferCharacteristic(C.MPP_FRAME_TRC_SMPTE170M) // also ITU-R BT601-6 525 or 625 / ITU-R BT1358 525 or 625 / ITU-R BT1700 NTSC
|
||||
MppFrameTrcSmpte240M = MppFrameColorTransferCharacteristic(C.MPP_FRAME_TRC_SMPTE240M)
|
||||
MppFrameTrcLinear = MppFrameColorTransferCharacteristic(C.MPP_FRAME_TRC_LINEAR) // "Linear transfer characteristics"
|
||||
MppFrameTrcLog = MppFrameColorTransferCharacteristic(C.MPP_FRAME_TRC_LOG) // "Logarithmic transfer characteristic (100:1 range)"
|
||||
MppFrameTrcLogSqrt = MppFrameColorTransferCharacteristic(C.MPP_FRAME_TRC_LOG_SQRT) // "Logarithmic transfer characteristic (100 * Sqrt(10) : 1 range)"
|
||||
MppFrameTrcIec61966_2_4 = MppFrameColorTransferCharacteristic(C.MPP_FRAME_TRC_IEC61966_2_4) // IEC 61966-2-4
|
||||
MppFrameTrcBt1361Ecg = MppFrameColorTransferCharacteristic(C.MPP_FRAME_TRC_BT1361_ECG) // ITU-R BT1361 Extended Colour Gamut
|
||||
MppFrameTrcIec61966_2_1 = MppFrameColorTransferCharacteristic(C.MPP_FRAME_TRC_IEC61966_2_1) // IEC 61966-2-1 (sRGB or sYCC)
|
||||
MppFrameTrcBt2020_10 = MppFrameColorTransferCharacteristic(C.MPP_FRAME_TRC_BT2020_10) // ITU-R BT2020 for 10 bit system
|
||||
MppFrameTrcBt2020_12 = MppFrameColorTransferCharacteristic(C.MPP_FRAME_TRC_BT2020_12) // ITU-R BT2020 for 12 bit system
|
||||
MppFrameTrcSmpte2084 = MppFrameColorTransferCharacteristic(C.MPP_FRAME_TRC_SMPTEST2084) // SMPTE ST 2084 for 10-, 12-, 14- and 16-bit systems
|
||||
MppFrameTrcSmpte428_1 = MppFrameColorTransferCharacteristic(C.MPP_FRAME_TRC_SMPTEST428_1) // SMPTE ST 428-1
|
||||
MppFrameTrcAribStdB67 = MppFrameColorTransferCharacteristic(C.MPP_FRAME_TRC_ARIB_STD_B67) // ARIB STD-B67, known as "Hybrid log-gamma"
|
||||
MppFrameTrcNB = MppFrameColorTransferCharacteristic(C.MPP_FRAME_TRC_NB) // Not part of ABI
|
||||
)
|
||||
|
||||
// YUV colorspace type
|
||||
type MppFrameColorSpace = C.MppFrameColorSpace
|
||||
|
||||
const (
|
||||
MppFrameSpcRGB = MppFrameColorSpace(C.MPP_FRAME_SPC_RGB) // order of coefficients is actually GBR, also IEC 61966-2-1 (sRGB)
|
||||
MppFrameSpcBt709 = MppFrameColorSpace(C.MPP_FRAME_SPC_BT709) // also ITU-R BT1361 / IEC 61966-2-4 xvYCC709 / SMPTE RP177 Annex B
|
||||
MppFrameSpcUnspecified = MppFrameColorSpace(C.MPP_FRAME_SPC_UNSPECIFIED)
|
||||
MppFrameSpcReserved = MppFrameColorSpace(C.MPP_FRAME_SPC_RESERVED)
|
||||
MppFrameSpcFcc = MppFrameColorSpace(C.MPP_FRAME_SPC_FCC) // FCC Title 47 Code of Federal Regulations 73.682 (a)(20)
|
||||
MppFrameSpcBt470bg = MppFrameColorSpace(C.MPP_FRAME_SPC_BT470BG) // also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM / IEC 61966-2-4 xvYCC601
|
||||
MppFrameSpcSmpte170m = MppFrameColorSpace(C.MPP_FRAME_SPC_SMPTE170M) // also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC / functionally identical to above
|
||||
MppFrameSpcSmpte240m = MppFrameColorSpace(C.MPP_FRAME_SPC_SMPTE240M)
|
||||
MppFrameSpcYcocg = MppFrameColorSpace(C.MPP_FRAME_SPC_YCOCG) // Used by Dirac / VC-2 and H.264 FRext, see ITU-T SG16
|
||||
MppFrameSpcBt2020Ncl = MppFrameColorSpace(C.MPP_FRAME_SPC_BT2020_NCL) // ITU-R BT2020 non-constant luminance system
|
||||
MppFrameSpcBt2020Cl = MppFrameColorSpace(C.MPP_FRAME_SPC_BT2020_CL) // ITU-R BT2020 constant luminance system
|
||||
MppFrameSpcSmpte2085 = MppFrameColorSpace(C.MPP_FRAME_SPC_SMPTE2085) // SMPTE 2085, Y'D'zD'x
|
||||
MppFrameSpcChromaDerivedNcl = MppFrameColorSpace(C.MPP_FRAME_SPC_CHROMA_DERIVED_NCL) // Chromaticity-derived non-constant luminance system
|
||||
MppFrameSpcChromaDerivedCl = MppFrameColorSpace(C.MPP_FRAME_SPC_CHROMA_DERIVED_CL) // Chromaticity-derived constant luminance system
|
||||
MppFrameSpcIctcp = MppFrameColorSpace(C.MPP_FRAME_SPC_ICTCP) // ITU-R BT.2100-0, ICtCp
|
||||
MppFrameSpcNB = MppFrameColorSpace(C.MPP_FRAME_SPC_NB) // Not part of ABI
|
||||
)
|
||||
|
||||
// Location of chroma samples
|
||||
type MppFrameChromaLocation = C.MppFrameChromaLocation
|
||||
|
||||
const (
|
||||
MppChromaLocUnspecified = MppFrameChromaLocation(C.MPP_CHROMA_LOC_UNSPECIFIED)
|
||||
MppChromaLocLeft = MppFrameChromaLocation(C.MPP_CHROMA_LOC_LEFT) // mpeg2/4 4:2:0, h264 default for 4:2:0
|
||||
MppChromaLocCenter = MppFrameChromaLocation(C.MPP_CHROMA_LOC_CENTER) // mpeg1 4:2:0, jpeg 4:2:0, h263 4:2:0
|
||||
MppChromaLocTopLeft = MppFrameChromaLocation(C.MPP_CHROMA_LOC_TOPLEFT) // ITU-R 601, SMPTE 274M 296M S314M(DV 4:1:1), mpeg2 4:2:2
|
||||
MppChromaLocTop = MppFrameChromaLocation(C.MPP_CHROMA_LOC_TOP)
|
||||
MppChromaLocBottomLeft = MppFrameChromaLocation(C.MPP_CHROMA_LOC_BOTTOMLEFT)
|
||||
MppChromaLocBottom = MppFrameChromaLocation(C.MPP_CHROMA_LOC_BOTTOM)
|
||||
MppChromaLocNB = MppFrameChromaLocation(C.MPP_CHROMA_LOC_NB) // Not part of ABI
|
||||
)
|
||||
|
||||
type MppFrameChromaFormat = C.int
|
||||
|
||||
const (
|
||||
MppChromaFormatUnspecified = MppFrameChromaFormat(C.MPP_CHROMA_UNSPECIFIED)
|
||||
MppChromaFormat400 = MppFrameChromaFormat(C.MPP_CHROMA_400)
|
||||
MppChromaFormat410 = MppFrameChromaFormat(C.MPP_CHROMA_410)
|
||||
MppChromaFormat411 = MppFrameChromaFormat(C.MPP_CHROMA_411)
|
||||
MppChromaFormat420 = MppFrameChromaFormat(C.MPP_CHROMA_420)
|
||||
MppChromaFormat422 = MppFrameChromaFormat(C.MPP_CHROMA_422)
|
||||
MppChromaFormat440 = MppFrameChromaFormat(C.MPP_CHROMA_440)
|
||||
MppChromaFormat444 = MppFrameChromaFormat(C.MPP_CHROMA_444)
|
||||
)
|
||||
|
||||
// MppFrameFormat bit flag
|
||||
const (
|
||||
MppFrameFmtMask = C.MPP_FRAME_FMT_MASK
|
||||
MppFrameFmtPropMask = C.MPP_FRAME_FMT_PROP_MASK
|
||||
|
||||
MppFrameFmtColorMask = C.MPP_FRAME_FMT_COLOR_MASK
|
||||
MppFrameFmtYuv = C.MPP_FRAME_FMT_YUV
|
||||
MppFrameFmtRgb = C.MPP_FRAME_FMT_RGB
|
||||
|
||||
MppFrameFbcMask = C.MPP_FRAME_FBC_MASK
|
||||
MppFrameFbcNone = C.MPP_FRAME_FBC_NONE
|
||||
|
||||
MppFrameHdrMask = C.MPP_FRAME_HDR_MASK
|
||||
MppFrameHdrNone = C.MPP_FRAME_HDR_NONE
|
||||
MppFrameHdr = C.MPP_FRAME_HDR
|
||||
|
||||
MppFrameTileFlag = C.MPP_FRAME_TILE_FLAG
|
||||
)
|
||||
|
||||
// AFBC_V1 is for ISP output.
|
||||
const MppFrameFbcAfbcV1 = C.MPP_FRAME_FBC_AFBC_V1
|
||||
|
||||
// AFBC_V2 is for video decoder output.
|
||||
const MppFrameFbcAfbcV2 = C.MPP_FRAME_FBC_AFBC_V2
|
||||
|
||||
const MppFrameFmtLeMask = C.MPP_FRAME_FMT_LE_MASK
|
||||
|
||||
func MppFrameFmtIsYUV(fmt MppFrameFormat) bool {
|
||||
return ((fmt & MppFrameFmtColorMask) == MppFrameFmtYuv) && ((fmt & MppFrameFmtMask) < MppFmtYuvButt)
|
||||
}
|
||||
|
||||
func MppFrameFmtIsYUV10Bit(fmt MppFrameFormat) bool {
|
||||
return (fmt&MppFrameFmtMask) == MppFmtYuv420sp10Bit || (fmt&MppFrameFmtMask) == MppFmtYuv422sp10Bit
|
||||
}
|
||||
|
||||
func MppFrameFmtIsRGB(fmt MppFrameFormat) bool {
|
||||
return ((fmt & MppFrameFmtColorMask) == MppFrameFmtRgb) && ((fmt & MppFrameFmtMask) < MppFmtRgbButt)
|
||||
}
|
||||
|
||||
// For MPP_FRAME_FBC_AFBC_V1 the 16byte aligned stride is used.
|
||||
func MppFrameFmtIsFbc(fmt MppFrameFormat) bool {
|
||||
return (fmt & MppFrameFbcMask) != MppFrameFbcNone
|
||||
}
|
||||
|
||||
func MppFrameFmtIsHdr(fmt MppFrameFormat) bool {
|
||||
return (fmt & MppFrameHdrMask) != MppFrameHdrNone
|
||||
}
|
||||
|
||||
func MppFrameFmtIsLe(fmt MppFrameFormat) bool {
|
||||
return (fmt & MppFrameFmtLeMask) == MppFrameFmtLeMask
|
||||
}
|
||||
|
||||
func MppFrameFmtIsBe(fmt MppFrameFormat) bool {
|
||||
return (fmt & MppFrameFmtLeMask) == 0
|
||||
}
|
||||
|
||||
func MppFrameFmtIsTile(fmt MppFrameFormat) bool {
|
||||
return (fmt & MppFrameTileFlag) != 0
|
||||
}
|
||||
|
||||
// mpp color format index definition
|
||||
type MppFrameFormat = C.MppFrameFormat
|
||||
|
||||
const (
|
||||
MppFmtYuv420sp = MppFrameFormat(C.MPP_FMT_YUV420SP) // YYYY... UV... (NV12)
|
||||
/*
|
||||
* A rockchip specific pixel format, without gap between pixel aganist
|
||||
* the P010_10LE/P010_10BE
|
||||
*/
|
||||
MppFmtYuv420sp10Bit = MppFrameFormat(C.MPP_FMT_YUV420SP_10BIT)
|
||||
MppFmtYuv422sp = MppFrameFormat(C.MPP_FMT_YUV422SP) // YYYY... UVUV... (NV16)
|
||||
MppFmtYuv422sp10Bit = MppFrameFormat(C.MPP_FMT_YUV422SP_10BIT) ///< Not part of ABI
|
||||
MppFmtYuv420p = MppFrameFormat(C.MPP_FMT_YUV420P) // YYYY... U...V... (I420)
|
||||
MppFmtYuv420spVu = MppFrameFormat(C.MPP_FMT_YUV420SP_VU) // YYYY... VUVUVU... (NV21)
|
||||
MppFmtYuv422p = MppFrameFormat(C.MPP_FMT_YUV422P) // YYYY... UU...VV...(422P)
|
||||
MppFmtYuv422spVu = MppFrameFormat(C.MPP_FMT_YUV422SP_VU) // YYYY... VUVUVU... (NV61)
|
||||
MppFmtYuv422Yuyv = MppFrameFormat(C.MPP_FMT_YUV422_YUYV) // YUYVYUYV... (YUY2)
|
||||
MppFmtYuv422Yvyu = MppFrameFormat(C.MPP_FMT_YUV422_YVYU) // YVYUYVYU... (YVY2)
|
||||
MppFmtYuv422Uyvy = MppFrameFormat(C.MPP_FMT_YUV422_UYVY) // UYVYUYVY... (UYVY)
|
||||
MppFmtYuv422Vyuy = MppFrameFormat(C.MPP_FMT_YUV422_VYUY) // VYUYVYUY... (VYUY)
|
||||
MppFmtYuv400 = MppFrameFormat(C.MPP_FMT_YUV400) // YYYY...
|
||||
MppFmtYuv440sp = MppFrameFormat(C.MPP_FMT_YUV440SP) // YYYY... UVUV...
|
||||
MppFmtYuv411sp = MppFrameFormat(C.MPP_FMT_YUV411SP) // YYYY... UV...
|
||||
MppFmtYuv444sp = MppFrameFormat(C.MPP_FMT_YUV444SP) // YYYY... UVUVUVUV...
|
||||
MppFmtYuv444p = MppFrameFormat(C.MPP_FMT_YUV444P) // YYYY... UUUU... VVVV...
|
||||
MppFmtYuvButt = MppFrameFormat(C.MPP_FMT_YUV_BUTT)
|
||||
|
||||
MppFmtRgb565 = MppFrameFormat(C.MPP_FMT_RGB565) // 16-bit RGB
|
||||
MppFmtBgr565 = MppFrameFormat(C.MPP_FMT_BGR565) // 16-bit RGB
|
||||
MppFmtRgb555 = MppFrameFormat(C.MPP_FMT_RGB555) // 15-bit RGB
|
||||
MppFmtBgr555 = MppFrameFormat(C.MPP_FMT_BGR555) // 15-bit RGB
|
||||
MppFmtRgb444 = MppFrameFormat(C.MPP_FMT_RGB444) // 12-bit RGB
|
||||
MppFmtBgr444 = MppFrameFormat(C.MPP_FMT_BGR444) // 12-bit RGB
|
||||
MppFmtRgb888 = MppFrameFormat(C.MPP_FMT_RGB888) // 24-bit RGB
|
||||
MppFmtBgr888 = MppFrameFormat(C.MPP_FMT_BGR888) // 24-bit RGB
|
||||
MppFmtRgb101010 = MppFrameFormat(C.MPP_FMT_RGB101010) // 30-bit RGB
|
||||
MppFmtBgr101010 = MppFrameFormat(C.MPP_FMT_BGR101010) // 30-bit RGB
|
||||
MppFmtArgb8888 = MppFrameFormat(C.MPP_FMT_ARGB8888) // 32-bit RGB
|
||||
MppFmtAbgr8888 = MppFrameFormat(C.MPP_FMT_ABGR8888) // 32-bit RGB
|
||||
MppFmtBgra8888 = MppFrameFormat(C.MPP_FMT_BGRA8888) // 32-bit RGB
|
||||
MppFmtRgba8888 = MppFrameFormat(C.MPP_FMT_RGBA8888) // 32-bit RGB
|
||||
MppFmtRgbButt = MppFrameFormat(C.MPP_FMT_RGB_BUTT)
|
||||
|
||||
MppFmtButt = MppFrameFormat(C.MPP_FMT_BUTT)
|
||||
)
|
||||
|
||||
type MppFrameRational struct {
|
||||
c C.struct_MppFrameRational
|
||||
}
|
||||
|
||||
func (r *MppFrameRational) Num() int32 {
|
||||
return int32(r.c.num)
|
||||
}
|
||||
|
||||
func (r *MppFrameRational) Den() int32 {
|
||||
return int32(r.c.den)
|
||||
}
|
||||
|
||||
func (r *MppFrameRational) SetNum(num int32) {
|
||||
r.c.num = cS32(num)
|
||||
}
|
||||
|
||||
func (r *MppFrameRational) SetDen(den int32) {
|
||||
r.c.den = cS32(den)
|
||||
}
|
||||
|
||||
type MppFrameMasteringDisplayMetadata struct {
|
||||
c C.struct_MppFrameMasteringDisplayMetadata
|
||||
}
|
||||
|
||||
func (m *MppFrameMasteringDisplayMetadata) DisplayPrimaries() [3][2]uint16 {
|
||||
var result [3][2]uint16
|
||||
for i := 0; i < 3; i++ {
|
||||
for j := 0; j < 2; j++ {
|
||||
result[i][j] = uint16(m.c.display_primaries[i][j])
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func (m *MppFrameMasteringDisplayMetadata) WhitePoint() [2]uint16 {
|
||||
var result [2]uint16
|
||||
for i := 0; i < 2; i++ {
|
||||
result[i] = uint16(m.c.white_point[i])
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func (m *MppFrameMasteringDisplayMetadata) MaxLuminance() uint32 {
|
||||
return uint32(m.c.max_luminance)
|
||||
}
|
||||
|
||||
func (m *MppFrameMasteringDisplayMetadata) MinLuminance() uint32 {
|
||||
return uint32(m.c.min_luminance)
|
||||
}
|
||||
|
||||
func (m *MppFrameMasteringDisplayMetadata) SetDisplayPrimaries(displayPrimaries [3][2]uint16) {
|
||||
for i := 0; i < 3; i++ {
|
||||
for j := 0; j < 2; j++ {
|
||||
m.c.display_primaries[i][j] = cU16(displayPrimaries[i][j])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (m *MppFrameMasteringDisplayMetadata) SetWhitePoint(whitePoint [2]uint16) {
|
||||
for i := 0; i < 2; i++ {
|
||||
m.c.white_point[i] = cU16(whitePoint[i])
|
||||
}
|
||||
}
|
||||
|
||||
func (m *MppFrameMasteringDisplayMetadata) SetMaxLuminance(maxLuminance uint32) {
|
||||
m.c.max_luminance = cU32(maxLuminance)
|
||||
}
|
||||
|
||||
func (m *MppFrameMasteringDisplayMetadata) SetMinLuminance(minLuminance uint32) {
|
||||
m.c.min_luminance = cU32(minLuminance)
|
||||
}
|
||||
|
||||
type MppFrameContentLightMetadata struct {
|
||||
c C.struct_MppFrameContentLightMetadata
|
||||
}
|
||||
|
||||
func (m *MppFrameContentLightMetadata) MaxCLL() uint16 {
|
||||
return uint16(m.c.MaxCLL)
|
||||
}
|
||||
|
||||
func (m *MppFrameContentLightMetadata) MaxFALL() uint16 {
|
||||
return uint16(m.c.MaxFALL)
|
||||
}
|
||||
|
||||
func (m *MppFrameContentLightMetadata) SetMaxCLL(maxCLL uint16) {
|
||||
m.c.MaxCLL = cU16(maxCLL)
|
||||
}
|
||||
|
||||
func (m *MppFrameContentLightMetadata) SetMaxFALL(maxFALL uint16) {
|
||||
m.c.MaxFALL = cU16(maxFALL)
|
||||
}
|
||||
|
||||
type MppFrameHdrDynamicMeta struct {
|
||||
c *C.struct_MppFrameHdrDynamicMeta
|
||||
}
|
||||
|
||||
func (m *MppFrameHdrDynamicMeta) HdrFmt() uint32 {
|
||||
return uint32(m.c.hdr_fmt)
|
||||
}
|
||||
|
||||
func (m *MppFrameHdrDynamicMeta) Size() uint32 {
|
||||
return uint32(m.c.size)
|
||||
}
|
||||
|
||||
func (m *MppFrameHdrDynamicMeta) SetHdrFmt(hdrFmt uint32) {
|
||||
m.c.hdr_fmt = cU32(hdrFmt)
|
||||
}
|
||||
|
||||
func (m *MppFrameHdrDynamicMeta) SetSize(size uint32) {
|
||||
m.c.size = cU32(size)
|
||||
}
|
||||
|
||||
type MppFrameError = C.int
|
||||
|
||||
const (
|
||||
MppFrameErrUnknow = MppFrameError(C.MPP_FRAME_ERR_UNKNOW) // General error not specified
|
||||
MppFrameErrUnsupport = MppFrameError(C.MPP_FRAME_ERR_UNSUPPORT) // Critical error for decoder not support error
|
||||
MppFrameErrDecInvalid = MppFrameError(C.MPP_FRAME_ERR_DEC_INVALID) // Fatal error for decoder can not parse a valid frame for hardware. the pixel data is all invalid.
|
||||
MppFrameErrDecHwErr = MppFrameError(C.MPP_FRAME_ERR_DEC_HW_ERR) // Normal error for decoder found hardware error on decoding.
|
||||
MppFrameErrDecMissRef = MppFrameError(C.MPP_FRAME_ERR_DEC_MISS_REF) // Normal error for decoder found missing reference frame on decoding.
|
||||
)
|
||||
|
||||
func MppFrameInit() (*MppFrame, MppRet) {
|
||||
frame := new(MppFrame)
|
||||
ret := MppRet(C.mpp_frame_init(frame.c))
|
||||
return frame, ret
|
||||
}
|
||||
|
||||
func (f *MppFrame) Deinit() MppRet {
|
||||
return MppRet(C.mpp_frame_deinit(f.c))
|
||||
}
|
||||
|
||||
func (f *MppFrame) GetWidth() uint32 {
|
||||
return uint32(C.mpp_frame_get_width(*f.c))
|
||||
}
|
||||
|
||||
func (f *MppFrame) SetWidth(width uint32) {
|
||||
C.mpp_frame_set_width(*f.c, cU32(width))
|
||||
}
|
||||
|
||||
func (f *MppFrame) GetHeight() uint32 {
|
||||
return uint32(C.mpp_frame_get_height(*f.c))
|
||||
}
|
||||
|
||||
func (f *MppFrame) SetHeight(height uint32) {
|
||||
C.mpp_frame_set_height(*f.c, cU32(height))
|
||||
}
|
||||
|
||||
func (f *MppFrame) GetHorStride() uint32 {
|
||||
return uint32(C.mpp_frame_get_hor_stride(*f.c))
|
||||
}
|
||||
|
||||
func (f *MppFrame) SetHorStride(horStride uint32) {
|
||||
C.mpp_frame_set_hor_stride(*f.c, cU32(horStride))
|
||||
}
|
||||
|
||||
func (f *MppFrame) GetVerStride() uint32 {
|
||||
return uint32(C.mpp_frame_get_ver_stride(*f.c))
|
||||
}
|
||||
|
||||
func (f *MppFrame) SetVerStride(verStride uint32) {
|
||||
C.mpp_frame_set_ver_stride(*f.c, cU32(verStride))
|
||||
}
|
||||
|
||||
func (f *MppFrame) SetHorStridePixel(horStridePixel uint32) {
|
||||
C.mpp_frame_set_hor_stride_pixel(*f.c, cU32(horStridePixel))
|
||||
}
|
||||
|
||||
func (f *MppFrame) GetHorStridePixel() uint32 {
|
||||
return uint32(C.mpp_frame_get_hor_stride_pixel(*f.c))
|
||||
}
|
||||
|
||||
func (f *MppFrame) SetFbcHdrStride(fbcHdrStride uint32) {
|
||||
C.mpp_frame_set_fbc_hdr_stride(*f.c, cU32(fbcHdrStride))
|
||||
}
|
||||
|
||||
func (f *MppFrame) GetFbcHdrStride() uint32 {
|
||||
return uint32(C.mpp_frame_get_fbc_hdr_stride(*f.c))
|
||||
}
|
||||
|
||||
func (f *MppFrame) GetOffsetX() uint32 {
|
||||
return uint32(C.mpp_frame_get_offset_x(*f.c))
|
||||
}
|
||||
|
||||
func (f *MppFrame) SetOffsetX(offsetX uint32) {
|
||||
C.mpp_frame_set_offset_x(*f.c, cU32(offsetX))
|
||||
}
|
||||
|
||||
func (f *MppFrame) GetOffsetY() uint32 {
|
||||
return uint32(C.mpp_frame_get_offset_y(*f.c))
|
||||
}
|
||||
|
||||
func (f *MppFrame) SetOffsetY(offsetY uint32) {
|
||||
C.mpp_frame_set_offset_y(*f.c, cU32(offsetY))
|
||||
}
|
||||
|
||||
func (f *MppFrame) GetMode() uint32 {
|
||||
return uint32(C.mpp_frame_get_mode(*f.c))
|
||||
}
|
||||
|
||||
func (f *MppFrame) SetMode(mode uint32) {
|
||||
C.mpp_frame_set_mode(*f.c, cU32(mode))
|
||||
}
|
||||
|
||||
func (f *MppFrame) GetDiscard() uint32 {
|
||||
return uint32(C.mpp_frame_get_discard(*f.c))
|
||||
}
|
||||
|
||||
func (f *MppFrame) SetDiscard(discard uint32) {
|
||||
C.mpp_frame_set_discard(*f.c, cU32(discard))
|
||||
}
|
||||
|
||||
func (f *MppFrame) GetViewId() uint32 {
|
||||
return uint32(C.mpp_frame_get_viewid(*f.c))
|
||||
}
|
||||
|
||||
func (f *MppFrame) SetViewId(viewId uint32) {
|
||||
C.mpp_frame_set_viewid(*f.c, cU32(viewId))
|
||||
}
|
||||
|
||||
func (f *MppFrame) GetPoc() uint32 {
|
||||
return uint32(C.mpp_frame_get_poc(*f.c))
|
||||
}
|
||||
|
||||
func (f *MppFrame) SetPoc(poc uint32) {
|
||||
C.mpp_frame_set_poc(*f.c, cU32(poc))
|
||||
}
|
||||
|
||||
func (f *MppFrame) GetPts() int64 {
|
||||
return int64(C.mpp_frame_get_pts(*f.c))
|
||||
}
|
||||
|
||||
func (f *MppFrame) SetPts(pts int64) {
|
||||
C.mpp_frame_set_pts(*f.c, cS64(pts))
|
||||
}
|
||||
|
||||
func (f *MppFrame) GetDts() int64 {
|
||||
return int64(C.mpp_frame_get_dts(*f.c))
|
||||
}
|
||||
|
||||
func (f *MppFrame) SetDts(dts int64) {
|
||||
C.mpp_frame_set_dts(*f.c, cS64(dts))
|
||||
}
|
||||
|
||||
func (f *MppFrame) GetErrInfo() uint32 {
|
||||
return uint32(C.mpp_frame_get_errinfo(*f.c))
|
||||
}
|
||||
|
||||
func (f *MppFrame) SetErrInfo(errInfo uint32) {
|
||||
C.mpp_frame_set_errinfo(*f.c, cU32(errInfo))
|
||||
}
|
||||
|
||||
func (f *MppFrame) GetBufSize() int64 {
|
||||
return int64(C.mpp_frame_get_buf_size(*f.c))
|
||||
}
|
||||
|
||||
func (f *MppFrame) SetBufSize(bufSize int64) {
|
||||
C.mpp_frame_set_buf_size(*f.c, C.size_t(bufSize))
|
||||
}
|
||||
|
||||
func (f *MppFrame) SetThumbnailEn(thumbnailEn uint32) {
|
||||
C.mpp_frame_set_thumbnail_en(*f.c, cU32(thumbnailEn))
|
||||
}
|
||||
|
||||
func (f *MppFrame) GetThumbnailEn() uint32 {
|
||||
return uint32(C.mpp_frame_get_thumbnail_en(*f.c))
|
||||
}
|
||||
|
||||
// flow control parmeter
|
||||
func (f *MppFrame) GetEos() uint32 {
|
||||
return uint32(C.mpp_frame_get_eos(*f.c))
|
||||
}
|
||||
|
||||
func (f *MppFrame) SetEos(eos uint32) {
|
||||
C.mpp_frame_set_eos(*f.c, cU32(eos))
|
||||
}
|
||||
|
||||
func (f *MppFrame) GetInfoChange() uint32 {
|
||||
return uint32(C.mpp_frame_get_info_change(*f.c))
|
||||
}
|
||||
|
||||
func (f *MppFrame) SetInfoChange(infoChange uint32) {
|
||||
C.mpp_frame_set_info_change(*f.c, cU32(infoChange))
|
||||
}
|
||||
|
||||
// buffer parameter
|
||||
func (f *MppFrame) GetBuffer() *MppBuffer {
|
||||
return &MppBuffer{c: C.mpp_frame_get_buffer(*f.c)}
|
||||
}
|
||||
|
||||
func (f *MppFrame) SetBuffer(buf *MppBuffer) {
|
||||
C.mpp_frame_set_buffer(*f.c, buf.c)
|
||||
}
|
||||
|
||||
// meta data parameter
|
||||
func (f *MppFrame) HasMeta() uint32 {
|
||||
return uint32(C.mpp_frame_has_meta(*f.c))
|
||||
}
|
||||
|
||||
func (f *MppFrame) GetMeta() *MppMeta {
|
||||
return &MppMeta{c: C.mpp_frame_get_meta(*f.c)}
|
||||
}
|
||||
|
||||
func (f *MppFrame) SetMeta(meta *MppMeta) {
|
||||
C.mpp_frame_set_meta(*f.c, meta.c)
|
||||
}
|
||||
|
||||
// color related parameter
|
||||
func (f *MppFrame) GetColorRange() MppFrameColorRange {
|
||||
return MppFrameColorRange(C.mpp_frame_get_color_range(*f.c))
|
||||
}
|
||||
|
||||
func (f *MppFrame) SetColorRange(colorRange MppFrameColorRange) {
|
||||
C.mpp_frame_set_color_range(*f.c, C.MppFrameColorRange(colorRange))
|
||||
}
|
||||
|
||||
func (f *MppFrame) GetColorPrimaries() MppFrameColorPrimaries {
|
||||
return MppFrameColorPrimaries(C.mpp_frame_get_color_primaries(*f.c))
|
||||
}
|
||||
|
||||
func (f *MppFrame) SetColorPrimaries(colorPrimaries MppFrameColorPrimaries) {
|
||||
C.mpp_frame_set_color_primaries(*f.c, colorPrimaries)
|
||||
}
|
||||
|
||||
func (f *MppFrame) GetColorTrc() MppFrameColorTransferCharacteristic {
|
||||
return MppFrameColorTransferCharacteristic(C.mpp_frame_get_color_trc(*f.c))
|
||||
}
|
||||
|
||||
func (f *MppFrame) SetColorTrc(colorTrc MppFrameColorTransferCharacteristic) {
|
||||
C.mpp_frame_set_color_trc(*f.c, colorTrc)
|
||||
}
|
||||
|
||||
func (f *MppFrame) GetColorSpace() MppFrameColorSpace {
|
||||
return MppFrameColorSpace(C.mpp_frame_get_colorspace(*f.c))
|
||||
}
|
||||
|
||||
func (f *MppFrame) SetColorSpace(colorSpace MppFrameColorSpace) {
|
||||
C.mpp_frame_set_colorspace(*f.c, colorSpace)
|
||||
}
|
||||
|
||||
func (f *MppFrame) GetChromaLocation() MppFrameChromaLocation {
|
||||
return MppFrameChromaLocation(C.mpp_frame_get_chroma_location(*f.c))
|
||||
}
|
||||
|
||||
func (f *MppFrame) SetChromaLocation(chromaLocation MppFrameChromaLocation) {
|
||||
C.mpp_frame_set_chroma_location(*f.c, chromaLocation)
|
||||
}
|
||||
|
||||
func (f *MppFrame) GetFmt() MppFrameFormat {
|
||||
return MppFrameFormat(C.mpp_frame_get_fmt(*f.c))
|
||||
}
|
||||
|
||||
func (f *MppFrame) SetFmt(fmt MppFrameFormat) {
|
||||
C.mpp_frame_set_fmt(*f.c, fmt)
|
||||
}
|
||||
|
||||
func (f *MppFrame) GetSar() *MppFrameRational {
|
||||
return &MppFrameRational{c: C.mpp_frame_get_sar(*f.c)}
|
||||
}
|
||||
|
||||
func (f *MppFrame) SetSar(sar *MppFrameRational) {
|
||||
C.mpp_frame_set_sar(*f.c, sar.c)
|
||||
}
|
||||
|
||||
func (f *MppFrame) GetMasteringDisplay() *MppFrameMasteringDisplayMetadata {
|
||||
return &MppFrameMasteringDisplayMetadata{c: C.mpp_frame_get_mastering_display(*f.c)}
|
||||
}
|
||||
|
||||
func (f *MppFrame) SetMasteringDisplay(masteringDisplay *MppFrameMasteringDisplayMetadata) {
|
||||
C.mpp_frame_set_mastering_display(*f.c, masteringDisplay.c)
|
||||
}
|
||||
|
||||
func (f *MppFrame) GetContentLight() *MppFrameContentLightMetadata {
|
||||
return &MppFrameContentLightMetadata{c: C.mpp_frame_get_content_light(*f.c)}
|
||||
}
|
||||
|
||||
func (f *MppFrame) SetContentLight(contentLight *MppFrameContentLightMetadata) {
|
||||
C.mpp_frame_set_content_light(*f.c, contentLight.c)
|
||||
}
|
||||
|
||||
func (f *MppFrame) GetHdrDynamicMeta() *MppFrameHdrDynamicMeta {
|
||||
return &MppFrameHdrDynamicMeta{c: C.mpp_frame_get_hdr_dynamic_meta(*f.c)}
|
||||
}
|
||||
|
||||
func (f *MppFrame) SetHdrDynamicMeta(hdrDynamicMeta *MppFrameHdrDynamicMeta) {
|
||||
C.mpp_frame_set_hdr_dynamic_meta(*f.c, hdrDynamicMeta.c)
|
||||
}
|
238
hdr_meta_com.go
Normal file
238
hdr_meta_com.go
Normal file
@@ -0,0 +1,238 @@
|
||||
package rkcodec
|
||||
|
||||
//#include <rockchip/rk_hdr_meta_com.h>
|
||||
import "C"
|
||||
|
||||
type HdrCodecType = C.HdrCodecType
|
||||
|
||||
const (
|
||||
HdrAVS2 = HdrCodecType(C.HDR_AVS2)
|
||||
HdrHEVC = HdrCodecType(C.HDR_HEVC)
|
||||
HdrH264 = HdrCodecType(C.HDR_H264)
|
||||
HdrAV1 = HdrCodecType(C.HDR_AV1)
|
||||
HdrCodecBut = HdrCodecType(C.HDR_CODEC_BUT)
|
||||
)
|
||||
|
||||
type HdrFormat = C.HdrFormat
|
||||
|
||||
const (
|
||||
HdrNone = HdrFormat(C.HDR_NONE)
|
||||
Hdr10 = HdrFormat(C.HDR10)
|
||||
Hlg = HdrFormat(C.HLG)
|
||||
// RESERVED3 = 3, //reserved for more future static hdr format
|
||||
// RESERVED4 = 4, //reserved for more future static hdr format
|
||||
Hdrvivid = HdrFormat(C.HDRVIVID)
|
||||
// RESERVED6 = 6, //reserved for hdr vivid
|
||||
// RESERVED7 = 7, //reserved for hdr vivid
|
||||
Hdr10plus = HdrFormat(C.HDR10PLUS)
|
||||
// RESERVED9 = 9, //reserved for hdr10+
|
||||
// RESERVED10 = 10,//reserved for hdr10+
|
||||
Dolby = HdrFormat(C.DOLBY)
|
||||
// RESERVED12 = 12, //reserved for other dynamic hdr format
|
||||
// RESERVED13 = 13, //reserved for other dynamic hdr format
|
||||
HdrFormatMax = HdrFormat(C.HDR_FORMAT_MAX)
|
||||
)
|
||||
|
||||
type HdrPayloadFormat = C.HdrPayloadFormat
|
||||
|
||||
const (
|
||||
HdrPayloadStatic = HdrPayloadFormat(C.STATIC)
|
||||
HdrPayloadDynamic = HdrPayloadFormat(C.DYNAMIC)
|
||||
HdrPayloadFormatMax = HdrPayloadFormat(C.HDR_PAYLOAD_FORMAT_MAX)
|
||||
)
|
||||
|
||||
type HdrStaticMeta struct {
|
||||
c C.HdrStaticMeta
|
||||
}
|
||||
|
||||
func (m *HdrStaticMeta) GetColorSpace() uint32 {
|
||||
return uint32(m.c.color_space)
|
||||
}
|
||||
|
||||
func (m *HdrStaticMeta) SetColorSpace(v uint32) {
|
||||
m.c.color_space = cU32(v)
|
||||
}
|
||||
|
||||
func (m *HdrStaticMeta) GetColorPrimaries() uint32 {
|
||||
return uint32(m.c.color_primaries)
|
||||
}
|
||||
|
||||
func (m *HdrStaticMeta) SetColorPrimaries(v uint32) {
|
||||
m.c.color_primaries = cU32(v)
|
||||
}
|
||||
|
||||
func (m *HdrStaticMeta) GetColorTrc() uint32 {
|
||||
return uint32(m.c.color_trc)
|
||||
}
|
||||
|
||||
func (m *HdrStaticMeta) SetColorTrc(v uint32) {
|
||||
m.c.color_trc = cU32(v)
|
||||
}
|
||||
|
||||
func (m *HdrStaticMeta) GetRedX() uint32 {
|
||||
return uint32(m.c.red_x)
|
||||
}
|
||||
|
||||
func (m *HdrStaticMeta) SetRedX(v uint32) {
|
||||
m.c.red_x = cU32(v)
|
||||
}
|
||||
|
||||
func (m *HdrStaticMeta) GetRedY() uint32 {
|
||||
return uint32(m.c.red_y)
|
||||
}
|
||||
|
||||
func (m *HdrStaticMeta) SetRedY(v uint32) {
|
||||
m.c.red_y = cU32(v)
|
||||
}
|
||||
|
||||
func (m *HdrStaticMeta) GetGreenX() uint32 {
|
||||
return uint32(m.c.green_x)
|
||||
}
|
||||
|
||||
func (m *HdrStaticMeta) SetGreenX(v uint32) {
|
||||
m.c.green_x = cU32(v)
|
||||
}
|
||||
|
||||
func (m *HdrStaticMeta) GetGreenY() uint32 {
|
||||
return uint32(m.c.green_y)
|
||||
}
|
||||
|
||||
func (m *HdrStaticMeta) SetGreenY(v uint32) {
|
||||
m.c.green_y = cU32(v)
|
||||
}
|
||||
|
||||
func (m *HdrStaticMeta) GetBlueX() uint32 {
|
||||
return uint32(m.c.blue_x)
|
||||
}
|
||||
|
||||
func (m *HdrStaticMeta) SetBlueX(v uint32) {
|
||||
m.c.blue_x = cU32(v)
|
||||
}
|
||||
|
||||
func (m *HdrStaticMeta) GetBlueY() uint32 {
|
||||
return uint32(m.c.blue_y)
|
||||
}
|
||||
|
||||
func (m *HdrStaticMeta) SetBlueY(v uint32) {
|
||||
m.c.blue_y = cU32(v)
|
||||
}
|
||||
|
||||
func (m *HdrStaticMeta) GetWhitePointX() uint32 {
|
||||
return uint32(m.c.white_point_x)
|
||||
}
|
||||
|
||||
func (m *HdrStaticMeta) SetWhitePointX(v uint32) {
|
||||
m.c.white_point_x = cU32(v)
|
||||
}
|
||||
|
||||
func (m *HdrStaticMeta) GetWhitePointY() uint32 {
|
||||
return uint32(m.c.white_point_y)
|
||||
}
|
||||
|
||||
func (m *HdrStaticMeta) SetWhitePointY(v uint32) {
|
||||
m.c.white_point_y = cU32(v)
|
||||
}
|
||||
|
||||
func (m *HdrStaticMeta) GetMinLuminance() uint32 {
|
||||
return uint32(m.c.min_luminance)
|
||||
}
|
||||
|
||||
func (m *HdrStaticMeta) SetMinLuminance(v uint32) {
|
||||
m.c.min_luminance = cU32(v)
|
||||
}
|
||||
|
||||
func (m *HdrStaticMeta) GetMaxLuminance() uint32 {
|
||||
return uint32(m.c.max_luminance)
|
||||
}
|
||||
|
||||
func (m *HdrStaticMeta) SetMaxLuminance(v uint32) {
|
||||
m.c.max_luminance = cU32(v)
|
||||
}
|
||||
|
||||
func (m *HdrStaticMeta) GetMaxCll() uint32 {
|
||||
return uint32(m.c.max_cll)
|
||||
}
|
||||
|
||||
func (m *HdrStaticMeta) SetMaxCll(v uint32) {
|
||||
m.c.max_cll = cU32(v)
|
||||
}
|
||||
|
||||
func (m *HdrStaticMeta) GetMaxFall() uint32 {
|
||||
return uint32(m.c.max_fall)
|
||||
}
|
||||
|
||||
func (m *HdrStaticMeta) SetMaxFall(v uint32) {
|
||||
m.c.max_fall = cU32(v)
|
||||
}
|
||||
|
||||
type RkMetaHdrHeader struct {
|
||||
c C.RkMetaHdrHeader
|
||||
}
|
||||
|
||||
func (m *RkMetaHdrHeader) GetMagic() uint16 {
|
||||
return uint16(m.c.magic)
|
||||
}
|
||||
|
||||
func (m *RkMetaHdrHeader) SetMagic(v uint16) {
|
||||
m.c.magic = cU16(v)
|
||||
}
|
||||
|
||||
func (m *RkMetaHdrHeader) GetSize() uint16 {
|
||||
return uint16(m.c.size)
|
||||
}
|
||||
|
||||
func (m *RkMetaHdrHeader) SetSize(v uint16) {
|
||||
m.c.size = cU16(v)
|
||||
}
|
||||
|
||||
func (m *RkMetaHdrHeader) GetMessageTotal() uint16 {
|
||||
return uint16(m.c.message_total)
|
||||
}
|
||||
|
||||
func (m *RkMetaHdrHeader) SetMessageTotal(v uint16) {
|
||||
m.c.message_total = cU16(v)
|
||||
}
|
||||
|
||||
func (m *RkMetaHdrHeader) GetMessageIndex() uint16 {
|
||||
return uint16(m.c.message_index)
|
||||
}
|
||||
|
||||
func (m *RkMetaHdrHeader) SetMessageIndex(v uint16) {
|
||||
m.c.message_index = cU16(v)
|
||||
}
|
||||
|
||||
func (m *RkMetaHdrHeader) GetVersion() uint16 {
|
||||
return uint16(m.c.version)
|
||||
}
|
||||
|
||||
func (m *RkMetaHdrHeader) SetVersion(v uint16) {
|
||||
m.c.version = cU16(v)
|
||||
}
|
||||
|
||||
func (m *RkMetaHdrHeader) GetHdrFormat() uint16 {
|
||||
return uint16(m.c.hdr_format)
|
||||
}
|
||||
|
||||
func (m *RkMetaHdrHeader) SetHdrFormat(v uint16) {
|
||||
m.c.hdr_format = cU16(v)
|
||||
}
|
||||
|
||||
func (m *RkMetaHdrHeader) GetHdrPayloadType() uint16 {
|
||||
return uint16(m.c.hdr_payload_type)
|
||||
}
|
||||
|
||||
func (m *RkMetaHdrHeader) SetHdrPayloadType(v uint16) {
|
||||
m.c.hdr_payload_type = cU16(v)
|
||||
}
|
||||
|
||||
func (m *RkMetaHdrHeader) GetVideoFormat() uint16 {
|
||||
return uint16(m.c.video_format)
|
||||
}
|
||||
|
||||
func (m *RkMetaHdrHeader) SetVideoFormat(v uint16) {
|
||||
m.c.video_format = cU16(v)
|
||||
}
|
||||
|
||||
func (f *MppFrame) FillHdrMeta(t HdrCodecType) {
|
||||
C.fill_hdr_meta_to_frame(*f.c, C.HdrCodecType(t))
|
||||
}
|
194
meta.go
Normal file
194
meta.go
Normal file
@@ -0,0 +1,194 @@
|
||||
package rkcodec
|
||||
|
||||
//#include <rockchip/mpp_meta.h>
|
||||
//#include <rockchip/rk_type.h>
|
||||
import "C"
|
||||
import "unsafe"
|
||||
|
||||
type MppMetaType = cU32
|
||||
|
||||
const (
|
||||
MetaTypeFrame = MppMetaType(C.TYPE_FRAME)
|
||||
MetaTypePacket = MppMetaType(C.TYPE_PACKET)
|
||||
MetaTypeBuffer = MppMetaType(C.TYPE_BUFFER)
|
||||
|
||||
MetaTypeS32 = MppMetaType(C.TYPE_S32)
|
||||
MetaTypeS64 = MppMetaType(C.TYPE_S64)
|
||||
MetaTypePtr = MppMetaType(C.TYPE_PTR)
|
||||
)
|
||||
|
||||
type MppMetaKey = C.MppMetaKey
|
||||
|
||||
const (
|
||||
// data flow key
|
||||
MetaKeyInputFrame = MppMetaKey(C.KEY_INPUT_FRAME)
|
||||
MetaKeyInputPacket = MppMetaKey(C.KEY_INPUT_PACKET)
|
||||
MetaKeyOutputFrame = MppMetaKey(C.KEY_OUTPUT_FRAME)
|
||||
MetaKeyOutputPacket = MppMetaKey(C.KEY_OUTPUT_PACKET)
|
||||
// output motion information for motion detection
|
||||
MetaKeyMotionInfo = MppMetaKey(C.KEY_MOTION_INFO)
|
||||
MetaKeyHdrInfo = MppMetaKey(C.KEY_HDR_INFO)
|
||||
MetaKeyHdrMetaOffset = MppMetaKey(C.KEY_HDR_META_OFFSET)
|
||||
MetaKeyHdrMetaSize = MppMetaKey(C.KEY_HDR_META_SIZE)
|
||||
|
||||
// flow control key
|
||||
MetaKeyInputBlock = MppMetaKey(C.KEY_INPUT_BLOCK)
|
||||
MetaKeyOutputBlock = MppMetaKey(C.KEY_OUTPUT_BLOCK)
|
||||
MetaKeyInputIdrReq = MppMetaKey(C.KEY_INPUT_IDR_REQ) // input idr frame request flag
|
||||
MetaKeyOutputIntra = MppMetaKey(C.KEY_OUTPUT_INTRA) // output intra frame indicator
|
||||
|
||||
// mpp_frame / mpp_packet meta data info key
|
||||
MetaKeyTemporalId = MppMetaKey(C.KEY_TEMPORAL_ID)
|
||||
MetaKeyLongRefIdx = MppMetaKey(C.KEY_LONG_REF_IDX)
|
||||
MetaKeyEncAverageQp = MppMetaKey(C.KEY_ENC_AVERAGE_QP)
|
||||
MetaKeyEncStartQp = MppMetaKey(C.KEY_ENC_START_QP)
|
||||
MetaKeyRoiData = MppMetaKey(C.KEY_ROI_DATA)
|
||||
MetaKeyOsdData = MppMetaKey(C.KEY_OSD_DATA)
|
||||
MetaKeyOsdData2 = MppMetaKey(C.KEY_OSD_DATA2)
|
||||
MetaKeyUserData = MppMetaKey(C.KEY_USER_DATA)
|
||||
MetaKeyUserDatas = MppMetaKey(C.KEY_USER_DATAS)
|
||||
|
||||
// num of inter different size predicted block
|
||||
MetaKeyLvl64InterNum = MppMetaKey(C.KEY_LVL64_INTER_NUM)
|
||||
MetaKeyLvl32InterNum = MppMetaKey(C.KEY_LVL32_INTER_NUM)
|
||||
MetaKeyLvl16InterNum = MppMetaKey(C.KEY_LVL16_INTER_NUM)
|
||||
MetaKeyLvl8InterNum = MppMetaKey(C.KEY_LVL8_INTER_NUM)
|
||||
// num of intra different size predicted block
|
||||
MetaKeyLvl32IntraNum = MppMetaKey(C.KEY_LVL32_INTRA_NUM)
|
||||
MetaKeyLvl16IntraNum = MppMetaKey(C.KEY_LVL16_INTRA_NUM)
|
||||
MetaKeyLvl8IntraNum = MppMetaKey(C.KEY_LVL8_INTRA_NUM)
|
||||
MetaKeyLvl4IntraNum = MppMetaKey(C.KEY_LVL4_INTRA_NUM)
|
||||
// output P skip frame indicator
|
||||
MetaKeyOutputPskip = MppMetaKey(C.KEY_OUTPUT_PSKIP)
|
||||
MetaKeyEncSse = MppMetaKey(C.KEY_ENC_SSE)
|
||||
|
||||
// For vepu580 roi buffer config mode
|
||||
MetaKeyRoiData2 = MppMetaKey(C.KEY_ROI_DATA2)
|
||||
|
||||
// qpmap for rv1109/1126 encoder qpmap config
|
||||
MetaKeyQpmap0 = MppMetaKey(C.KEY_QPMAP0)
|
||||
|
||||
// input motion list for smart p rate control
|
||||
MetaKeyMvList = MppMetaKey(C.KEY_MV_LIST)
|
||||
|
||||
// frame long-term reference frame operation
|
||||
MetaKeyEncMarkLtr = MppMetaKey(C.KEY_ENC_MARK_LTR)
|
||||
MetaKeyEncUseLtr = MppMetaKey(C.KEY_ENC_USE_LTR)
|
||||
|
||||
// MLVEC specified encoder feature
|
||||
MetaKeyEncFrameQp = MppMetaKey(C.KEY_ENC_FRAME_QP)
|
||||
MetaKeyEncBaseLayerPid = MppMetaKey(C.KEY_ENC_BASE_LAYER_PID)
|
||||
|
||||
// Thumbnail info for decoder output frame
|
||||
MetaKeyDecTbnEn = MppMetaKey(C.KEY_DEC_TBN_EN)
|
||||
MetaKeyDecTbnYOffset = MppMetaKey(C.KEY_DEC_TBN_Y_OFFSET)
|
||||
MetaKeyDecTbnUvOffset = MppMetaKey(C.KEY_DEC_TBN_UV_OFFSET)
|
||||
)
|
||||
|
||||
func (m *MppMeta) GetWithTag(tag string, caller string) MppRet {
|
||||
return MppRet(C.mpp_meta_get_with_tag(&m.c, C.CString(tag), C.CString(caller)))
|
||||
}
|
||||
|
||||
func (m *MppMeta) Put() MppRet {
|
||||
return MppRet(C.mpp_meta_put(m.c))
|
||||
}
|
||||
|
||||
func (m *MppMeta) Size() int32 {
|
||||
return int32(C.mpp_meta_size(m.c))
|
||||
}
|
||||
|
||||
func (m *MppMeta) SetS32(key MppMetaKey, val int32) MppRet {
|
||||
return MppRet(C.mpp_meta_set_s32(m.c, key, C.RK_S32(val)))
|
||||
}
|
||||
|
||||
func (m *MppMeta) SetS64(key MppMetaKey, val int64) MppRet {
|
||||
return MppRet(C.mpp_meta_set_s64(m.c, key, C.RK_S64(val)))
|
||||
}
|
||||
|
||||
func (m *MppMeta) SetPtr(key MppMetaKey, val unsafe.Pointer) MppRet {
|
||||
return MppRet(C.mpp_meta_set_ptr(m.c, key, val))
|
||||
}
|
||||
|
||||
func (m *MppMeta) GetS32(key MppMetaKey) (int32, MppRet) {
|
||||
var val C.RK_S32
|
||||
ret := MppRet(C.mpp_meta_get_s32(m.c, key, &val))
|
||||
return int32(val), ret
|
||||
}
|
||||
|
||||
func (m *MppMeta) GetS64(key MppMetaKey) (int64, MppRet) {
|
||||
var val C.RK_S64
|
||||
ret := MppRet(C.mpp_meta_get_s64(m.c, key, &val))
|
||||
return int64(val), ret
|
||||
}
|
||||
|
||||
func (m *MppMeta) GetPtr(key MppMetaKey) (unsafe.Pointer, MppRet) {
|
||||
var val unsafe.Pointer
|
||||
ret := MppRet(C.mpp_meta_get_ptr(m.c, key, &val))
|
||||
return val, ret
|
||||
}
|
||||
|
||||
func (m *MppMeta) SetFrame(key MppMetaKey, frame MppFrame) MppRet {
|
||||
return MppRet(C.mpp_meta_set_frame(m.c, key, *frame.c))
|
||||
}
|
||||
|
||||
func (m *MppMeta) SetPacket(key MppMetaKey, packet MppPacket) MppRet {
|
||||
return MppRet(C.mpp_meta_set_packet(m.c, key, *packet.c))
|
||||
}
|
||||
|
||||
func (m *MppMeta) SetBuffer(key MppMetaKey, buffer MppBuffer) MppRet {
|
||||
return MppRet(C.mpp_meta_set_buffer(m.c, key, buffer.c))
|
||||
}
|
||||
|
||||
func (m *MppMeta) GetFrame(key MppMetaKey) (MppFrame, MppRet) {
|
||||
var frame MppFrame
|
||||
ret := MppRet(C.mpp_meta_get_frame(m.c, key, frame.c))
|
||||
return frame, ret
|
||||
}
|
||||
|
||||
func (m *MppMeta) GetPacket(key MppMetaKey) (MppPacket, MppRet) {
|
||||
var packet MppPacket
|
||||
ret := MppRet(C.mpp_meta_get_packet(m.c, key, packet.c))
|
||||
return packet, ret
|
||||
}
|
||||
|
||||
func (m *MppMeta) GetBuffer(key MppMetaKey) (MppBuffer, MppRet) {
|
||||
var buffer MppBuffer
|
||||
ret := MppRet(C.mpp_meta_get_buffer(m.c, key, &buffer.c))
|
||||
return buffer, ret
|
||||
}
|
||||
|
||||
func (m *MppMeta) GetS32D(key MppMetaKey, def int32) (int32, MppRet) {
|
||||
var val C.RK_S32
|
||||
ret := MppRet(C.mpp_meta_get_s32_d(m.c, key, &val, C.RK_S32(def)))
|
||||
return int32(val), ret
|
||||
}
|
||||
|
||||
func (m *MppMeta) GetS64D(key MppMetaKey, def int64) (int64, MppRet) {
|
||||
var val C.RK_S64
|
||||
ret := MppRet(C.mpp_meta_get_s64_d(m.c, key, &val, C.RK_S64(def)))
|
||||
return int64(val), ret
|
||||
}
|
||||
|
||||
func (m *MppMeta) GetPtrD(key MppMetaKey, def unsafe.Pointer) (unsafe.Pointer, MppRet) {
|
||||
var val unsafe.Pointer
|
||||
ret := MppRet(C.mpp_meta_get_ptr_d(m.c, key, &val, def))
|
||||
return val, ret
|
||||
}
|
||||
|
||||
func (m *MppMeta) GetFrameD(key MppMetaKey, def MppFrame) (MppFrame, MppRet) {
|
||||
var frame MppFrame
|
||||
ret := MppRet(C.mpp_meta_get_frame_d(m.c, key, frame.c, *def.c))
|
||||
return frame, ret
|
||||
}
|
||||
|
||||
func (m *MppMeta) GetPacketD(key MppMetaKey, def MppPacket) (MppPacket, MppRet) {
|
||||
var packet MppPacket
|
||||
ret := MppRet(C.mpp_meta_get_packet_d(m.c, key, packet.c, *def.c))
|
||||
return packet, ret
|
||||
}
|
||||
|
||||
func (m *MppMeta) GetBufferD(key MppMetaKey, def MppBuffer) (MppBuffer, MppRet) {
|
||||
var buffer MppBuffer
|
||||
ret := MppRet(C.mpp_meta_get_buffer_d(m.c, key, &buffer.c, def.c))
|
||||
return buffer, ret
|
||||
}
|
102
mpi.go
Normal file
102
mpi.go
Normal file
@@ -0,0 +1,102 @@
|
||||
package rkcodec
|
||||
|
||||
//#include <rockchip/rk_mpi.h>
|
||||
//#include "codec.h"
|
||||
import "C"
|
||||
import "unsafe"
|
||||
|
||||
type Codec struct {
|
||||
c *C.struct_MppCodec
|
||||
}
|
||||
|
||||
func NewMppCodec() *Codec {
|
||||
return &Codec{c: C.mpp_ctx_api_alloc()}
|
||||
}
|
||||
|
||||
func (c *Codec) Init(t MppCtxType, coding MppCodingType) MppRet {
|
||||
return MppRet(C.codec_init(c.c, C.MppCtxType(t), C.MppCodingType(coding)))
|
||||
}
|
||||
|
||||
func (c *Codec) Destroy() MppRet {
|
||||
return MppRet(C.codec_destroy(c.c))
|
||||
}
|
||||
|
||||
func (c *Codec) Size() uint32 {
|
||||
return uint32(C.codec_size(c.c))
|
||||
}
|
||||
|
||||
func (c *Codec) Version() uint32 {
|
||||
return uint32(C.codec_version(c.c))
|
||||
}
|
||||
|
||||
func (c *Codec) Decode(packet MppPacket, frame *MppFrame) MppRet {
|
||||
return MppRet(C.codec_decode(c.c, *packet.c, frame.c))
|
||||
}
|
||||
|
||||
func (c *Codec) DecodePutPacket(packet MppPacket) MppRet {
|
||||
return MppRet(C.codec_decode_put_packet(c.c, *packet.c))
|
||||
}
|
||||
|
||||
func (c *Codec) DecodeGetFrame(frame *MppFrame) MppRet {
|
||||
return MppRet(C.codec_decode_get_frame(c.c, frame.c))
|
||||
}
|
||||
|
||||
func (c *Codec) Encode(frame MppFrame, packet *MppPacket) MppRet {
|
||||
return MppRet(C.codec_encode(c.c, *frame.c, packet.c))
|
||||
}
|
||||
|
||||
func (c *Codec) EncodePutFrame(frame MppFrame) MppRet {
|
||||
return MppRet(C.codec_encode_put_frame(c.c, *frame.c))
|
||||
}
|
||||
|
||||
func (c *Codec) EncodeGetPacket(packet *MppPacket) MppRet {
|
||||
return MppRet(C.codec_encode_get_packet(c.c, packet.c))
|
||||
}
|
||||
|
||||
func (c *Codec) Isp(dst, src MppFrame) MppRet {
|
||||
return MppRet(C.codec_isp(c.c, *dst.c, *src.c))
|
||||
}
|
||||
|
||||
func (c *Codec) IspPutFrame(frame MppFrame) MppRet {
|
||||
return MppRet(C.codec_isp_put_frame(c.c, *frame.c))
|
||||
}
|
||||
|
||||
func (c *Codec) IspGetFrame(frame *MppFrame) MppRet {
|
||||
return MppRet(C.codec_isp_get_frame(c.c, frame.c))
|
||||
}
|
||||
|
||||
func (c *Codec) Poll(t MppPortType, timeout MppPollType) {
|
||||
C.codec_poll(c.c, C.MppPortType(t), C.MppPollType(timeout))
|
||||
}
|
||||
|
||||
func (c *Codec) Dequeue(t MppPortType, task *MppTask) MppRet {
|
||||
return MppRet(C.codec_dequeue(c.c, C.MppPortType(t), task.c))
|
||||
}
|
||||
|
||||
func (c *Codec) Enqueue(t MppPortType, task MppTask) MppRet {
|
||||
return MppRet(C.codec_enqueue(c.c, C.MppPortType(t), *task.c))
|
||||
}
|
||||
|
||||
func (c *Codec) Reset() MppRet {
|
||||
return MppRet(C.codec_reset(c.c))
|
||||
}
|
||||
|
||||
func (c *Codec) Control(cmd MpiCmd, param any) MppRet {
|
||||
point := unsafe.Pointer(¶m)
|
||||
return MppRet(C.codec_control(c.c, C.MpiCmd(cmd), point))
|
||||
}
|
||||
|
||||
// CheckSupportFormat Reutnr 0 for support, -1 for unsupport
|
||||
func CheckSupportFormat(t MppCtxType, coding MppCodingType) MppRet {
|
||||
return MppRet(C.mpp_check_support_format(C.MppCtxType(t), C.MppCodingType(coding)))
|
||||
}
|
||||
|
||||
// ShowSupportFormat No return value, It just print format info to standard output
|
||||
func ShowSupportFormat() {
|
||||
C.mpp_show_support_format()
|
||||
}
|
||||
|
||||
// ShowColorFormat No return value, It just print format info to standard output
|
||||
func ShowColorFormat() {
|
||||
C.mpp_show_color_format()
|
||||
}
|
131
mpi_cmd.go
Normal file
131
mpi_cmd.go
Normal file
@@ -0,0 +1,131 @@
|
||||
package rkcodec
|
||||
|
||||
//#include <rockchip/rk_mpi_cmd.h>
|
||||
import "C"
|
||||
|
||||
type MpiCmd = C.MpiCmd
|
||||
|
||||
const (
|
||||
MppOsalCmdBase = MpiCmd(C.MPP_OSAL_CMD_BASE)
|
||||
MppOsalCmdEnd = MpiCmd(C.MPP_OSAL_CMD_END)
|
||||
|
||||
MppCmdBase = MpiCmd(C.MPP_CMD_BASE)
|
||||
MppEnableDeinterlace = MpiCmd(C.MPP_ENABLE_DEINTERLACE)
|
||||
MppSetInputBlock = MpiCmd(C.MPP_SET_INPUT_BLOCK) // deprecated
|
||||
MppSetInputBlockTimeout = MpiCmd(C.MPP_SET_INTPUT_BLOCK_TIMEOUT) // deprecated
|
||||
MppSetOutputBlock = MpiCmd(C.MPP_SET_OUTPUT_BLOCK) // deprecated
|
||||
MppSetOutputBlockTimeout = MpiCmd(C.MPP_SET_OUTPUT_BLOCK_TIMEOUT) // deprecated
|
||||
|
||||
// timeout setup, refer to MPP_TIMEOUT_XXX
|
||||
MppSetInputTimeout = MpiCmd(C.MPP_SET_INPUT_TIMEOUT) // parameter type RK_S64
|
||||
MppSetOutputTimeout = MpiCmd(C.MPP_SET_OUTPUT_TIMEOUT) // parameter type RK_S64
|
||||
MppSetDisableThread = MpiCmd(C.MPP_SET_DISABLE_THREAD) // MPP no thread mode and use external thread to decode
|
||||
|
||||
MppStateCmdBase = MpiCmd(C.MPP_STATE_CMD_BASE)
|
||||
MppStart = MpiCmd(C.MPP_START)
|
||||
MppStop = MpiCmd(C.MPP_STOP)
|
||||
MppPause = MpiCmd(C.MPP_PAUSE)
|
||||
MppResume = MpiCmd(C.MPP_RESUME)
|
||||
|
||||
MppCmdEnd = MpiCmd(C.MPP_CMD_END)
|
||||
|
||||
MppCodecCmdBase = MpiCmd(C.MPP_CODEC_CMD_BASE)
|
||||
MppCodecGetFrameInfo = MpiCmd(C.MPP_CODEC_GET_FRAME_INFO)
|
||||
MppCodecCmdEnd = MpiCmd(C.MPP_CODEC_CMD_END)
|
||||
|
||||
MppDecCmdBase = MpiCmd(C.MPP_DEC_CMD_BASE)
|
||||
MppDecSetFrameInfo = MpiCmd(C.MPP_DEC_SET_FRAME_INFO) // vpu api legacy control for buffer slot dimension init
|
||||
MppDecSetExtBufGroup = MpiCmd(C.MPP_DEC_SET_EXT_BUF_GROUP) // IMPORTANT: set external buffer group to mpp decoder
|
||||
MppDecSetInfoChangeReady = MpiCmd(C.MPP_DEC_SET_INFO_CHANGE_READY)
|
||||
MppDecSetPresentTimeOrder = MpiCmd(C.MPP_DEC_SET_PRESENT_TIME_ORDER) // use input time order for output
|
||||
MppDecSetParserSplitMode = MpiCmd(C.MPP_DEC_SET_PARSER_SPLIT_MODE) // Need to setup before init
|
||||
MppDecSetParserFastMode = MpiCmd(C.MPP_DEC_SET_PARSER_FAST_MODE) // Need to setup before init
|
||||
MppDecGetStreamCount = MpiCmd(C.MPP_DEC_GET_STREAM_COUNT)
|
||||
MppDecGetVpumemUsedCount = MpiCmd(C.MPP_DEC_GET_VPUMEM_USED_COUNT)
|
||||
MppDecSetVc1ExtraData = MpiCmd(C.MPP_DEC_SET_VC1_EXTRA_DATA)
|
||||
MppDecSetOutputFormat = MpiCmd(C.MPP_DEC_SET_OUTPUT_FORMAT)
|
||||
MppDecSetDisableError = MpiCmd(C.MPP_DEC_SET_DISABLE_ERROR) // When set it will disable sw/hw error (H.264 / H.265)
|
||||
MppDecSetImmediateOut = MpiCmd(C.MPP_DEC_SET_IMMEDIATE_OUT)
|
||||
MppDecSetEnableDeinterlace = MpiCmd(C.MPP_DEC_SET_ENABLE_DEINTERLACE) // MPP enable deinterlace by default. Vpuapi can disable it
|
||||
MppDecSetEnableFastPlay = MpiCmd(C.MPP_DEC_SET_ENABLE_FAST_PLAY) // enable idr output immediately
|
||||
MppDecSetDisableThread = MpiCmd(C.MPP_DEC_SET_DISABLE_THREAD) // MPP no thread mode and use external thread to decode
|
||||
MppDecSetMaxUseBufferSize = MpiCmd(C.MPP_DEC_SET_MAX_USE_BUFFER_SIZE)
|
||||
MppDecSetEnableMVC = MpiCmd(C.MPP_DEC_SET_ENABLE_MVC) // enable MVC decoding
|
||||
|
||||
MppDecCmdQuery = MpiCmd(C.MPP_DEC_CMD_QUERY) // query decoder runtime information for decode stage
|
||||
// query decoder runtime information for decode stage
|
||||
MppDecQuery = MpiCmd(C.MPP_DEC_QUERY) // set and get MppDecQueryCfg structure
|
||||
|
||||
CmdDecCmdCfg = MpiCmd(C.CMD_DEC_CMD_CFG)
|
||||
MppDecSetCfg = MpiCmd(C.MPP_DEC_SET_CFG) // set MppDecCfg structure
|
||||
MppDecGetCfg = MpiCmd(C.MPP_DEC_GET_CFG) // get MppDecCfg structure
|
||||
|
||||
MppDecCmdEnd = MpiCmd(C.MPP_DEC_CMD_END)
|
||||
|
||||
MppEncCmdBase = MpiCmd(C.MPP_ENC_CMD_BASE)
|
||||
// basic encoder setup control
|
||||
MppEncSetCfg = MpiCmd(C.MPP_ENC_SET_CFG) // set MppEncCfg structure
|
||||
MppEncGetCfg = MpiCmd(C.MPP_ENC_GET_CFG) // get MppEncCfg structure
|
||||
MppEncSetPrepCfg = MpiCmd(C.MPP_ENC_SET_PREP_CFG) // deprecated set MppEncPrepCfg structure, use MPP_ENC_SET_CFG instead
|
||||
MppEncGetPrepCfg = MpiCmd(C.MPP_ENC_GET_PREP_CFG) // deprecated get MppEncPrepCfg structure, use MPP_ENC_GET_CFG instead
|
||||
MppEncSetRcCfg = MpiCmd(C.MPP_ENC_SET_RC_CFG) // deprecated set MppEncRcCfg structure, use MPP_ENC_SET_CFG instead
|
||||
MppEncGetRcCfg = MpiCmd(C.MPP_ENC_GET_RC_CFG) // deprecated get MppEncRcCfg structure, use MPP_ENC_GET_CFG instead
|
||||
MppEncSetCodecCfg = MpiCmd(C.MPP_ENC_SET_CODEC_CFG) // deprecated set MppEncCodecCfg structure, use MPP_ENC_SET_CFG instead
|
||||
MppEncGetCodecCfg = MpiCmd(C.MPP_ENC_GET_CODEC_CFG) // deprecated get MppEncCodecCfg structure, use MPP_ENC_GET_CFG instead
|
||||
// runtime encoder setup control
|
||||
MppEncSetIdrFrame = MpiCmd(C.MPP_ENC_SET_IDR_FRAME) // next frame will be encoded as intra frame
|
||||
MppEncSetOsdLegacy0 = MpiCmd(C.MPP_ENC_SET_OSD_LEGACY_0) // deprecated
|
||||
MppEncSetOsdLegacy1 = MpiCmd(C.MPP_ENC_SET_OSD_LEGACY_1) // deprecated
|
||||
MppEncSetOsdLegacy2 = MpiCmd(C.MPP_ENC_SET_OSD_LEGACY_2) // deprecated
|
||||
MppEncGetHdrSync = MpiCmd(C.MPP_ENC_GET_HDR_SYNC) // get vps / sps / pps which has better sync behavior parameter is MppPacket
|
||||
MppEncGetExtraInfo = MpiCmd(C.MPP_ENC_GET_EXTRA_INFO) // deprecated
|
||||
MppEncSetSeiCfg = MpiCmd(C.MPP_ENC_SET_SEI_CFG) // SEI: Supplement Enhancemant Information, parameter is MppSeiMode
|
||||
MppEncGetSeiData = MpiCmd(C.MPP_ENC_GET_SEI_DATA) // SEI: Supplement Enhancemant Information, parameter is MppPacket
|
||||
MppEncPreAllocBuff = MpiCmd(C.MPP_ENC_PRE_ALLOC_BUFF) // deprecated
|
||||
MppEncSetQpRange = MpiCmd(C.MPP_ENC_SET_QP_RANGE) // used for adjusting qp range, the parameter can be 1 or 2
|
||||
MppEncSetRoiCfg = MpiCmd(C.MPP_ENC_SET_ROI_CFG) // set MppEncROICfg structure
|
||||
MppEncSetCtuQp = MpiCmd(C.MPP_ENC_SET_CTU_QP) // for H265 Encoder,set CTU's size and QP
|
||||
|
||||
MppEncCmdQuery = MpiCmd(C.MPP_ENC_CMD_QUERY) // query encoder runtime information for encode stage
|
||||
// query encoder runtime information for encode stage
|
||||
MppEncQuery = MpiCmd(C.MPP_ENC_QUERY) // set and get MppEncQueryCfg structure
|
||||
|
||||
// User define rate control stategy API control
|
||||
MppEncCfgRcApi = MpiCmd(C.MPP_ENC_CFG_RC_API)
|
||||
// Get RcApiQueryAll structure
|
||||
MppEncGetRcApiAll = MpiCmd(C.MPP_ENC_GET_RC_API_ALL)
|
||||
// Get RcApiQueryType structure
|
||||
MppEncGetRcApiByType = MpiCmd(C.MPP_ENC_GET_RC_API_BY_TYPE)
|
||||
// Set RcImplApi structure
|
||||
MppEncSetRcApiCfg = MpiCmd(C.MPP_ENC_SET_RC_API_CFG)
|
||||
// Get RcApiBrief structure
|
||||
MppEncGetRcApiCurrent = MpiCmd(C.MPP_ENC_GET_RC_API_CURRENT)
|
||||
// Set RcApiBrief structure
|
||||
MppEncSetRcApiCurrent = MpiCmd(C.MPP_ENC_SET_RC_API_CURRENT)
|
||||
|
||||
MppEncCfgMisc = MpiCmd(C.MPP_ENC_CFG_MISC)
|
||||
MppEncSetHeaderMode = MpiCmd(C.MPP_ENC_SET_HEADER_MODE) // set MppEncHeaderMode
|
||||
MppEncGetHeaderMode = MpiCmd(C.MPP_ENC_GET_HEADER_MODE) // get MppEncHeaderMode
|
||||
|
||||
MppEncCfgSplit = MpiCmd(C.MPP_ENC_CFG_SPLIT)
|
||||
MppEncSetSplit = MpiCmd(C.MPP_ENC_SET_SPLIT) // set MppEncSliceSplit structure
|
||||
MppEncGetSplit = MpiCmd(C.MPP_ENC_GET_SPLIT) // get MppEncSliceSplit structure
|
||||
|
||||
MppEncCfgRef = MpiCmd(C.MPP_ENC_CFG_REF)
|
||||
MppEncSetRefCfg = MpiCmd(C.MPP_ENC_SET_REF_CFG) // set MppEncRefCfg structure
|
||||
|
||||
MppEncCfgOsd = MpiCmd(C.MPP_ENC_CFG_OSD)
|
||||
MppEncSetOsdPltCfg = MpiCmd(C.MPP_ENC_SET_OSD_PLT_CFG) // set OSD palette, parameter should be pointer to MppEncOSDPltCfg
|
||||
MppEncGetOsdPltCfg = MpiCmd(C.MPP_ENC_GET_OSD_PLT_CFG) // get OSD palette, parameter should be pointer to MppEncOSDPltCfg
|
||||
MppEncSetOsdDataCfg = MpiCmd(C.MPP_ENC_SET_OSD_DATA_CFG) // set OSD data with at most 8 regions, parameter should be pointer to MppEncOSDData
|
||||
|
||||
MppEncCmdEnd = MpiCmd(C.MPP_ENC_CMD_END)
|
||||
|
||||
MppIspCmdBase = MpiCmd(C.MPP_ISP_CMD_BASE)
|
||||
MppIspCmdEnd = MpiCmd(C.MPP_ISP_CMD_END)
|
||||
|
||||
MppHalCmdBase = MpiCmd(C.MPP_HAL_CMD_BASE)
|
||||
MppHalCmdEnd = MpiCmd(C.MPP_HAL_CMD_END)
|
||||
|
||||
MpiCmdButt = MpiCmd(C.MPI_CMD_BUTT)
|
||||
)
|
170
packet.go
Normal file
170
packet.go
Normal file
@@ -0,0 +1,170 @@
|
||||
package rkcodec
|
||||
|
||||
/*
|
||||
#include <rockchip/mpp_packet.h>
|
||||
|
||||
RK_S32 MppPktSeg_getType(const MppPktSeg seg) {
|
||||
return seg.type;
|
||||
}
|
||||
|
||||
void MppPktSeg_setType(MppPktSeg seg, RK_S32 type) {
|
||||
seg.type = type;
|
||||
}
|
||||
*/
|
||||
import "C"
|
||||
|
||||
func NewMppPacket() (*MppPacket, MppRet) {
|
||||
packet := new(MppPacket)
|
||||
ret := MppRet(C.mpp_packet_new(packet.c))
|
||||
return packet, ret
|
||||
}
|
||||
|
||||
// MPP_RET mpp_packet_init(MppPacket *packet, void *data, size_t size);
|
||||
func (packet *MppPacket) Init(data []byte, size int64) MppRet {
|
||||
return MppRet(C.mpp_packet_init(packet.c, C.CBytes(data), C.size_t(size)))
|
||||
}
|
||||
|
||||
func (packet *MppPacket) InitWithBuffer(buffer *MppBuffer) MppRet {
|
||||
return MppRet(C.mpp_packet_init_with_buffer(packet.c, buffer.c))
|
||||
}
|
||||
|
||||
func (packet *MppPacket) CopyInit(src *MppPacket) MppRet {
|
||||
return MppRet(C.mpp_packet_copy_init(packet.c, *src.c))
|
||||
}
|
||||
|
||||
func (packet *MppPacket) Deinit() MppRet {
|
||||
return MppRet(C.mpp_packet_deinit(packet.c))
|
||||
}
|
||||
|
||||
func (packet *MppPacket) GetData() []byte {
|
||||
return C.GoBytes(C.mpp_packet_get_data(*packet.c), C.int(C.mpp_packet_get_size(*packet.c)))
|
||||
}
|
||||
|
||||
func (packet *MppPacket) SetData(data []byte) {
|
||||
C.mpp_packet_set_data(*packet.c, C.CBytes(data))
|
||||
C.mpp_packet_set_size(*packet.c, C.size_t(len(data)))
|
||||
}
|
||||
|
||||
func (packet *MppPacket) SetPts(pts int64) {
|
||||
C.mpp_packet_set_pts(*packet.c, C.RK_S64(pts))
|
||||
}
|
||||
|
||||
func (packet *MppPacket) GetPts() int64 {
|
||||
return int64(C.mpp_packet_get_pts(*packet.c))
|
||||
}
|
||||
|
||||
func (packet *MppPacket) SetDts(dts int64) {
|
||||
C.mpp_packet_set_dts(*packet.c, C.RK_S64(dts))
|
||||
}
|
||||
|
||||
func (packet *MppPacket) GetDts() int64 {
|
||||
return int64(C.mpp_packet_get_dts(*packet.c))
|
||||
}
|
||||
|
||||
func (packet *MppPacket) SetFlag(flag uint32) {
|
||||
C.mpp_packet_set_flag(*packet.c, C.RK_U32(flag))
|
||||
}
|
||||
|
||||
func (packet *MppPacket) GetFlag() uint32 {
|
||||
return uint32(C.mpp_packet_get_flag(*packet.c))
|
||||
}
|
||||
|
||||
func (packet *MppPacket) SetEos() MppRet {
|
||||
return MppRet(C.mpp_packet_set_eos(*packet.c))
|
||||
}
|
||||
|
||||
func (packet *MppPacket) ClrEos() MppRet {
|
||||
return MppRet(C.mpp_packet_clr_eos(*packet.c))
|
||||
}
|
||||
|
||||
func (packet *MppPacket) GetEos() uint32 {
|
||||
return uint32(C.mpp_packet_get_eos(*packet.c))
|
||||
}
|
||||
|
||||
func (packet *MppPacket) SetExtraData() MppRet {
|
||||
return MppRet(C.mpp_packet_set_extra_data(*packet.c))
|
||||
}
|
||||
|
||||
func (packet *MppPacket) SetBuffer(buffer *MppBuffer) {
|
||||
C.mpp_packet_set_buffer(*packet.c, buffer.c)
|
||||
}
|
||||
|
||||
func (packet *MppPacket) GetBuffer() *MppBuffer {
|
||||
return &MppBuffer{c: C.mpp_packet_get_buffer(*packet.c)}
|
||||
}
|
||||
|
||||
func (packet *MppPacket) Read(offset int64, data []byte) MppRet {
|
||||
return MppRet(C.mpp_packet_read(*packet.c, C.size_t(offset), C.CBytes(data), C.size_t(len(data))))
|
||||
}
|
||||
|
||||
func (packet *MppPacket) Write(offset int64, data []byte) MppRet {
|
||||
return MppRet(C.mpp_packet_write(*packet.c, C.size_t(offset), C.CBytes(data), C.size_t(len(data))))
|
||||
}
|
||||
|
||||
func (packet *MppPacket) HasMeta() int32 {
|
||||
return int32(C.mpp_packet_has_meta(*packet.c))
|
||||
}
|
||||
|
||||
func (packet *MppPacket) GetMeta() *MppMeta {
|
||||
return &MppMeta{c: C.mpp_packet_get_meta(*packet.c)}
|
||||
}
|
||||
|
||||
func (packet *MppPacket) IsPartition() uint32 {
|
||||
return uint32(C.mpp_packet_is_partition(*packet.c))
|
||||
}
|
||||
|
||||
func (packet *MppPacket) IsSoi() uint32 {
|
||||
return uint32(C.mpp_packet_is_soi(*packet.c))
|
||||
}
|
||||
|
||||
func (packet *MppPacket) IsEoi() uint32 {
|
||||
return uint32(C.mpp_packet_is_eoi(*packet.c))
|
||||
}
|
||||
|
||||
type MppPktSeg struct {
|
||||
c C.struct_MppPktSeg_t
|
||||
}
|
||||
|
||||
func (seg *MppPktSeg) GetIndex() int32 {
|
||||
return int32(seg.c.index)
|
||||
}
|
||||
|
||||
func (seg *MppPktSeg) SetIndex(index int32) {
|
||||
seg.c.index = cS32(index)
|
||||
}
|
||||
|
||||
func (seg *MppPktSeg) GetType() int32 {
|
||||
return int32(C.MppPktSeg_getType(seg.c))
|
||||
}
|
||||
|
||||
func (seg *MppPktSeg) SetType(t int32) {
|
||||
C.MppPktSeg_setType(seg.c, cS32(t))
|
||||
}
|
||||
|
||||
func (seg *MppPktSeg) GetOffset() uint32 {
|
||||
return uint32(seg.c.offset)
|
||||
}
|
||||
|
||||
func (seg *MppPktSeg) SetOffset(offset uint32) {
|
||||
seg.c.offset = cU32(offset)
|
||||
}
|
||||
|
||||
func (seg *MppPktSeg) GetLength() uint32 {
|
||||
return uint32(seg.c.len)
|
||||
}
|
||||
|
||||
func (seg *MppPktSeg) SetLength(length uint32) {
|
||||
seg.c.len = cU32(length)
|
||||
}
|
||||
|
||||
func (seg *MppPktSeg) Next() *MppPktSeg {
|
||||
return &MppPktSeg{c: *seg.c.next}
|
||||
}
|
||||
|
||||
// func (packet *MppPacket) GetSengmentNb() uint32 {
|
||||
// return uint32(C.mpp_packet_get_sengment_nb(*packet.c))
|
||||
// }
|
||||
|
||||
// func (packet *MppPacket) GetSengment(index uint32) *MppPktSeg {
|
||||
// return &MppPktSeg{c: C.mpp_packet_get_sengment(*packet.c, C.RK_U32(index))}
|
||||
// }
|
97
task.go
Normal file
97
task.go
Normal file
@@ -0,0 +1,97 @@
|
||||
package rkcodec
|
||||
|
||||
//#include <rockchip/mpp_task.h>
|
||||
import "C"
|
||||
import "unsafe"
|
||||
|
||||
type MppPortType = C.MppPortType
|
||||
|
||||
const (
|
||||
MppPortInput = MppPortType(C.MPP_PORT_INPUT)
|
||||
MppPortOutput = MppPortType(C.MPP_PORT_OUTPUT)
|
||||
MppPortButt = MppPortType(C.MPP_PORT_BUTT)
|
||||
)
|
||||
|
||||
type MppTaskWorkMode = C.MppTaskWorkMode
|
||||
|
||||
const (
|
||||
MppTaskAsync = MppTaskWorkMode(C.MPP_TASK_ASYNC)
|
||||
MppTaskSync = MppTaskWorkMode(C.MPP_TASK_SYNC)
|
||||
MppTaskWorkModeButt = MppTaskWorkMode(C.MPP_TASK_WORK_MODE_BUTT)
|
||||
)
|
||||
|
||||
type MppPollType = C.MppPollType
|
||||
|
||||
const (
|
||||
MppPollButt = MppPollType(C.MPP_POLL_BUTT)
|
||||
MppPollBlock = MppPollType(C.MPP_POLL_BLOCK)
|
||||
MppPollNonBlock = MppPollType(C.MPP_POLL_NON_BLOCK)
|
||||
MppPollMax = MppPollType(C.MPP_POLL_MAX)
|
||||
)
|
||||
|
||||
const (
|
||||
MppTimeoutButt = C.MPP_TIMEOUT_BUTT
|
||||
MppTimeoutBlock = C.MPP_TIMEOUT_BLOCK
|
||||
MppTimeoutNonBlock = C.MPP_TIMEOUT_NON_BLOCK
|
||||
MppTimeoutMax = C.MPP_TIMEOUT_MAX
|
||||
)
|
||||
|
||||
func (task *MppTask) MetaSetS32(key MppMetaKey, val int32) MppRet {
|
||||
return MppRet(C.mpp_task_meta_set_s32(*task.c, C.MppMetaKey(key), cS32(val)))
|
||||
}
|
||||
|
||||
func (task *MppTask) MetaSetS64(key MppMetaKey, val int64) MppRet {
|
||||
return MppRet(C.mpp_task_meta_set_s64(*task.c, C.MppMetaKey(key), cS64(val)))
|
||||
}
|
||||
|
||||
func (task *MppTask) MetaSetPtr(key MppMetaKey, val unsafe.Pointer) MppRet {
|
||||
return MppRet(C.mpp_task_meta_set_ptr(*task.c, C.MppMetaKey(key), val))
|
||||
}
|
||||
|
||||
func (task *MppTask) MetaSetFrame(key MppMetaKey, frame *MppFrame) MppRet {
|
||||
return MppRet(C.mpp_task_meta_set_frame(*task.c, C.MppMetaKey(key), *frame.c))
|
||||
}
|
||||
|
||||
func (task *MppTask) MetaSetPacket(key MppMetaKey, packet *MppPacket) MppRet {
|
||||
return MppRet(C.mpp_task_meta_set_packet(*task.c, C.MppMetaKey(key), *packet.c))
|
||||
}
|
||||
|
||||
func (task *MppTask) MetaSetBuffer(key MppMetaKey, buffer MppBuffer) MppRet {
|
||||
return MppRet(C.mpp_task_meta_set_buffer(*task.c, C.MppMetaKey(key), buffer.c))
|
||||
}
|
||||
|
||||
func (task *MppTask) MetaGetS32(key MppMetaKey, defaultVal int32) (int32, MppRet) {
|
||||
var val cS32
|
||||
ret := MppRet(C.mpp_task_meta_get_s32(*task.c, C.MppMetaKey(key), &val, cS32(defaultVal)))
|
||||
return int32(val), ret
|
||||
}
|
||||
|
||||
func (task *MppTask) MetaGetS64(key MppMetaKey, defaultVal int64) (int64, MppRet) {
|
||||
var val cS64
|
||||
ret := MppRet(C.mpp_task_meta_get_s64(*task.c, C.MppMetaKey(key), &val, cS64(defaultVal)))
|
||||
return int64(val), ret
|
||||
}
|
||||
|
||||
func (task *MppTask) MetaGetPtr(key MppMetaKey, defaultVal unsafe.Pointer) (unsafe.Pointer, MppRet) {
|
||||
var val unsafe.Pointer
|
||||
ret := MppRet(C.mpp_task_meta_get_ptr(*task.c, C.MppMetaKey(key), &val, defaultVal))
|
||||
return val, ret
|
||||
}
|
||||
|
||||
func (task *MppTask) MetaGetFrame(key MppMetaKey) (*MppFrame, MppRet) {
|
||||
var frame MppFrame
|
||||
ret := MppRet(C.mpp_task_meta_get_frame(*task.c, C.MppMetaKey(key), frame.c))
|
||||
return &frame, ret
|
||||
}
|
||||
|
||||
func (task *MppTask) MetaGetPacket(key MppMetaKey) (*MppPacket, MppRet) {
|
||||
var packet MppPacket
|
||||
ret := MppRet(C.mpp_task_meta_get_packet(*task.c, C.MppMetaKey(key), packet.c))
|
||||
return &packet, ret
|
||||
}
|
||||
|
||||
func (task *MppTask) MetaGetBuffer(key MppMetaKey) (MppBuffer, MppRet) {
|
||||
var buffer MppBuffer
|
||||
ret := MppRet(C.mpp_task_meta_get_buffer(*task.c, C.MppMetaKey(key), &buffer.c))
|
||||
return buffer, ret
|
||||
}
|
78
type.go
78
type.go
@@ -1,5 +1,81 @@
|
||||
package rkcodec
|
||||
|
||||
//#cgo pkg-config: rockchip_mpp
|
||||
//#include <rockchip/rk_type.h>
|
||||
import "C"
|
||||
|
||||
type cU8 = C.RK_U8
|
||||
type cU16 = C.RK_U16
|
||||
type cU32 = C.RK_U32
|
||||
type cULONG = C.RK_ULONG
|
||||
type cU64 = C.RK_U64
|
||||
|
||||
type cS8 = C.RK_S8
|
||||
type cS16 = C.RK_S16
|
||||
type cS32 = C.RK_S32
|
||||
type cLONG = C.RK_LONG
|
||||
type cS64 = C.RK_S64
|
||||
|
||||
// type MppCtxType = C.enum_MppCtxType
|
||||
type MppCtxType = C.int
|
||||
|
||||
const (
|
||||
MppCtxDec = MppCtxType(C.MPP_CTX_DEC) // decoder
|
||||
MppCtxEnc = MppCtxType(C.MPP_CTX_ENC) // encoder
|
||||
MppCtxIsp = MppCtxType(C.MPP_CTX_ISP) // isp
|
||||
MppCtxButt = MppCtxType(C.MPP_CTX_BUTT) // undefined
|
||||
)
|
||||
|
||||
// type MppCodingType = C.enum_MppCodingType
|
||||
type MppCodingType = C.int
|
||||
|
||||
const (
|
||||
MppCodingUnused = MppCodingType(C.MPP_VIDEO_CodingUnused) // Value when coding is N/A
|
||||
MppCodingAutoDetect = MppCodingType(C.MPP_VIDEO_CodingAutoDetect) // Autodetection of coding type
|
||||
MppCodingMPEG2 = MppCodingType(C.MPP_VIDEO_CodingMPEG2) // AKA: H.262
|
||||
MppCodingH263 = MppCodingType(C.MPP_VIDEO_CodingH263) // H.263
|
||||
MppCodingMPEG4 = MppCodingType(C.MPP_VIDEO_CodingMPEG4) // MPEG-4
|
||||
MppCodingWMV = MppCodingType(C.MPP_VIDEO_CodingWMV) // Windows Media Video (WMV1,WMV2,WMV3)
|
||||
MppCodingRV = MppCodingType(C.MPP_VIDEO_CodingRV) // all versions of Real Video
|
||||
MppCodingAVC = MppCodingType(C.MPP_VIDEO_CodingAVC) // H.264/AVC
|
||||
MppCodingMJPEG = MppCodingType(C.MPP_VIDEO_CodingMJPEG) // Motion JPEG
|
||||
MppCodingVP8 = MppCodingType(C.MPP_VIDEO_CodingVP8) // VP8
|
||||
MppCodingVP9 = MppCodingType(C.MPP_VIDEO_CodingVP9) // VP9
|
||||
MppCodingVC1 = MppCodingType(C.MPP_VIDEO_CodingVC1) // Windows Media Video (WMV1,WMV2,WMV3)
|
||||
MppCodingFLV1 = MppCodingType(C.MPP_VIDEO_CodingFLV1) // Sorenson H.263
|
||||
MppCodingDIVX3 = MppCodingType(C.MPP_VIDEO_CodingDIVX3) // DIVX3
|
||||
MppCodingVP6 = MppCodingType(C.MPP_VIDEO_CodingVP6)
|
||||
MppCodingHEVC = MppCodingType(C.MPP_VIDEO_CodingHEVC) // H.265/HEVC
|
||||
MppCodingAVSPLUS = MppCodingType(C.MPP_VIDEO_CodingAVSPLUS) // AVS+
|
||||
MppCodingAVS = MppCodingType(C.MPP_VIDEO_CodingAVS) // AVS profile=0x20
|
||||
MppCodingAVS2 = MppCodingType(C.MPP_VIDEO_CodingAVS2) // AVS2
|
||||
MppCodingAV1 = MppCodingType(C.MPP_VIDEO_CodingAV1) // av1
|
||||
MppCodingKhronosExtensions = MppCodingType(C.MPP_VIDEO_CodingKhronosExtensions) // Reserved region for introducing Khronos Standard Extensions
|
||||
MppCodingVendorStartUnused = MppCodingType(C.MPP_VIDEO_CodingVendorStartUnused) // Reserved region for introducing Vendor Extensions
|
||||
MppCodingMax = MppCodingType(C.MPP_VIDEO_CodingMax)
|
||||
)
|
||||
|
||||
type MppCtx struct {
|
||||
c *C.MppCtx
|
||||
}
|
||||
type MppParam = *C.MppParam
|
||||
|
||||
type MppFrame struct {
|
||||
c *C.MppFrame
|
||||
}
|
||||
type MppPacket struct {
|
||||
c *C.MppPacket
|
||||
}
|
||||
|
||||
type MppBuffer struct {
|
||||
c C.MppBuffer
|
||||
}
|
||||
type MppBufferGroup struct {
|
||||
c *C.MppBufferGroup
|
||||
}
|
||||
|
||||
type MppTask struct {
|
||||
c *C.MppTask
|
||||
}
|
||||
type MppMeta struct {
|
||||
c C.MppMeta
|
||||
}
|
||||
|
18
type_test.go
Normal file
18
type_test.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package rkcodec
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestType(t *testing.T) {
|
||||
t.Log(MppCtxEnc)
|
||||
t.Log(MppSuccess)
|
||||
t.Log(MppErrUnknow)
|
||||
t.Log(MppBufferTypeButt)
|
||||
t.Log(MppBufferFlagsDMA32)
|
||||
t.Log(MppFramePrimariesNB)
|
||||
t.Log(MetaKeyDecTbnUvOffset)
|
||||
t.Log(HdrFormatMax)
|
||||
t.Log(MpiCmdButt)
|
||||
t.Log(MppTimeoutMax)
|
||||
}
|
Reference in New Issue
Block a user