mirror of
https://github.com/nyanmisaka/mpp.git
synced 2025-10-06 09:36:49 +08:00
[mpi]: add more mpi log
git-svn-id: https://10.10.10.66:8443/svn/MediaProcessPlatform/trunk/mpp@1041 6e48237b-75ef-9749-8fc9-41990f28c85a
This commit is contained in:
@@ -25,6 +25,7 @@
|
||||
#define MPP_BUF_DBG_OPS_RUNTIME (0x00000002)
|
||||
#define MPP_BUF_DBG_OPS_HISTORY (0x00000004)
|
||||
#define MPP_BUF_DBG_CLR_ON_EXIT (0x00000008)
|
||||
#define MPP_BUF_DBG_CHECK_SIZE (0x00000010)
|
||||
|
||||
#define mpp_buf_dbg(flag, fmt, ...) _mpp_dbg(mpp_buffer_debug, flag, fmt, ## __VA_ARGS__)
|
||||
#define mpp_buf_dbg_f(flag, fmt, ...) _mpp_dbg_f(mpp_buffer_debug, flag, fmt, ## __VA_ARGS__)
|
||||
|
@@ -370,7 +370,8 @@ MppBufferImpl *mpp_buffer_get_unused(MppBufferGroupImpl *p, size_t size)
|
||||
if (!list_empty(&p->list_unused)) {
|
||||
MppBufferImpl *pos, *n;
|
||||
list_for_each_entry_safe(pos, n, &p->list_unused, MppBufferImpl, list_status) {
|
||||
//mpp_log("[RKV_DEBUG]pos->info.size=%d, size=%d \n", pos->info.size, size);
|
||||
mpp_buf_dbg(MPP_BUF_DBG_CHECK_SIZE, "request size %d on buf idx %d size %d\n",
|
||||
size, pos->buffer_id, pos->info.size);
|
||||
if (pos->info.size >= size) {
|
||||
buffer = pos;
|
||||
inc_buffer_ref_no_lock(buffer);
|
||||
|
283
mpp/mpi.cpp
283
mpp/mpi.cpp
@@ -59,223 +59,279 @@ static MPP_RET _check_mpp_ctx(MpiImpl *p, const char *caller)
|
||||
|
||||
static MPP_RET mpi_config(MppCtx ctx, MppEncConfig cfg)
|
||||
{
|
||||
(void)cfg;
|
||||
|
||||
MPI_FUNCTION_ENTER();
|
||||
MPP_RET ret = MPP_NOK;
|
||||
MpiImpl *p = (MpiImpl *)ctx;
|
||||
MPP_RET ret = check_mpp_ctx(p);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
MPI_FUNCTION_LEAVE();
|
||||
return MPP_OK;
|
||||
mpi_dbg_func("enter ctx %p cfg %p\n", ctx, cfg);
|
||||
do {
|
||||
ret = check_mpp_ctx(p);
|
||||
if (ret)
|
||||
break;
|
||||
|
||||
// TODO: do config here
|
||||
} while (0);
|
||||
|
||||
mpi_dbg_func("leave ret %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static MPP_RET mpi_decode(MppCtx ctx, MppPacket packet, MppFrame *frame)
|
||||
{
|
||||
(void)packet;
|
||||
(void)frame;
|
||||
|
||||
MPI_FUNCTION_ENTER();
|
||||
MPP_RET ret = MPP_NOK;
|
||||
MpiImpl *p = (MpiImpl *)ctx;
|
||||
MPP_RET ret = check_mpp_ctx(p);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
MPI_FUNCTION_LEAVE();
|
||||
return MPP_OK;
|
||||
mpi_dbg_func("enter ctx %p packet %p frame %p\n", ctx, packet, frame);
|
||||
do {
|
||||
ret = check_mpp_ctx(p);
|
||||
if (ret)
|
||||
break;
|
||||
|
||||
if (NULL == frame || NULL == packet) {
|
||||
mpp_err_f("found NULL input packet %p frame %p\n", packet, frame);
|
||||
ret = MPP_ERR_NULL_PTR;
|
||||
break;
|
||||
}
|
||||
// TODO: do decode here
|
||||
} while (0);
|
||||
|
||||
mpi_dbg_func("leave ret %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static MPP_RET mpi_decode_put_packet(MppCtx ctx, MppPacket packet)
|
||||
{
|
||||
MPI_FUNCTION_ENTER();
|
||||
|
||||
MPP_RET ret = MPP_NOK;
|
||||
MpiImpl *p = (MpiImpl *)ctx;
|
||||
MPP_RET ret = check_mpp_ctx(p);
|
||||
|
||||
mpi_dbg_func("enter ctx %p packet %p\n", ctx, packet);
|
||||
do {
|
||||
ret = check_mpp_ctx(p);
|
||||
if (ret)
|
||||
return ret;
|
||||
break;
|
||||
|
||||
if (NULL == packet) {
|
||||
mpp_err_f("found NULL input packet\n", packet);
|
||||
return MPP_ERR_NULL_PTR;
|
||||
mpp_err_f("found NULL input packet\n");
|
||||
ret = MPP_ERR_NULL_PTR;
|
||||
break;
|
||||
}
|
||||
|
||||
ret = p->ctx->put_packet(packet);
|
||||
} while (0);
|
||||
|
||||
MPI_FUNCTION_LEAVE();
|
||||
mpi_dbg_func("leave ret %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static MPP_RET mpi_decode_get_frame(MppCtx ctx, MppFrame *frame)
|
||||
{
|
||||
MPI_FUNCTION_ENTER();
|
||||
|
||||
MPP_RET ret = MPP_NOK;
|
||||
MpiImpl *p = (MpiImpl *)ctx;
|
||||
MPP_RET ret = check_mpp_ctx(p);
|
||||
|
||||
mpi_dbg_func("enter ctx %p frame %p\n", ctx, frame);
|
||||
do {
|
||||
ret = check_mpp_ctx(p);
|
||||
if (ret)
|
||||
return ret;
|
||||
break;
|
||||
|
||||
if (NULL == frame) {
|
||||
mpp_err_f("found NULL input frame\n", frame);
|
||||
return MPP_ERR_NULL_PTR;
|
||||
mpp_err_f("found NULL input frame\n");
|
||||
ret = MPP_ERR_NULL_PTR;
|
||||
break;
|
||||
}
|
||||
|
||||
ret = p->ctx->get_frame(frame);
|
||||
} while (0);
|
||||
|
||||
MPI_FUNCTION_LEAVE();
|
||||
mpi_dbg_func("leave ret %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static MPP_RET mpi_encode(MppCtx ctx, MppFrame frame, MppPacket *packet)
|
||||
{
|
||||
(void)packet;
|
||||
(void)frame;
|
||||
|
||||
MPI_FUNCTION_ENTER();
|
||||
MPP_RET ret = MPP_NOK;
|
||||
MpiImpl *p = (MpiImpl *)ctx;
|
||||
MPP_RET ret = check_mpp_ctx(p);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
MPI_FUNCTION_LEAVE();
|
||||
return MPP_OK;
|
||||
mpi_dbg_func("enter ctx %p frame %p packet %p\n", ctx, frame, packet);
|
||||
do {
|
||||
ret = check_mpp_ctx(p);
|
||||
if (ret)
|
||||
break;
|
||||
|
||||
if (NULL == frame || NULL == packet) {
|
||||
mpp_err_f("found NULL input frame %p packet %p\n", frame, packet);
|
||||
ret = MPP_ERR_NULL_PTR;
|
||||
break;
|
||||
}
|
||||
|
||||
// TODO: do encode here
|
||||
} while (0);
|
||||
|
||||
mpi_dbg_func("leave ret %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static MPP_RET mpi_encode_put_frame(MppCtx ctx, MppFrame frame)
|
||||
{
|
||||
MPI_FUNCTION_ENTER();
|
||||
|
||||
MPP_RET ret = MPP_NOK;
|
||||
MpiImpl *p = (MpiImpl *)ctx;
|
||||
MPP_RET ret = check_mpp_ctx(p);
|
||||
|
||||
mpi_dbg_func("enter ctx %p frame %p\n", ctx, frame);
|
||||
do {
|
||||
ret = check_mpp_ctx(p);
|
||||
if (ret)
|
||||
return ret;
|
||||
break;
|
||||
|
||||
if (NULL == frame) {
|
||||
mpp_err_f("found NULL input frame\n", frame);
|
||||
return MPP_ERR_NULL_PTR;
|
||||
mpp_err_f("found NULL input frame\n");
|
||||
ret = MPP_ERR_NULL_PTR;
|
||||
break;
|
||||
}
|
||||
|
||||
ret = p->ctx->put_frame(frame);
|
||||
} while (0);
|
||||
|
||||
MPI_FUNCTION_LEAVE();
|
||||
mpi_dbg_func("leave ret %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static MPP_RET mpi_encode_get_packet(MppCtx ctx, MppPacket *packet)
|
||||
{
|
||||
MPI_FUNCTION_ENTER();
|
||||
|
||||
MPP_RET ret = MPP_NOK;
|
||||
MpiImpl *p = (MpiImpl *)ctx;
|
||||
MPP_RET ret = check_mpp_ctx(p);
|
||||
|
||||
mpi_dbg_func("enter ctx %p packet %p\n", ctx, packet);
|
||||
do {
|
||||
ret = check_mpp_ctx(p);
|
||||
if (ret)
|
||||
return ret;
|
||||
break;
|
||||
|
||||
if (NULL == packet) {
|
||||
mpp_err_f("found NULL input packet\n", packet);
|
||||
return MPP_ERR_NULL_PTR;
|
||||
mpp_err_f("found NULL input packet\n");
|
||||
ret = MPP_ERR_NULL_PTR;
|
||||
break;
|
||||
}
|
||||
|
||||
ret = p->ctx->get_packet(packet);
|
||||
} while (0);
|
||||
|
||||
MPI_FUNCTION_LEAVE();
|
||||
mpi_dbg_func("leave ret %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static MPP_RET mpi_isp(MppCtx ctx, MppFrame dst, MppFrame src)
|
||||
{
|
||||
MPI_FUNCTION_ENTER();
|
||||
(void)ctx;
|
||||
(void)dst;
|
||||
(void)src;
|
||||
MPI_FUNCTION_LEAVE();
|
||||
MPP_RET ret = MPP_OK;
|
||||
mpi_dbg_func("enter ctx %p dst %p src %p\n", ctx, dst, src);
|
||||
|
||||
// TODO: do isp process here
|
||||
|
||||
mpi_dbg_func("leave ret %d\n", ret);
|
||||
return MPP_OK;
|
||||
}
|
||||
|
||||
static MPP_RET mpi_isp_put_frame(MppCtx ctx, MppFrame frame)
|
||||
{
|
||||
MPI_FUNCTION_ENTER();
|
||||
(void)ctx;
|
||||
(void)frame;
|
||||
MPI_FUNCTION_LEAVE();
|
||||
return MPP_OK;
|
||||
MPP_RET ret = MPP_OK;
|
||||
mpi_dbg_func("enter ctx %p frame %p\n", ctx, frame);
|
||||
|
||||
// TODO: do isp put frame process here
|
||||
|
||||
mpi_dbg_func("leave ret %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static MPP_RET mpi_isp_get_frame(MppCtx ctx, MppFrame *frame)
|
||||
{
|
||||
MPI_FUNCTION_ENTER();
|
||||
(void)ctx;
|
||||
(void)frame;
|
||||
MPI_FUNCTION_LEAVE();
|
||||
return MPP_OK;
|
||||
MPP_RET ret = MPP_OK;
|
||||
mpi_dbg_func("enter ctx %p frame %p\n", ctx, frame);
|
||||
|
||||
// TODO: do isp get frame process here
|
||||
|
||||
mpi_dbg_func("leave ret %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static MPP_RET mpi_dequeue(MppCtx ctx, MppPortType type, MppTask *task)
|
||||
{
|
||||
MPI_FUNCTION_ENTER();
|
||||
|
||||
MPP_RET ret = MPP_NOK;
|
||||
MpiImpl *p = (MpiImpl *)ctx;
|
||||
MPP_RET ret = check_mpp_ctx(p);
|
||||
|
||||
mpi_dbg_func("enter ctx %p type task %p\n", ctx, type, task);
|
||||
do {
|
||||
ret = check_mpp_ctx(p);
|
||||
if (ret)
|
||||
return ret;
|
||||
break;;
|
||||
|
||||
if (type >= MPP_PORT_BUTT || NULL == task) {
|
||||
mpp_err_f("invalid input type %d task %p\n", type, task);
|
||||
return MPP_ERR_UNKNOW;
|
||||
ret = MPP_ERR_UNKNOW;
|
||||
break;
|
||||
}
|
||||
|
||||
ret = p->ctx->dequeue(type, task);
|
||||
} while (0);
|
||||
|
||||
MPI_FUNCTION_LEAVE();
|
||||
mpi_dbg_func("leave ret %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static MPP_RET mpi_enqueue(MppCtx ctx, MppPortType type, MppTask task)
|
||||
{
|
||||
MPI_FUNCTION_ENTER();
|
||||
|
||||
MPP_RET ret = MPP_NOK;
|
||||
MpiImpl *p = (MpiImpl *)ctx;
|
||||
MPP_RET ret = check_mpp_ctx(p);
|
||||
|
||||
mpi_dbg_func("enter ctx %p type task %p\n", ctx, type, task);
|
||||
do {
|
||||
ret = check_mpp_ctx(p);
|
||||
if (ret)
|
||||
return ret;
|
||||
break;;
|
||||
|
||||
if (type >= MPP_PORT_BUTT || NULL == task) {
|
||||
mpp_err_f("invalid input type %d task %p\n", type, task);
|
||||
return MPP_ERR_UNKNOW;
|
||||
ret = MPP_ERR_UNKNOW;
|
||||
break;
|
||||
}
|
||||
|
||||
ret = p->ctx->enqueue(type, task);
|
||||
} while (0);
|
||||
|
||||
MPI_FUNCTION_LEAVE();
|
||||
mpi_dbg_func("leave ret %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static MPP_RET mpi_reset(MppCtx ctx)
|
||||
{
|
||||
MPI_FUNCTION_ENTER();
|
||||
|
||||
MPP_RET ret = MPP_NOK;
|
||||
MpiImpl *p = (MpiImpl *)ctx;
|
||||
MPP_RET ret = check_mpp_ctx(p);
|
||||
|
||||
mpi_dbg_func("enter ctx %p\n", ctx);
|
||||
do {
|
||||
ret = check_mpp_ctx(p);
|
||||
if (ret)
|
||||
return ret;
|
||||
break;;
|
||||
|
||||
ret = p->ctx->reset();
|
||||
} while (0);
|
||||
|
||||
MPI_FUNCTION_LEAVE();
|
||||
mpi_dbg_func("leave ret %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static MPP_RET mpi_control(MppCtx ctx, MpiCmd cmd, MppParam param)
|
||||
{
|
||||
MPI_FUNCTION_ENTER();
|
||||
|
||||
MPP_RET ret = MPP_NOK;
|
||||
MpiImpl *p = (MpiImpl *)ctx;
|
||||
MPP_RET ret = check_mpp_ctx(p);
|
||||
|
||||
mpi_dbg_func("enter ctx %p cmd %x parm %p\n", ctx, cmd, param);
|
||||
do {
|
||||
ret = check_mpp_ctx(p);
|
||||
if (ret)
|
||||
return ret;
|
||||
break;;
|
||||
|
||||
ret = p->ctx->control(cmd, param);
|
||||
} while (0);
|
||||
|
||||
MPI_FUNCTION_LEAVE();
|
||||
mpi_dbg_func("leave ret %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -301,20 +357,23 @@ static MppApi mpp_api = {
|
||||
|
||||
MPP_RET mpp_create(MppCtx *ctx, MppApi **mpi)
|
||||
{
|
||||
MPI_FUNCTION_ENTER();
|
||||
|
||||
if (NULL == ctx || NULL == mpi) {
|
||||
mpp_err_f("invalid input ctx %p mpi %p\n", ctx, mpi);
|
||||
return MPP_ERR_NULL_PTR;
|
||||
}
|
||||
|
||||
|
||||
*ctx = NULL;
|
||||
*mpi = NULL;
|
||||
|
||||
MPP_RET ret = MPP_OK;
|
||||
mpi_dbg_func("enter ctx %p mpi %p\n", ctx, mpi);
|
||||
do {
|
||||
MpiImpl *p = mpp_malloc(MpiImpl, 1);
|
||||
if (NULL == p) {
|
||||
mpp_err_f("failed to allocate context\n");
|
||||
return MPP_ERR_MALLOC;
|
||||
ret = MPP_ERR_MALLOC;
|
||||
break;
|
||||
}
|
||||
|
||||
memset(p, 0, sizeof(*p));
|
||||
@@ -322,7 +381,8 @@ MPP_RET mpp_create(MppCtx *ctx, MppApi **mpi)
|
||||
if (NULL == p->ctx) {
|
||||
mpp_free(p);
|
||||
mpp_err_f("failed to new Mpp\n");
|
||||
return MPP_ERR_MALLOC;
|
||||
ret = MPP_ERR_MALLOC;
|
||||
break;
|
||||
}
|
||||
|
||||
mpp_api.version = mpp_info_get_revision();
|
||||
@@ -330,43 +390,51 @@ MPP_RET mpp_create(MppCtx *ctx, MppApi **mpi)
|
||||
p->check = p;
|
||||
*ctx = p;
|
||||
*mpi = p->api;
|
||||
} while (0);
|
||||
|
||||
mpp_log("mpp version: %d\n", mpp_api.version);
|
||||
|
||||
MPI_FUNCTION_LEAVE_OK();
|
||||
return MPP_OK;
|
||||
mpi_dbg_func("leave ret %d ctx %p mpi %p\n", ret, *ctx, *mpi);
|
||||
return ret;
|
||||
}
|
||||
|
||||
MPP_RET mpp_init(MppCtx ctx, MppCtxType type, MppCodingType coding)
|
||||
{
|
||||
MPI_FUNCTION_ENTER();
|
||||
|
||||
MPP_RET ret = MPP_OK;
|
||||
MpiImpl *p = (MpiImpl*)ctx;
|
||||
MPP_RET ret = check_mpp_ctx(p);
|
||||
|
||||
mpi_dbg_func("enter ctx %p type %d coding %d\n", ctx, type, coding);
|
||||
do {
|
||||
ret = check_mpp_ctx(p);
|
||||
if (ret)
|
||||
return ret;
|
||||
break;
|
||||
|
||||
if (type >= MPP_CTX_BUTT ||
|
||||
coding >= MPP_VIDEO_CodingMax) {
|
||||
mpp_err_f("invalid input type %d coding %d\n", type, coding);
|
||||
return MPP_ERR_UNKNOW;
|
||||
ret = MPP_ERR_UNKNOW;
|
||||
break;
|
||||
}
|
||||
|
||||
ret = p->ctx->init(type, coding);
|
||||
p->type = type;
|
||||
p->coding = coding;
|
||||
} while (0);
|
||||
|
||||
get_mpi_debug();
|
||||
MPI_FUNCTION_LEAVE_OK();
|
||||
mpi_dbg_func("leave ret %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
MPP_RET mpp_destroy(MppCtx ctx)
|
||||
{
|
||||
MPI_FUNCTION_ENTER();
|
||||
mpi_dbg_func("enter ctx %p\n", ctx);
|
||||
|
||||
MPP_RET ret = MPP_OK;
|
||||
MpiImpl *p = (MpiImpl*)ctx;
|
||||
MPP_RET ret = check_mpp_ctx(p);
|
||||
|
||||
do {
|
||||
ret = check_mpp_ctx(p);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
@@ -374,9 +442,10 @@ MPP_RET mpp_destroy(MppCtx ctx)
|
||||
delete p->ctx;
|
||||
|
||||
mpp_free(p);
|
||||
} while (0);
|
||||
|
||||
MPI_FUNCTION_LEAVE();
|
||||
return MPP_OK;
|
||||
mpi_dbg_func("leave ret %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
MPP_RET mpp_check_support_format(MppCtxType type, MppCodingType coding)
|
||||
|
@@ -27,10 +27,7 @@
|
||||
#define mpi_dbg(flag, fmt, ...) _mpp_dbg(mpi_debug, flag, fmt, ## __VA_ARGS__)
|
||||
#define mpi_dbg_f(flag, fmt, ...) _mpp_dbg_f(mpi_debug, flag, fmt, ## __VA_ARGS__)
|
||||
|
||||
#define MPI_FUNCTION_ENTER() mpi_dbg_f(MPI_DBG_FUNCTION, "enter\n")
|
||||
#define MPI_FUNCTION_LEAVE() mpi_dbg_f(MPI_DBG_FUNCTION, "leave\n")
|
||||
#define MPI_FUNCTION_LEAVE_OK() mpi_dbg_f(MPI_DBG_FUNCTION, "success\n")
|
||||
#define MPI_FUNCTION_LEAVE_FAIL() mpi_dbg_f(MPI_DBG_FUNCTION, "failed\n")
|
||||
#define mpi_dbg_func(fmt, ...) mpi_dbg_f(MPI_DBG_FUNCTION, fmt, ## __VA_ARGS__)
|
||||
|
||||
typedef struct MpiImpl_t MpiImpl;
|
||||
|
||||
|
Reference in New Issue
Block a user