[mpp_dec] modify eos flow, fixed eos no notify to user

git-svn-id: https://10.10.10.66:8443/svn/MediaProcessPlatform/trunk/mpp@967 6e48237b-75ef-9749-8fc9-41990f28c85a
This commit is contained in:
ChenSiyong
2016-06-30 02:02:45 +00:00
parent 12e12ae0f2
commit fa119620cd
7 changed files with 76 additions and 43 deletions

View File

@@ -561,12 +561,13 @@ MPP_RET h264d_flush(void *decoder)
if (p_Dec->mvc_valid) {
FUN_CHECK(ret = output_dpb(p_Dec, p_Dec->p_Vid->p_Dpb_layer[1]));
}
#if 0
if (p_Dec->last_frame_slot_idx >= 0) {
mpp_buf_slot_set_prop(p_Dec->frame_slots, p_Dec->last_frame_slot_idx,
SLOT_EOS, &p_Dec->p_Inp->has_get_eos);
p_Dec->last_frame_slot_idx = -1;
}
#endif
__RETURN:
FunctionOut(p_Dec->logctx.parr[RUN_PARSE]);
return ret = MPP_OK;

View File

@@ -1720,15 +1720,15 @@ MPP_RET h265d_prepare(void *ctx, MppPacket pkt, HalDecTask *task)
return MPP_FAIL_SPLIT_FRAME;
}
} else {
pos = buf + length;
s->pts = pts;
mpp_packet_set_pos(pkt, pos);
if (s->eos) {
if (s->eos && !length) {
task->valid = 0;
task->flags.eos = 1;
mpp_log_f("hevc flush eos");
h265d_flush(ctx);
return ret;
}
}
#ifdef dump
@@ -1796,15 +1796,9 @@ MPP_RET h265d_parse(void *ctx, HalDecTask *task)
} else {
if (s->eos) {
h265d_flush(ctx);
s->task->flags.eos = 1;
}
}
#if 0
for (i = 0; i < MPP_ARRAY_ELEMS(s->DPB); i++) {
HEVCFrame *frame = &s->DPB[i];
if (frame->poc != INT_MAX)
mpp_err("poc[%d] = %d", i, frame->poc);
}
#endif
s->nb_frame++;
if (s->is_decoded) {
h265d_dbg(H265D_DBG_GLOBAL, "Decoded frame with POC %d.\n", s->poc);
@@ -1972,21 +1966,9 @@ MPP_RET h265d_init(void *ctx, ParserCfg *parser_cfg)
MPP_RET h265d_flush(void *ctx)
{
RK_S32 ret = 0;
H265dContext_t *h265dctx = (H265dContext_t *)ctx;
HEVCContext *s = (HEVCContext *)h265dctx->priv_data;
HEVCFrame *frame = NULL;
do {
ret = mpp_hevc_output_frame(ctx, 1);
} while (ret);
frame = &s->DPB[s->output_frame_idx];
if ((frame->slot_index < 0xff) && s->eos) {
mpp_buf_slot_set_prop(s->slots, frame->slot_index, SLOT_EOS, &s->eos);
} else {
if (s->notify_cb.callBack != NULL && s->eos) {
s->notify_cb.callBack(s->notify_cb.opaque, NULL);
}
}
return MPP_OK;
}

View File

@@ -329,6 +329,7 @@ MPP_RET m2vd_parser_flush(void *ctx)
mpp_buf_slot_enqueue(p->frame_slots, p->frame_ref0->slot_index, QUEUE_DISPLAY);
p->frame_ref0->flags = 0;
exit:
#if 0
if (p->eos) {
if ( p->frame_ref0->slot_index < 0xff) {
mpp_buf_slot_set_prop(p->frame_slots, p->frame_ref0->slot_index, SLOT_EOS, &p->eos);
@@ -338,6 +339,7 @@ exit:
}
}
}
#endif
return ret;
}
@@ -434,6 +436,7 @@ MPP_RET m2vd_parser_prepare(void *ctx, MppPacket pkt, HalDecTask *task)
if (out_size == 0 && p->eos) {
m2vd_parser_flush(ctx);
task->flags.eos = 1;
return ret;
}

View File

@@ -440,9 +440,7 @@ MPP_RET vp8d_parser_prepare(void *ctx, MppPacket pkt, HalDecTask *task)
mpp_packet_set_pos(pkt, pos);
if (out_size == 0 && p->eos) {
if (p->notify_cb.callBack != NULL) {
p->notify_cb.callBack(p->notify_cb.opaque, NULL);
}
task->flags.eos = p->eos;
return ret;
}
@@ -1197,13 +1195,7 @@ MPP_RET vp8d_parser_parse(void *ctx, HalDecTask *in_task)
in_task->output = p->frame_out->slot_index;
in_task->valid = 1;
if (p->eos) {
if (p->showFrame) {
mpp_buf_slot_set_prop(p->frame_slots, p->frame_out->slot_index, SLOT_EOS, &p->eos);
} else {
if (p->notify_cb.callBack != NULL) {
p->notify_cb.callBack(p->notify_cb.opaque, NULL);
}
}
in_task->flags.eos = p->eos;
}
vp8d_ref_update(p);

