mirror of
https://github.com/nyanmisaka/mpp.git
synced 2025-10-05 09:06:50 +08:00
[osal]: change mpp_buffer working flow and buffer limitation interface
git-svn-id: https://10.10.10.66:8443/svn/MediaProcessPlatform/trunk/mpp@136 6e48237b-75ef-9749-8fc9-41990f28c85a
This commit is contained in:
@@ -33,37 +33,69 @@
|
||||
#define SZ_64M (SZ_1M*64)
|
||||
#define SZ_80M (SZ_1M*80)
|
||||
|
||||
/*
|
||||
* MppBuffer module has several functions:
|
||||
*
|
||||
* 1. buffer get / put / reference management / and external commit.
|
||||
* this part is the basic user interface for MppBuffer.
|
||||
*
|
||||
* function:
|
||||
*
|
||||
* mpp_buffer_get
|
||||
* mpp_buffer_put
|
||||
* mpp_buffer_inc_ref
|
||||
* mpp_buffer_commit
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
typedef void* MppBuffer;
|
||||
typedef void* MppBufferGroup;
|
||||
|
||||
/*
|
||||
* mpp buffer pool support two buffer malloc mode:
|
||||
* mpp buffer group support two work flow mode:
|
||||
*
|
||||
* native mode: all buffer are generated by mpp and buffer type can be read from MppBuffer
|
||||
* 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_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 mode: all buffer are commited out of mpp
|
||||
* under this mode, buffer pool is controlled by external api
|
||||
* 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_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_get(A) return a
|
||||
* mpp_buffer_get(A) return b
|
||||
* mpp_buffer_put(a)
|
||||
* mpp_buffer_put(b)
|
||||
*
|
||||
@@ -72,9 +104,27 @@ typedef void* MppBufferGroup;
|
||||
*
|
||||
* 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_MODE_NATIVE,
|
||||
MPP_BUFFER_MODE_COMMIT,
|
||||
MPP_BUFFER_MODE_NORMAL,
|
||||
MPP_BUFFER_MODE_LIMIT,
|
||||
MPP_BUFFER_MODE_BUTT,
|
||||
} MppBufferMode;
|
||||
|
||||
/*
|
||||
@@ -86,6 +136,7 @@ typedef enum {
|
||||
typedef enum {
|
||||
MPP_BUFFER_TYPE_NORMAL,
|
||||
MPP_BUFFER_TYPE_ION,
|
||||
MPP_BUFFER_TYPE_V4L2,
|
||||
MPP_BUFFER_TYPE_BUTT,
|
||||
} MppBufferType;
|
||||
|
||||
@@ -101,10 +152,16 @@ typedef struct {
|
||||
MppBufferData data;
|
||||
} MppBufferCommit;
|
||||
|
||||
#define BUFFER_GROUP_SIZE_DEFAULT (SZ_1M*80)
|
||||
#define BUFFER_GROUP_SIZE_DEFAULT (SZ_1M*80)
|
||||
|
||||
#define mpp_buffer_get(...) mpp_buffer_get_with_tag(MODULE_TAG, ## __VA_ARGS__)
|
||||
#define mpp_buffer_group_get(...) mpp_buffer_group_get_with_tag(MODULE_TAG, ## __VA_ARGS__)
|
||||
#define mpp_buffer_get(...) \
|
||||
mpp_buffer_get_with_tag(MODULE_TAG, ## __VA_ARGS__)
|
||||
|
||||
#define mpp_buffer_group_normal_get(...) \
|
||||
mpp_buffer_group_get(MODULE_TAG, MPP_BUFFER_MODE_NORMAL, ## __VA_ARGS__)
|
||||
|
||||
#define mpp_buffer_group_limited_get(...) \
|
||||
mpp_buffer_group_get(MODULE_TAG, MPP_BUFFER_MODE_LIMIT, ## __VA_ARGS__)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -120,9 +177,9 @@ MPP_RET mpp_buffer_get_with_tag(const char *tag, MppBufferGroup group, MppBuffer
|
||||
MPP_RET mpp_buffer_put(MppBuffer *buffer);
|
||||
MPP_RET mpp_buffer_inc_ref(MppBuffer buffer);
|
||||
|
||||
MPP_RET mpp_buffer_group_get_with_tag(const char *tag, MppBufferGroup *group, MppBufferType type);
|
||||
MPP_RET mpp_buffer_group_get(const char *tag, MppBufferMode mode, MppBufferGroup *group, MppBufferType type);
|
||||
MPP_RET mpp_buffer_group_put(MppBufferGroup *group);
|
||||
MPP_RET mpp_buffer_group_set_limit(MppBufferGroup group, size_t limit);
|
||||
MPP_RET mpp_buffer_group_limit_config(MppBufferGroup group, size_t size, RK_S32 count);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
Reference in New Issue
Block a user