mirror of
https://github.com/nyanmisaka/mpp.git
synced 2025-10-04 00:36:23 +08:00

git-svn-id: https://10.10.10.66:8443/svn/MediaProcessPlatform/trunk/mpp@119 6e48237b-75ef-9749-8fc9-41990f28c85a
104 lines
3.3 KiB
C
104 lines
3.3 KiB
C
/*
|
|
* Copyright 2010 Rockchip Electronics S.LSI 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"
|
|
|
|
typedef void* MppBuffer;
|
|
typedef void* MppBufferGroup;
|
|
|
|
/*
|
|
* mpp buffer pool support two buffer malloc mode:
|
|
*
|
|
* native mode: all buffer are generated by mpp and buffer type can be read from MppBuffer
|
|
* under this mode, buffer pool is maintained internally
|
|
*
|
|
* typical call flow:
|
|
*
|
|
* mpp_buffer_get() return a
|
|
* mpp_buffer_inc_ref(a)
|
|
* mpp_buffer_put(a)
|
|
* mpp_buffer_put(a)
|
|
*
|
|
* commit mode: all buffer are commited out of mpp
|
|
* under this mode, buffer pool is controlled by external api
|
|
*
|
|
* typical call flow:
|
|
*
|
|
* ==== external allocator ====
|
|
* mpp_buffer_commit(a)
|
|
* mpp_buffer_commit(b)
|
|
*
|
|
* ======= internal user ======
|
|
* mpp_buffer_get() return a
|
|
* mpp_buffer_get() return b
|
|
* mpp_buffer_put(a)
|
|
* mpp_buffer_put(b)
|
|
*
|
|
* ==== external allocator ====
|
|
* mpp_buffer_commit(a)
|
|
* mpp_buffer_commit(b)
|
|
*
|
|
* NOTE: commit/remove interface required group handle to record
|
|
* buffer group information
|
|
*/
|
|
typedef enum {
|
|
MPP_BUFFER_MODE_NATIVE,
|
|
MPP_BUFFER_MODE_COMMIT,
|
|
} MppBufferMode;
|
|
|
|
/*
|
|
* mpp buffer has two types:
|
|
*
|
|
* normal : normal malloc buffer for unit test or hardware simulation
|
|
* ion : use ion device under Android/Linux, MppBuffer will encapsulte ion file handle
|
|
*/
|
|
typedef enum {
|
|
MPP_BUFFER_TYPE_NORMAL,
|
|
MPP_BUFFER_TYPE_ION,
|
|
MPP_BUFFER_TYPE_BUTT,
|
|
} MppBufferType;
|
|
|
|
#define mpp_buffer_commit(...) _mpp_buffer_commit(MODULE_TAG, ## __VA_ARGS__)
|
|
#define mpp_buffer_remove(...) _mpp_buffer_remove(MODULE_TAG, ## __VA_ARGS__)
|
|
|
|
#define mpp_buffer_get(...) _mpp_buffer_get(MODULE_TAG, ## __VA_ARGS__)
|
|
#define mpp_buffer_put(...) _mpp_buffer_put(MODULE_TAG, ## __VA_ARGS__)
|
|
#define mpp_buffer_inc_ref(...) _mpp_buffer_inc_ref(MODULE_TAG, ## __VA_ARGS__)
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
/*
|
|
* MppBuffer interface
|
|
*/
|
|
MPP_RET _mpp_buffer_commit(const char *tag, MppBufferGroup *group, MppBuffer *buffer, MppBufferType type, size_t size);
|
|
MPP_RET _mpp_buffer_remove(const char *tag, MppBufferGroup *group, MppBuffer *buffer);
|
|
|
|
MPP_RET _mpp_buffer_get(const char *tag, MppBuffer *buffer, size_t size);
|
|
MPP_RET _mpp_buffer_put(const char *tag, MppBuffer *buffer);
|
|
MPP_RET _mpp_buffer_inc_ref(const char *tag, MppBuffer buffer);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /*__MPP_BUFFER_H__*/
|