[mpp]: add need_split flag to MppDec. When set this flag parser will do frame split internally. Default is disabled

git-svn-id: https://10.10.10.66:8443/svn/MediaProcessPlatform/trunk/mpp@922 6e48237b-75ef-9749-8fc9-41990f28c85a
This commit is contained in:
ChenHengming
2016-06-16 07:25:08 +00:00
parent dfe367b0ff
commit 589bb07317
8 changed files with 60 additions and 39 deletions

View File

@@ -77,8 +77,8 @@ typedef enum {
MPP_DEC_SET_EXT_BUF_GROUP, /* IMPORTANT: set external buffer group to mpp decoder */ MPP_DEC_SET_EXT_BUF_GROUP, /* IMPORTANT: set external buffer group to mpp decoder */
MPP_DEC_USE_PRESENT_TIME_ORDER, MPP_DEC_USE_PRESENT_TIME_ORDER,
MPP_DEC_SET_VC1_EXTRA_DATA, MPP_DEC_SET_VC1_EXTRA_DATA,
MPP_DEC_SET_VP6_ID, MPP_DEC_SET_PARSER_SPLIT_MODE, /* Need to setup before init */
MPP_DEC_USE_FAST_MODE, MPP_DEC_SET_PARSER_FAST_MODE, /* Need to setup before init */
MPP_DEC_GET_STREAM_COUNT, MPP_DEC_GET_STREAM_COUNT,
MPP_ENC_CMD_BASE = 0x50000, MPP_ENC_CMD_BASE = 0x50000,

View File

@@ -33,14 +33,23 @@ struct MppDec_t {
MppBufSlots packet_slots; MppBufSlots packet_slots;
HalTaskGroup tasks; HalTaskGroup tasks;
// status flag
RK_U32 reset_flag; RK_U32 reset_flag;
// work mode flag
RK_U32 parser_need_split;
RK_U32 parser_fast_mode;
// dec parser thread runtime resource context // dec parser thread runtime resource context
MppPacket mpp_pkt_in; MppPacket mpp_pkt_in;
RK_U32 fast_mode;
void *mpp; void *mpp;
}; };
typedef struct {
MppCodingType coding;
RK_U32 fast_mode;
RK_U32 need_split;
} MppDecCfg;
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
@@ -55,7 +64,7 @@ void *mpp_dec_hal_thread(void *data);
/* /*
* *
*/ */
MPP_RET mpp_dec_init(MppDec *dec, MppCodingType coding); MPP_RET mpp_dec_init(MppDec *dec, MppDecCfg *cfg);
MPP_RET mpp_dec_deinit(MppDec *dec); MPP_RET mpp_dec_deinit(MppDec *dec);
MPP_RET mpp_dec_reset(MppDec *dec); MPP_RET mpp_dec_reset(MppDec *dec);

View File

@@ -35,8 +35,8 @@ typedef struct DecParserInitCfg_t {
MppBufSlots packet_slots; MppBufSlots packet_slots;
// output // output
RK_S32 task_count; RK_U32 task_count;
RK_S32 need_split; RK_U32 need_split;
IOInterruptCB notify_cb; IOInterruptCB notify_cb;
} ParserCfg; } ParserCfg;

View File