View File

@@ -236,6 +236,16 @@ static void mpp_put_frame(Mpp *mpp, MppFrame frame)
list->unlock();
}
static void mpp_put_frame_eos(Mpp *mpp)
{
MppFrame info_frame = NULL;
mpp_frame_init(&info_frame);
mpp_assert(NULL == mpp_frame_get_buffer(info_frame));
mpp_frame_set_eos(info_frame, 1);
mpp_put_frame((Mpp*)mpp, info_frame);
return;
}
static void mpp_dec_push_display(Mpp *mpp)
{
RK_S32 index;
@@ -257,6 +267,14 @@ static void mpp_dec_push_display(Mpp *mpp)
mpp->mThreadHal->unlock(THREAD_QUE_DISPLAY);
}
static void mpp_dec_push_eos_task(Mpp *mpp, DecTask *task)
{
hal_task_hnd_set_info(task->hnd, &task->info);
mpp->mThreadHal->lock();
hal_task_hnd_set_status(task->hnd, TASK_PROCESSING);
mpp->mThreadHal->unlock();
mpp->mThreadHal->signal();
}
static MPP_RET try_proc_dec_task(Mpp *mpp, DecTask *task)
{
@@ -343,13 +361,18 @@ static MPP_RET try_proc_dec_task(Mpp *mpp, DecTask *task)
}
}
/*
* We may find eos in prepare step and there will be no anymore vaild task generated.
* So here we try push all frames to display to avoid eos no notify to display
*/
mpp_dec_push_display(mpp);
task->status.curr_task_rdy = task_dec->valid;
/*
* We may find eos in prepare step and there will be no anymore vaild task generated.
* So here we try push eos task to hal, hal will push all frame to display then
* push a eos frame to tell all frame decoded
*/
// mpp_dec_push_display(mpp);
if (task_dec->flags.eos && !task_dec->valid) {
mpp_dec_push_eos_task(mpp, task);
task->hnd = NULL;
}
if (!task->status.curr_task_rdy)
return MPP_NOK;
@@ -435,7 +458,7 @@ static MPP_RET try_proc_dec_task(Mpp *mpp, DecTask *task)
* We may find eos in prepare step and there will be no anymore vaild task generated.
* So here we try push all frames to display to avoid eos no notify to display
*/
mpp_dec_push_display(mpp);
// mpp_dec_push_display(mpp);
/*
* 8. send packet data to parser
@@ -487,9 +510,19 @@ static MPP_RET try_proc_dec_task(Mpp *mpp, DecTask *task)
mpp_assert(task->hnd);
}
// send info change task to hal thread
if (task_dec->output < 0) {
hal_task_hnd_set_status(task->hnd, TASK_IDLE);
/*
* We may find eos in parser step and there will be no anymore vaild task generated.
* So here we try push eos task to hal, hal will push all frame to display then
* push a eos frame to tell all frame decoded
*/
if (task_dec->flags.eos) {
mpp_dec_push_eos_task(mpp, task);
} else {
hal_task_hnd_set_status(task->hnd, TASK_IDLE);
}
mpp->mTaskPutCount++;
task->hnd = NULL;
if (task->status.dec_pkt_copy_rdy) {
@@ -690,6 +723,19 @@ void *mpp_dec_hal_thread(void *data)
mpp->mThreadCodec->signal();
continue;
}
/*
* check eos task
* if this task is invalid then eos flag come we will flush display que
* then push eos frame to tell all frame decoded
*/
if (task_dec->flags.eos && !task_dec->valid) {
mpp_dec_push_display(mpp);
mpp_put_frame_eos(mpp);
hal_task_hnd_set_status(task, TASK_IDLE);
mpp->mThreadCodec->signal();
task = NULL;
continue;
}
mpp_hal_hw_wait(dec->hal, &task_info);
p_e = mpp_time();
cur_deat = (p_e - p_s);
@@ -732,6 +778,14 @@ void *mpp_dec_hal_thread(void *data)
mpp_dec_flush(dec);
}
mpp_dec_push_display(mpp);
/*
* check eos task
* if this task is valid then eos flag come we will flush display que
* then push eos frame to tell all frame decoded
*/
if (task_dec->flags.eos) {
mpp_put_frame_eos(mpp);
}
}
}

View File

@@ -44,7 +44,7 @@ static const ParserApi *parsers[] = {
&api_avsd_parser,
&api_m2vd_parser,
&api_mpg4d_parser,
&api_vp8d_parser,
&api_vp8d_parser,
&dummy_dec_parser,
};

View File

@@ -229,6 +229,7 @@ MPP_RET hal_task_info_init(HalTaskInfo *task, MppCtxType type)
HalDecTask *p = &task->dec;
p->valid = 0;
p->flags.val = 0;
p->flags.eos = 0;
p->prev_status = 0;
p->input_packet = NULL;
p->output = -1;