[mpi]: add basic mpi empty function

git-svn-id: https://10.10.10.66:8443/svn/MediaProcessPlatform/trunk/mpp@114 6e48237b-75ef-9749-8fc9-41990f28c85a
This commit is contained in:
ChenHengming
2015-08-17 09:16:26 +00:00
parent 70671a1cca
commit 32c1b2f18c
9 changed files with 386 additions and 0 deletions

66
inc/mpp_buffer.h Normal file
View File

@@ -0,0 +1,66 @@
/*
* 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 __RK_MPI_BUFFER_H__
#define __RK_MPI_BUFFER_H__
#include "rk_type.h"
#include "mpp_err.h"
typedef void* MppBuffer;
typedef void* MppBufferPool;
typedef struct {
RK_U32 api_size;
RK_U32 api_version;
MPP_RET (*commit)(MppBufferPool pool, MppBuffer buffer);
MPP_RET (*get_unused)(MppBufferPool pool, MppBuffer *buffer);
MPP_RET (*ref_used)(MppBufferPool pool, MppBuffer buffer);
MPP_RET (*unref_used)(MppBufferPool pool, MppBuffer buffer);
MPP_RET (*reset)(MppBufferPool pool);
RK_S32 (*get_unsed_num)(MppBufferPool pool);
RK_U32 reserv[16];
} MppBufferPoolApi;
#ifdef __cplusplus
extern "C" {
#endif
/*
* MppBufferPool interface
*/
MPP_RET mpp_buffer_init(MppBuffer *buffer, RK_U32 type, RK_U32 size);
MPP_RET mpp_buffer_deinit(MppBuffer *buffer);
MPP_RET mpp_buffer_inc_ref(MppBuffer buffer);
MPP_RET mpp_buffer_dec_ref(MppBuffer buffer);
/*
* MppBufferPool interface
*/
MPP_RET mpp_buffer_pool_init(MppBufferPool *pool, RK_U32 count, RK_U32 size);
MPP_RET mpp_buffer_pool_get_api(MppBufferPool pool, MppBufferPoolApi *api);
MPP_RET mpp_buffer_pool_deinit(MppBufferPool *pool);
#ifdef __cplusplus
}
#endif
#endif /*__RK_MPI_BUFFER_H__*/

View File

@@ -25,6 +25,9 @@ typedef enum {
MPP_OK = RK_OK, MPP_OK = RK_OK,
MPP_ERR_UNKNOW = -1, MPP_ERR_UNKNOW = -1,
MPP_ERR_NULL_PTR = -2,
MPP_ERR_MALLOC = -3,
MPP_ERR_BASE = -1000, MPP_ERR_BASE = -1000,
MPP_ERR_LIST_STREAM = MPP_ERR_BASE - 1, MPP_ERR_LIST_STREAM = MPP_ERR_BASE - 1,

41
inc/mpp_frame.h Normal file
View File

@@ -0,0 +1,41 @@
/*
* 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_FRAME_H__
#define __MPP_FRAME_H__
#include "rk_type.h"
#include "mpp_err.h"
typedef void* MppFrame;
#ifdef __cplusplus
extern "C" {
#endif
/*
* MppFrame interface
*/
MPP_RET mpp_frame_init(MppFrame *frame, RK_U8 *data, RK_U32 size);
MPP_RET mpp_frame_deinit(MppFrame *frame);
MPP_RET mpp_frame_get_info(MppFrame frame);
#ifdef __cplusplus
}
#endif
#endif /*__MPP_FRAME_H__*/

39
inc/mpp_packet.h Normal file
View File

@@ -0,0 +1,39 @@
/*
* 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_PACKET_H__
#define __MPP_PACKET_H__
#include "rk_type.h"
#include "mpp_err.h"
typedef void* MppPacket;
#ifdef __cplusplus
extern "C" {
#endif
/*
* MppPacket interface
*/
MPP_RET mpp_packet_init(MppPacket *packet, void *data, RK_U32 size);
MPP_RET mpp_packet_deinit(MppPacket *packet);
#ifdef __cplusplus
}
#endif
#endif /*__MPP_PACKET_H__*/

View File

