mirror of
https://github.com/nyanmisaka/mpp.git
synced 2025-10-04 08:46:24 +08:00
[mpi/mpp]: add format check function and modify mpp_dec_test for format check
git-svn-id: https://10.10.10.66:8443/svn/MediaProcessPlatform/trunk/mpp@925 6e48237b-75ef-9749-8fc9-41990f28c85a
This commit is contained in:
@@ -224,6 +224,10 @@ MPP_RET mpp_create(MppCtx *ctx, MppApi **mpi);
|
||||
MPP_RET mpp_init(MppCtx ctx, MppCtxType type, MppCodingType coding);
|
||||
MPP_RET mpp_destroy(MppCtx ctx);
|
||||
|
||||
// coding type format function
|
||||
MPP_RET mpp_check_support_format(MppCtxType type, MppCodingType coding);
|
||||
void mpp_show_support_format();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@@ -49,6 +49,7 @@ typedef struct {
|
||||
MppCodingType coding;
|
||||
RK_U32 fast_mode;
|
||||
RK_U32 need_split;
|
||||
void *mpp;
|
||||
} MppDecCfg;
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -64,7 +65,7 @@ void *mpp_dec_hal_thread(void *data);
|
||||
/*
|
||||
*
|
||||
*/
|
||||
MPP_RET mpp_dec_init(MppDec *dec, MppDecCfg *cfg);
|
||||
MPP_RET mpp_dec_init(MppDec **dec, MppDecCfg *cfg);
|
||||
MPP_RET mpp_dec_deinit(MppDec *dec);
|
||||
|
||||
MPP_RET mpp_dec_reset(MppDec *dec);
|
||||
|
@@ -705,7 +705,7 @@ void *mpp_dec_hal_thread(void *data)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
MPP_RET mpp_dec_init(MppDec *dec, MppDecCfg *cfg)
|
||||
MPP_RET mpp_dec_init(MppDec **dec, MppDecCfg *cfg)
|
||||
{
|
||||
MPP_RET ret;
|
||||
MppCodingType coding;
|
||||
@@ -714,6 +714,7 @@ MPP_RET mpp_dec_init(MppDec *dec, MppDecCfg *cfg)
|
||||
Parser parser = NULL;
|
||||
MppHal hal = NULL;
|
||||
RK_S32 hal_task_count = 0;
|
||||
MppDec *p = NULL;
|
||||
IOInterruptCB cb = {NULL, NULL};
|
||||
|
||||
if (NULL == dec || NULL == cfg) {
|
||||
@@ -721,6 +722,14 @@ MPP_RET mpp_dec_init(MppDec *dec, MppDecCfg *cfg)
|
||||
return MPP_ERR_NULL_PTR;
|
||||
}
|
||||
|
||||
*dec = NULL;
|
||||
|
||||
p = mpp_calloc(MppDec, 1);
|
||||
if (NULL == p) {
|
||||
mpp_err_f("failed to malloc context\n");
|
||||
return MPP_ERR_NULL_PTR;
|
||||
}
|
||||
|
||||
coding = cfg->coding;
|
||||
hal_task_count = (cfg->fast_mode) ? (3) : (2);
|
||||
|
||||
@@ -739,7 +748,7 @@ MPP_RET mpp_dec_init(MppDec *dec, MppDecCfg *cfg)
|
||||
|
||||
mpp_buf_slot_setup(packet_slots, hal_task_count);
|
||||
cb.callBack = mpp_dec_notify;
|
||||
cb.opaque = dec;
|
||||
cb.opaque = p;
|
||||
ParserCfg parser_cfg = {
|
||||
coding,
|
||||
frame_slots,
|
||||
@@ -776,19 +785,21 @@ MPP_RET mpp_dec_init(MppDec *dec, MppDecCfg *cfg)
|
||||
break;
|
||||
}
|
||||
|
||||
dec->coding = coding;
|
||||
dec->parser = parser;
|
||||
dec->hal = hal;
|
||||
dec->tasks = hal_cfg.tasks;
|
||||
dec->frame_slots = frame_slots;
|
||||
dec->packet_slots = packet_slots;
|
||||
p->coding = coding;
|
||||
p->parser = parser;
|
||||
p->hal = hal;
|
||||
p->tasks = hal_cfg.tasks;
|
||||
p->frame_slots = frame_slots;
|
||||
p->packet_slots = packet_slots;
|
||||
|
||||
dec->parser_need_split = cfg->need_split;
|
||||
dec->parser_fast_mode = cfg->fast_mode;
|
||||
p->mpp = cfg->mpp;
|
||||
p->parser_need_split = cfg->need_split;
|
||||
p->parser_fast_mode = cfg->fast_mode;
|
||||
*dec = p;
|
||||
return MPP_OK;
|
||||
} while (0);
|
||||
|
||||
mpp_dec_deinit(dec);
|
||||
mpp_dec_deinit(p);
|
||||
return MPP_NOK;
|
||||
}
|
||||
|
||||
|
50
mpp/mpi.cpp
50
mpp/mpi.cpp
@@ -25,6 +25,22 @@
|
||||
#include "mpi_impl.h"
|
||||
#include "mpp.h"
|
||||
#include "mpp_info.h"
|
||||
#include "mpp_common.h"
|
||||
|
||||
typedef struct {
|
||||
MppCtxType type;
|
||||
MppCodingType coding;
|
||||
const char *type_name;
|
||||
const char *coding_name;
|
||||
} MppCodingTypeInfo;
|
||||
|
||||
static MppCodingTypeInfo support_list[] = {
|
||||
{ MPP_CTX_DEC, MPP_VIDEO_CodingMPEG2, "dec", "mpeg2", },
|
||||
{ MPP_CTX_DEC, MPP_VIDEO_CodingAVC, "dec", "h.264/AVC", },
|
||||
{ MPP_CTX_DEC, MPP_VIDEO_CodingHEVC, "dec", "h.265/HEVC", },
|
||||
{ MPP_CTX_DEC, MPP_VIDEO_CodingVP9, "dec", "VP9", },
|
||||
{ MPP_CTX_DEC, MPP_VIDEO_CodingAVS, "dec", "avs+", },
|
||||
};
|
||||
|
||||
#define check_mpp_ctx(ctx) _check_mpp_ctx(ctx, __FUNCTION__)
|
||||
|
||||
@@ -328,13 +344,13 @@ MPP_RET mpp_init(MppCtx ctx, MppCtxType type, MppCodingType coding)
|
||||
return MPP_ERR_UNKNOW;
|
||||
}
|
||||
|
||||
p->ctx->init(type, coding);
|
||||
ret = p->ctx->init(type, coding);
|
||||
p->type = type;
|
||||
p->coding = coding;
|
||||
|
||||
get_mpi_debug();
|
||||
MPI_FUNCTION_LEAVE_OK();
|
||||
return MPP_OK;
|
||||
return ret;
|
||||
}
|
||||
|
||||
MPP_RET mpp_destroy(MppCtx ctx)
|
||||
@@ -355,3 +371,33 @@ MPP_RET mpp_destroy(MppCtx ctx)
|
||||
return MPP_OK;
|
||||
}
|
||||
|
||||
MPP_RET mpp_check_support_format(MppCtxType type, MppCodingType coding)
|
||||
{
|
||||
MPP_RET ret = MPP_NOK;
|
||||
RK_U32 i = 0;
|
||||
|
||||
for (i = 0; i < MPP_ARRAY_ELEMS(support_list); i++) {
|
||||
MppCodingTypeInfo *info = &support_list[i];
|
||||
if (type == info->type &&
|
||||
coding == info->coding) {
|
||||
ret = MPP_OK;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void mpp_show_support_format()
|
||||
{
|
||||
RK_U32 i = 0;
|
||||
|
||||
mpp_log("mpp coding type support list:");
|
||||
|
||||
for (i = 0; i < MPP_ARRAY_ELEMS(support_list); i++) {
|
||||
MppCodingTypeInfo *info = &support_list[i];
|
||||
mpp_log("type: %s id %d coding: %-16s id %d\n",
|
||||
info->type_name, info->type,
|
||||
info->coding_name, info->coding);
|
||||
}
|
||||
}
|
||||
|
||||
|
16
mpp/mpp.cpp
16
mpp/mpp.cpp
@@ -63,17 +63,15 @@ Mpp::Mpp()
|
||||
|
||||
MPP_RET Mpp::init(MppCtxType type, MppCodingType coding)
|
||||
{
|
||||
if (mpp_check_support_format(type, coding)) {
|
||||
mpp_err("unable to create unsupported type %d coding %d\n", type, coding);
|
||||
return MPP_NOK;
|
||||
}
|
||||
|
||||
mType = type;
|
||||
mCoding = coding;
|
||||
switch (mType) {
|
||||
case MPP_CTX_DEC : {
|
||||
mDec = mpp_calloc(MppDec, 1);
|
||||
if (NULL == mDec) {
|
||||
mpp_err_f("failed to malloc context\n");
|
||||
return MPP_ERR_NULL_PTR;
|
||||
}
|
||||
|
||||
mPackets = new mpp_list((node_destructor)mpp_packet_deinit);
|
||||
mFrames = new mpp_list((node_destructor)mpp_frame_deinit);
|
||||
mTasks = new mpp_list((node_destructor)NULL);
|
||||
@@ -82,9 +80,9 @@ MPP_RET Mpp::init(MppCtxType type, MppCodingType coding)
|
||||
coding,
|
||||
mParserFastMode,
|
||||
mParserNeedSplit,
|
||||
this,
|
||||
};
|
||||
mDec->mpp = this;
|
||||
mpp_dec_init(mDec, &cfg);
|
||||
mpp_dec_init(&mDec, &cfg);
|
||||
|
||||
mThreadCodec = new MppThread(mpp_dec_parser_thread, this, "mpp_dec_parser");
|
||||
mThreadHal = new MppThread(mpp_dec_hal_thread, this, "mpp_dec_hal");
|
||||
@@ -116,12 +114,12 @@ MPP_RET Mpp::init(MppCtxType type, MppCodingType coding)
|
||||
mPacketGroup) {
|
||||
mThreadCodec->start();
|
||||
mThreadHal->start();
|
||||
mInitDone = 1;
|
||||
} else {
|
||||
mpp_err("error found on mpp initialization\n");
|
||||
clear();
|
||||
}
|
||||
|
||||
mInitDone = 1;
|
||||
mpp_env_get_u32("mpp_debug", &mpp_debug, 0);
|
||||
return MPP_OK;
|
||||
}
|
||||
|
@@ -72,7 +72,7 @@ int mpi_dec_test(MpiDecTestCmd *cmd)
|
||||
|
||||
MpiCmd mpi_cmd = MPP_CMD_BASE;
|
||||
MppParam param = NULL;
|
||||
RK_U32 output_block = 1;
|
||||
RK_U32 need_split = 1;
|
||||
|
||||
// paramter for resource malloc
|
||||
RK_U32 width = cmd->width;
|
||||
@@ -123,21 +123,22 @@ int mpi_dec_test(MpiDecTestCmd *cmd)
|
||||
mpp_err("mpp_create failed\n");
|
||||
goto MPP_TEST_OUT;
|
||||
}
|
||||
ret = mpp_init(ctx, MPP_CTX_DEC, type);
|
||||
if (MPP_OK != ret) {
|
||||
mpp_err("mpp_init failed\n");
|
||||
goto MPP_TEST_OUT;
|
||||
}
|
||||
|
||||
// NOTE: decoder do not need control function
|
||||
mpi_cmd = MPP_SET_OUTPUT_BLOCK;
|
||||
param = &output_block;
|
||||
// NOTE: decoder split mode need to be set before init
|
||||
mpi_cmd = MPP_DEC_SET_PARSER_SPLIT_MODE;
|
||||
param = &need_split;
|
||||
ret = mpi->control(ctx, mpi_cmd, param);
|
||||
if (MPP_OK != ret) {
|
||||
mpp_err("mpi->control failed\n");
|
||||
goto MPP_TEST_OUT;
|
||||
}
|
||||
|
||||
ret = mpp_init(ctx, MPP_CTX_DEC, type);
|
||||
if (MPP_OK != ret) {
|
||||
mpp_err("mpp_init failed\n");
|
||||
goto MPP_TEST_OUT;
|
||||
}
|
||||
|
||||
while (!found_eos) {
|
||||
read_size = fread(buf, 1, packet_size, fp_input);
|
||||
mpp_log("read packet length %u\n", read_size);
|
||||
@@ -218,23 +219,12 @@ MPP_TEST_OUT:
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
static void mpi_dec_test_help()
|
||||
{
|
||||
mpp_log("usage: mpi_dec_test [options]\n");
|
||||
show_options(mpi_dec_cmd);
|
||||
}
|
||||
|
||||
static MPP_RET check_decoder_support_format(MppCodingType type)
|
||||
{
|
||||
if (type == MPP_VIDEO_CodingMPEG2 ||
|
||||
type == MPP_VIDEO_CodingMPEG4 ||
|
||||
type == MPP_VIDEO_CodingAVC ||
|
||||
type == MPP_VIDEO_CodingVP9 ||
|
||||
type == MPP_VIDEO_CodingHEVC ||
|
||||
type == MPP_VIDEO_CodingAVS)
|
||||
return MPP_OK;
|
||||
|
||||
return MPP_OK;
|
||||
mpp_show_support_format();
|
||||
}
|
||||
|
||||
static RK_S32 mpi_dec_test_parse_options(int argc, char **argv, MpiDecTestCmd* cmd)
|
||||
@@ -319,7 +309,7 @@ static RK_S32 mpi_dec_test_parse_options(int argc, char **argv, MpiDecTestCmd* c
|
||||
case 't':
|
||||
if (next) {
|
||||
cmd->type = (MppCodingType)atoi(next);
|
||||
err = check_decoder_support_format(cmd->type);
|
||||
err = mpp_check_support_format(MPP_CTX_DEC, cmd->type);
|
||||
}
|
||||
|
||||
if (!next || err) {
|
||||
@@ -349,6 +339,7 @@ static void mpi_dec_test_show_options(MpiDecTestCmd* cmd)
|
||||
mpp_log("output file name: %s\n", cmd->file_output);
|
||||
mpp_log("width : %4d\n", cmd->width);
|
||||
mpp_log("height : %4d\n", cmd->height);
|
||||
mpp_log("type : %d\n", cmd->type);
|
||||
mpp_log("debug flag : %x\n", cmd->debug);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user