[mpi]: use mpp_create / mpp_destroy pair to replace construct

git-svn-id: https://10.10.10.66:8443/svn/MediaProcessPlatform/trunk/mpp@532 6e48237b-75ef-9749-8fc9-41990f28c85a
This commit is contained in:
ChenHengming
2016-01-20 02:01:10 +00:00
parent 41a1543648
commit 4830431996
4 changed files with 23 additions and 24 deletions

View File

@@ -170,9 +170,9 @@ extern "C" {
/*
* mpp interface
*/
MPP_RET mpp_construct(MppCtx *ctx, MppApi **mpi);
MPP_RET mpp_create(MppCtx *ctx, MppApi **mpi);
MPP_RET mpp_init(MppCtx ctx, MppCtxType type, MppCodingType coding);
MPP_RET mpp_deinit(MppCtx ctx);
MPP_RET mpp_destroy(MppCtx ctx);
#ifdef __cplusplus
}

View File

@@ -30,7 +30,7 @@ VpuApi::VpuApi()
#ifdef DUMP_YUV
fp = fopen("data/hevcdump.yuv", "wb");
#endif
mpp_construct(&mpp_ctx, &mpi);
mpp_create(&mpp_ctx, &mpi);
frame_count = 0;
set_eos = 0;
mpp_log_f("ok\n");
@@ -40,7 +40,7 @@ VpuApi::VpuApi()
VpuApi::~VpuApi()
{
mpp_log_f("in\n");
mpp_deinit(mpp_ctx);
mpp_destroy(mpp_ctx);
mpp_log_f("ok\n");
}

View File

@@ -63,7 +63,7 @@ static MPP_RET mpi_decode_put_packet(MppCtx ctx, MppPacket packet)
MpiImpl *p = (MpiImpl *)ctx;
if (NULL == p || p->check != p || NULL == p->ctx || NULL == packet) {
mpp_err("mpi_decode_put_packet found invalid context input ctx %p packet %p\n",
mpp_err_f("found invalid context input ctx %p packet %p\n",
ctx, packet);
return MPP_ERR_UNKNOW;
}
@@ -80,7 +80,7 @@ static MPP_RET mpi_decode_get_frame(MppCtx ctx, MppFrame *frame)
MpiImpl *p = (MpiImpl *)ctx;
if (NULL == p || p->check != p || NULL == p->ctx || NULL == frame) {
mpp_err("mpi_decode_get_frame found invalid context input ctx %p frame %p\n",
mpp_err_f("found invalid context input ctx %p frame %p\n",
ctx, frame);
return MPP_ERR_UNKNOW;
}
@@ -97,7 +97,7 @@ static MPP_RET mpi_encode_put_frame(MppCtx ctx, MppFrame frame)
MpiImpl *p = (MpiImpl *)ctx;
if (NULL == p || p->check != p || NULL == p->ctx || NULL == frame) {
mpp_err("mpi_encode_put_frame found invalid context input ctx %p frame %p\n",
mpp_err_f("found invalid context input ctx %p frame %p\n",
ctx, frame);
return MPP_ERR_UNKNOW;
}
@@ -114,7 +114,7 @@ static MPP_RET mpi_encode_get_packet(MppCtx ctx, MppPacket *packet)
MpiImpl *p = (MpiImpl *)ctx;
if (NULL == p || p->check != p || NULL == p->ctx || NULL == packet) {
mpp_err("mpi_encode_get_packet found invalid context input ctx %p packet %p\n",
mpp_err_f("found invalid context input ctx %p packet %p\n",
ctx, packet);
return MPP_ERR_UNKNOW;
}
@@ -161,15 +161,14 @@ static MppApi mpp_api = {
{0},
};
MPP_RET mpp_construct(MppCtx *ctx, MppApi **mpi)
MPP_RET mpp_create(MppCtx *ctx, MppApi **mpi)
{
MpiImpl *p;
MPI_FUNCTION_ENTER();
if (NULL == ctx || NULL == mpi) {
mpp_err("mpp_init invalid input ctx %p mpi %p\n", ctx, mpi);
mpp_err_f("invalid input ctx %p mpi %p\n", ctx, mpi);
return MPP_ERR_NULL_PTR;
}
@@ -178,7 +177,7 @@ MPP_RET mpp_construct(MppCtx *ctx, MppApi **mpi)
p = mpp_malloc(MpiImpl, 1);
if (NULL == p) {
mpp_err("mpp_init failed to allocate context\n");
mpp_err_f("failed to allocate context\n");
return MPP_ERR_MALLOC;
}
@@ -186,7 +185,7 @@ MPP_RET mpp_construct(MppCtx *ctx, MppApi **mpi)
p->ctx = new Mpp();
if (NULL == p->ctx) {
mpp_free(p);
mpp_err("mpp_construct failed to new Mpp\n");
mpp_err_f("failed to new Mpp\n");
return MPP_ERR_MALLOC;
}
p->api = &mpp_api;
@@ -206,7 +205,7 @@ MPP_RET mpp_init(MppCtx ctx, MppCtxType type, MppCodingType coding)
if (NULL == ctx ||
type >= MPP_CTX_BUTT ||
coding >= MPP_VIDEO_CodingMax) {
mpp_err("mpp_init invalid input ctx %p type %d coding %d\n",
mpp_err_f("invalid input ctx %p type %d coding %d\n",
ctx, type, coding);
return MPP_ERR_NULL_PTR;
}
@@ -220,20 +219,20 @@ MPP_RET mpp_init(MppCtx ctx, MppCtxType type, MppCodingType coding)
return MPP_OK;
}
MPP_RET mpp_deinit(MppCtx ctx)
MPP_RET mpp_destroy(MppCtx ctx)
{
MpiImpl *p;
MPI_FUNCTION_ENTER();
if (NULL == ctx) {
mpp_err("mpp_deinit input ctx %p is null pointer\n", ctx);
mpp_err_f("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");
mpp_err_f("input invalid MppCtx\n");
return MPP_ERR_UNKNOW;
}

View File

@@ -63,10 +63,10 @@ int mpi_test()
mpp_log("mpi_test decoder test start\n");
// decoder demo
ret = mpp_construct(&ctx, &mpi);
ret = mpp_create(&ctx, &mpi);
if (MPP_OK != ret) {
mpp_err("mpp_construct failed\n");
mpp_err("mpp_create failed\n");
goto MPP_TEST_FAILED;
}
ret = mpp_init(ctx, MPP_CTX_DEC, MPP_VIDEO_CodingUnused);
@@ -172,15 +172,15 @@ int mpi_test()
goto MPP_TEST_FAILED;
}
mpp_deinit(ctx);
mpp_destroy(ctx);
mpp_log("mpi_test encoder test start\n");
// encoder demo
ret = mpp_construct(&ctx, &mpi);
ret = mpp_create(&ctx, &mpi);
if (MPP_OK != ret) {
mpp_err("mpp_construct failed\n");
mpp_err("mpp_create failed\n");
goto MPP_TEST_FAILED;
}
@@ -259,7 +259,7 @@ int mpi_test()
if (enc_in)
mpp_frame_deinit(&enc_in);
mpp_deinit(ctx);
mpp_destroy(ctx);
free(buf);
mpp_log("mpi_test success\n");
@@ -274,7 +274,7 @@ MPP_TEST_FAILED:
mpp_frame_deinit(&enc_in);
if (ctx)
mpp_deinit(ctx);
mpp_destroy(ctx);
if (buf)
free(buf);