@@ -150,7 +150,7 @@ static RK_U32 reset_dec_task(Mpp *mpp, DecTask *task)
MppBufSlots packet_slots = dec->packet_slots; MppBufSlots packet_slots = dec->packet_slots;
HalDecTask *task_dec = &task->info.dec; HalDecTask *task_dec = &task->info.dec;
if (!dec->fast_mode) { if (!dec->parser_fast_mode) {
if (!task->status.prev_task_rdy) { if (!task->status.prev_task_rdy) {
HalTaskHnd task_prev = NULL; HalTaskHnd task_prev = NULL;
hal_task_get_hnd(tasks, TASK_PROC_DONE, &task_prev); hal_task_get_hnd(tasks, TASK_PROC_DONE, &task_prev);
@@ -386,7 +386,7 @@ static MPP_RET try_proc_dec_task(Mpp *mpp, DecTask *task)
task->status.dec_pkt_copy_rdy = 1; task->status.dec_pkt_copy_rdy = 1;
} }
if (!dec->fast_mode) { if (!dec->parser_fast_mode) {
// wait previous task done // wait previous task done
if (!task->status.prev_task_rdy) { if (!task->status.prev_task_rdy) {
HalTaskHnd task_prev = NULL; HalTaskHnd task_prev = NULL;
@@ -680,8 +680,7 @@ void *mpp_dec_hal_thread(void *data)
// TODO: may have risk here // TODO: may have risk here
hal_task_hnd_set_status(task, TASK_PROC_DONE); hal_task_hnd_set_status(task, TASK_PROC_DONE);
task = NULL; task = NULL;
if (dec->fast_mode) { if (dec->parser_fast_mode) {
hal_task_get_hnd(tasks, TASK_PROC_DONE, &task); hal_task_get_hnd(tasks, TASK_PROC_DONE, &task);
if (task) { if (task) {
hal_task_hnd_set_status(task, TASK_IDLE); hal_task_hnd_set_status(task, TASK_IDLE);
@@ -706,24 +705,25 @@ void *mpp_dec_hal_thread(void *data)
return NULL; return NULL;
} }
MPP_RET mpp_dec_init(MppDec *dec, MppCodingType coding) MPP_RET mpp_dec_init(MppDec *dec, MppDecCfg *cfg)
{ {
MPP_RET ret; MPP_RET ret;
MppCodingType coding;
MppBufSlots frame_slots = NULL; MppBufSlots frame_slots = NULL;
MppBufSlots packet_slots = NULL; MppBufSlots packet_slots = NULL;
Parser parser = NULL; Parser parser = NULL;
MppHal hal = NULL; MppHal hal = NULL;
MppDec *p = dec; RK_S32 hal_task_count = 0;
RK_S32 task_count = 2;
IOInterruptCB cb = {NULL, NULL}; IOInterruptCB cb = {NULL, NULL};
if (dec->fast_mode) {
task_count = 3; if (NULL == dec || NULL == cfg) {
} mpp_err_f("invalid input dec %p cfg %p\n", dec, cfg);
if (NULL == p) {
mpp_err_f("failed to malloc context\n");
return MPP_ERR_NULL_PTR; return MPP_ERR_NULL_PTR;
} }
coding = cfg->coding;
hal_task_count = (cfg->fast_mode) ? (3) : (2);
do { do {
ret = mpp_buf_slot_init(&frame_slots); ret = mpp_buf_slot_init(&frame_slots);
if (ret) { if (ret) {
@@ -737,15 +737,15 @@ MPP_RET mpp_dec_init(MppDec *dec, MppCodingType coding)
break; break;
} }
mpp_buf_slot_setup(packet_slots, task_count); mpp_buf_slot_setup(packet_slots, hal_task_count);
cb.callBack = mpp_dec_notify; cb.callBack = mpp_dec_notify;
cb.opaque = dec; cb.opaque = dec;
ParserCfg parser_cfg = { ParserCfg parser_cfg = {
coding, coding,
frame_slots, frame_slots,
packet_slots, packet_slots,
task_count, hal_task_count,
0, cfg->need_split,
cb, cb,
}; };
@@ -766,7 +766,7 @@ MPP_RET mpp_dec_init(MppDec *dec, MppCodingType coding)
packet_slots, packet_slots,
NULL, NULL,
parser_cfg.task_count, parser_cfg.task_count,
dec->fast_mode, cfg->fast_mode,
cb, cb,
}; };
@@ -776,16 +776,19 @@ MPP_RET mpp_dec_init(MppDec *dec, MppCodingType coding)
break; break;
} }
p->coding = coding; dec->coding = coding;
p->parser = parser; dec->parser = parser;
p->hal = hal; dec->hal = hal;
p->tasks = hal_cfg.tasks; dec->tasks = hal_cfg.tasks;
p->frame_slots = frame_slots; dec->frame_slots = frame_slots;
p->packet_slots = packet_slots; dec->packet_slots = packet_slots;
dec->parser_need_split = cfg->need_split;
dec->parser_fast_mode = cfg->fast_mode;
return MPP_OK; return MPP_OK;
} while (0); } while (0);
mpp_dec_deinit(p); mpp_dec_deinit(dec);
return MPP_NOK; return MPP_NOK;
} }

View File

@@ -266,7 +266,7 @@ rk_list::~rk_list()
#define COUNT_ADD 100 #define COUNT_ADD 100
#define COUNT_DEL 99 #define COUNT_DEL 99
volatile int err = 0; static volatile int err = 0;
static int rk_list_fifo_test(rk_list *list_0) static int rk_list_fifo_test(rk_list *list_0)
{ {

View File

@@ -368,7 +368,7 @@ RK_S32 VpuApi::control(VpuCodecContext *ctx, VPU_API_CMD cmd, void *param)
break; break;
} }
case VPU_API_USE_FAST_MODE: { case VPU_API_USE_FAST_MODE: {
mpicmd = MPP_DEC_USE_FAST_MODE; mpicmd = MPP_DEC_SET_PARSER_FAST_MODE;
break; break;
} }
case VPU_API_DEC_GET_STREAM_COUNT: { case VPU_API_DEC_GET_STREAM_COUNT: {

View File

@@ -56,7 +56,8 @@ Mpp::Mpp()
mOutputBlock(0), mOutputBlock(0),
mMultiFrame(0), mMultiFrame(0),
mStatus(0), mStatus(0),
mFastMode(0) mParserFastMode(0),
mParserNeedSplit(0)
{ {
} }
@@ -77,11 +78,13 @@ MPP_RET Mpp::init(MppCtxType type, MppCodingType coding)
mFrames = new mpp_list((node_destructor)mpp_frame_deinit); mFrames = new mpp_list((node_destructor)mpp_frame_deinit);
mTasks = new mpp_list((node_destructor)NULL); mTasks = new mpp_list((node_destructor)NULL);
if (MPP_VIDEO_CodingHEVC == coding) { MppDecCfg cfg = {
mDec->fast_mode = mFastMode; coding,
} mParserFastMode,
mParserNeedSplit,
};
mDec->mpp = this; mDec->mpp = this;
mpp_dec_init(mDec, coding); mpp_dec_init(mDec, &cfg);
mThreadCodec = new MppThread(mpp_dec_parser_thread, this, "mpp_dec_parser"); mThreadCodec = new MppThread(mpp_dec_parser_thread, this, "mpp_dec_parser");
mThreadHal = new MppThread(mpp_dec_hal_thread, this, "mpp_dec_hal"); mThreadHal = new MppThread(mpp_dec_hal_thread, this, "mpp_dec_hal");
@@ -286,9 +289,14 @@ MPP_RET Mpp::control(MpiCmd cmd, MppParam param)
mpp_dec_control(mDec, cmd, param); mpp_dec_control(mDec, cmd, param);
break; break;
} }
case MPP_DEC_USE_FAST_MODE: { case MPP_DEC_SET_PARSER_SPLIT_MODE: {
RK_U32 mode = *((RK_U32 *)param); RK_U32 mode = *((RK_U32 *)param);
mFastMode = mode; mParserNeedSplit = mode;
break;
}
case MPP_DEC_SET_PARSER_FAST_MODE: {
RK_U32 mode = *((RK_U32 *)param);
mParserFastMode = mode;
break; break;
} }
case MPP_DEC_GET_STREAM_COUNT: { case MPP_DEC_GET_STREAM_COUNT: {

View File

@@ -119,7 +119,8 @@ private:
RK_U32 mMultiFrame; RK_U32 mMultiFrame;
RK_U32 mStatus; RK_U32 mStatus;
RK_U32 mFastMode; RK_U32 mParserFastMode;
RK_U32 mParserNeedSplit;
Mpp(const Mpp &); Mpp(const Mpp &);
Mpp &operator=(const Mpp &); Mpp &operator=(const Mpp &);