@@ -17,5 +17,75 @@
#ifndef __RK_MPI_H__ #ifndef __RK_MPI_H__
#define __RK_MPI_H__ #define __RK_MPI_H__
#include "rk_type.h"
#include "mpp_err.h"
#include "mpp_packet.h"
#include "mpp_buffer.h"
#include "mpp_frame.h"
typedef enum {
MPI_MPP_CMD_BASE = 0,
MPI_MPP_ENABLE_DEINTERLACE,
MPI_HAL_CMD_BASE = 0x10000,
MPI_OSAL_CMD_BASE = 0x20000,
MPI_OSAL_SET_VPUMEM_CONTEXT,
MPI_CODEC_CMD_BASE = 0x30000,
MPI_CODEC_INFO_CHANGE,
MPI_CODEC_SET_DEFAULT_WIDTH_HEIGH,
MPI_DEC_CMD_BASE = 0x40000,
MPI_DEC_USE_PRESENT_TIME_ORDER,
MPI_ENC_CMD_BASE = 0x50000,
MPI_ENC_SETCFG,
MPI_ENC_GETCFG,
MPI_ENC_SETFORMAT,
MPI_ENC_SETIDRFRAME,
} MPI_CMD;
typedef void* MppCtx;
typedef void* MppParam;
typedef struct {
RK_U32 mpi_size;
RK_U32 mpi_version;
MPP_RET (*init)(MppCtx ctx, MppPacket packet);
// sync interface
MPP_RET (*decode)(MppCtx ctx, MppPacket packet, MppFrame *frame);
MPP_RET (*encode)(MppCtx ctx, MppFrame frame, MppPacket *packet);
// async interface
MPP_RET (*decode_put_packet)(MppCtx ctx, MppPacket packet);
MPP_RET (*decode_get_frame)(MppCtx ctx, MppFrame *frame);
MPP_RET (*encode_put_frame)(MppCtx ctx, MppFrame frame);
MPP_RET (*encode_get_packet)(MppCtx ctx, MppPacket *packet);
MPP_RET (*flush)(MppCtx ctx);
MPP_RET (*control)(MppCtx ctx, MPI_CMD cmd, MppParam param);
RK_U32 reserv[16];
} MppApi;
#ifdef __cplusplus
extern "C" {
#endif
/*
* mpp interface
*/
MPP_RET mpp_init(MppCtx *ctx, MppApi **mpi);
MPP_RET mpp_deinit(MppCtx* ctx);
#ifdef __cplusplus
}
#endif
#endif /*__RK_MPI_H__*/ #endif /*__RK_MPI_H__*/

View File

@@ -21,6 +21,8 @@ add_subdirectory(hal)
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
add_library(mpp STATIC add_library(mpp STATIC
mpp_info.cpp mpp_info.cpp
mpi_impl.cpp
mpi.cpp
) )
add_subdirectory(legacy) add_subdirectory(legacy)

88
mpp/mpi.cpp Normal file
View File

@@ -0,0 +1,88 @@
/*
* 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.
*/
#define MODULE_TAG "mpi"
#include <string.h>
#include "rk_mpi.h"
#include "mpp_log.h"
#include "mpp_mem.h"
#include "mpi_impl.h"
MPP_RET mpp_init(MppCtx *ctx, MppApi **mpi)
{
MpiImpl *p;
MppApi *api;
MPI_FUNCTION_ENTER();
if (NULL == ctx || NULL == mpi) {
mpp_err("mpp_init input ctx %p mpi %p found null pointer\n",
ctx, mpi);
return MPP_ERR_NULL_PTR;
}
p = mpp_malloc(MpiImpl, 1);
if (NULL == p) {
mpp_err("mpp_init failed to allocate context\n");
return MPP_ERR_MALLOC;
}
api = mpp_malloc(MppApi, 1);
if (NULL == api) {
mpp_err("mpp_init failed to allocate mpi\n");
mpp_free(p);
return MPP_ERR_MALLOC;
}
memset(p, 0, sizeof(*p));
memset(api, 0, sizeof(*api));
p->api = api;
p->check = p;
*ctx = p;
MPI_FUNCTION_LEAVE_OK();
return MPP_OK;
}
MPP_RET mpp_deinit(MppCtx* ctx)
{
MpiImpl *p;
MPI_FUNCTION_ENTER();
if (NULL == ctx) {
mpp_err("mpp_deinit input ctx %p is null pointer\n", ctx);
return MPP_ERR_NULL_PTR;
}
p = (MpiImpl*)*ctx;
if (p->check != p) {
mpp_err("mpp_deinit input invalid MppCtx\n");
return MPP_ERR_UNKNOW;
}
if (p->api)
mpp_free(p->api);
if (p)
mpp_free(p->api);
MPI_FUNCTION_LEAVE();
return MPP_OK;
}

24
mpp/mpi_impl.cpp Normal file
View File

@@ -0,0 +1,24 @@
/*
* 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.
*/
#define MODULE_TAG "mpi"
#include "rk_mpi.h"
#include "mpp_log.h"
#include "mpi_impl.h"
RK_U32 mpi_debug = 0;

53
mpp/mpi_impl.h Normal file
View File

@@ -0,0 +1,53 @@
/*
* 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_IMPL_H__
#define __MPP_IMPL_H__
#include "rk_type.h"
#include "rk_mpi.h"
#include "vpu_api.h"
#define MPI_DBG_FUNCTION (0x00000001)
#define mpi_dbg(flag, fmt, ...) mpp_dbg(mpi_debug, flag, fmt, ## __VA_ARGS__)
#define MPI_FUNCTION_ENTER() mpi_dbg(MPI_DBG_FUNCTION, "%s enter\n", __FUNCTION__)
#define MPI_FUNCTION_LEAVE() mpi_dbg(MPI_DBG_FUNCTION, "%s leave\n", __FUNCTION__)
#define MPI_FUNCTION_LEAVE_OK() mpi_dbg(MPI_DBG_FUNCTION, "%s success\n", __FUNCTION__)
#define MPI_FUNCTION_LEAVE_FAIL() mpi_dbg(MPI_DBG_FUNCTION, "%s failed\n", __FUNCTION__)
typedef struct MpiImpl_t MpiImpl;
struct MpiImpl_t {
MpiImpl *check;
MppApi *api;
void *ctx;
};
#ifdef __cplusplus
extern "C" {
#endif
extern RK_U32 mpi_debug;
#ifdef __cplusplus
}
#endif
#endif /*__MPP_IMPL_H__*/