1/* 2 * Copyright (c) 2021 Rockchip Electronics Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16#ifndef __MPP_ALLOCATOR_H__ 17#define __MPP_ALLOCATOR_H__ 18 19#include "rk_type.h" 20#include "mpp_buffer.h" 21 22typedef void *MppAllocator; 23 24typedef struct MppAllocatorCfg_t { 25 // input 26 size_t alignment; 27 unsigned int flags; 28} MppAllocatorCfg; 29 30typedef struct MppAllocatorApi_t { 31 unsigned int size; 32 unsigned int version; 33 34 MPP_RET (*alloc)(MppAllocator allocator, MppBufferInfo *data); 35 MPP_RET (*free)(MppAllocator allocator, MppBufferInfo *data); 36 MPP_RET (*import)(MppAllocator allocator, MppBufferInfo *data); 37 MPP_RET (*release)(MppAllocator allocator, MppBufferInfo *data); 38 MPP_RET (*mmap)(MppAllocator allocator, MppBufferInfo *data); 39} MppAllocatorApi; 40 41#ifdef __cplusplus 42extern "C" { 43#endif 44 45MPP_RET mpp_allocator_get(MppAllocator *allocator, MppAllocatorApi **api, MppBufferType type); 46MPP_RET mpp_allocator_put(MppAllocator *allocator); 47 48#ifdef __cplusplus 49} 50#endif 51 52#endif /* __MPP_ALLOCATOR_H__ */ 53