[mpeg4d]: fix bug on eos and reset

git-svn-id: https://10.10.10.66:8443/svn/MediaProcessPlatform/trunk/mpp@975 6e48237b-75ef-9749-8fc9-41990f28c85a
This commit is contained in:
ChenHengming
2016-07-02 10:44:37 +00:00
parent dba5c94f8e
commit b334768d6f
2 changed files with 48 additions and 19 deletions

View File

@@ -144,7 +144,8 @@ MPP_RET mpg4d_reset(void *dec)
return MPP_ERR_NULL_PTR; return MPP_ERR_NULL_PTR;
} }
return mpp_mpg4_parser_reset(dec); Mpg4dCtx *p = (Mpg4dCtx *)dec;
return mpp_mpg4_parser_reset(p->parser);
} }
@@ -155,7 +156,8 @@ MPP_RET mpg4d_flush(void *dec)
return MPP_ERR_NULL_PTR; return MPP_ERR_NULL_PTR;
} }
return mpp_mpg4_parser_flush(dec); Mpg4dCtx *p = (Mpg4dCtx *)dec;
return mpp_mpg4_parser_flush(p->parser);
} }
@@ -171,7 +173,7 @@ MPP_RET mpg4d_control(void *dec, RK_S32 cmd_type, void *param)
p = (Mpg4dCtx *)dec; p = (Mpg4dCtx *)dec;
switch (cmd_type) { switch (cmd_type) {
case MPP_DEC_SET_INTERNAL_PTS_ENABLE : { case MPP_DEC_SET_INTERNAL_PTS_ENABLE : {
mpp_mpg4_parser_set_pts_mode(p, 1); mpp_mpg4_parser_set_pts_mode(p->parser, 0);
} break; } break;
} }
(void)param; (void)param;
@@ -183,6 +185,7 @@ MPP_RET mpg4d_prepare(void *dec, MppPacket pkt, HalDecTask *task)
Mpg4dCtx *p; Mpg4dCtx *p;
RK_U8 *pos; RK_U8 *pos;
size_t length; size_t length;
RK_U32 eos;
if (NULL == dec || NULL == pkt || NULL == task) { if (NULL == dec || NULL == pkt || NULL == task) {
mpp_err_f("found NULL intput dec %p pkt %p task %p\n", dec, pkt, task); mpp_err_f("found NULL intput dec %p pkt %p task %p\n", dec, pkt, task);
@@ -192,6 +195,15 @@ MPP_RET mpg4d_prepare(void *dec, MppPacket pkt, HalDecTask *task)
p = (Mpg4dCtx *)dec; p = (Mpg4dCtx *)dec;
pos = mpp_packet_get_pos(pkt); pos = mpp_packet_get_pos(pkt);
length = mpp_packet_get_length(pkt); length = mpp_packet_get_length(pkt);
eos = mpp_packet_get_eos(pkt);
if (eos && !length) {
task->valid = 0;
task->flags.eos = 1;
mpp_log_f("mpeg4d flush eos");
mpg4d_flush(dec);
return MPP_OK;
}
if (NULL == p->stream) { if (NULL == p->stream) {
mpp_err("failed to malloc task buffer for hardware with size %d\n", length); mpp_err("failed to malloc task buffer for hardware with size %d\n", length);

View File

@@ -1093,13 +1093,44 @@ MPP_RET mpp_mpg4_parser_deinit(Mpg4dParser ctx)
MPP_RET mpp_mpg4_parser_flush(Mpg4dParser ctx) MPP_RET mpp_mpg4_parser_flush(Mpg4dParser ctx)
{ {
(void)ctx; Mpg4dParserImpl *p = (Mpg4dParserImpl *)ctx;
MppBufSlots slots = p->frame_slots;
Mpg4Hdr *hdr_ref0 = &p->hdr_ref0;
Mpg4Hdr *hdr_ref1 = &p->hdr_ref1;
RK_S32 index = hdr_ref0->slot_idx;
if (index >= 0) {
mpp_buf_slot_set_flag(slots, index, SLOT_QUEUE_USE);
mpp_buf_slot_enqueue(slots, index, QUEUE_DISPLAY);
mpp_buf_slot_clr_flag(slots, index, SLOT_CODEC_USE);
hdr_ref0->slot_idx = -1;
}
index = hdr_ref1->slot_idx;
if (index >= 0) {
mpp_buf_slot_clr_flag(slots, index, SLOT_CODEC_USE);
hdr_ref1->slot_idx = -1;
}
return MPP_OK; return MPP_OK;
} }
MPP_RET mpp_mpg4_parser_reset(Mpg4dParser ctx) MPP_RET mpp_mpg4_parser_reset(Mpg4dParser ctx)
{ {
(void)ctx; Mpg4dParserImpl *p = (Mpg4dParserImpl *)ctx;
MppBufSlots slots = p->frame_slots;
Mpg4Hdr *hdr_ref0 = &p->hdr_ref0;
Mpg4Hdr *hdr_ref1 = &p->hdr_ref1;
if (hdr_ref0->slot_idx >= 0) {
mpp_buf_slot_clr_flag(slots, hdr_ref0->slot_idx, SLOT_CODEC_USE);
hdr_ref0->slot_idx = -1;
}
if (hdr_ref1->slot_idx >= 0) {
mpp_buf_slot_clr_flag(slots, hdr_ref1->slot_idx, SLOT_CODEC_USE);
hdr_ref1->slot_idx = -1;
}
return MPP_OK; return MPP_OK;
} }
@@ -1360,7 +1391,6 @@ MPP_RET mpp_mpg4_parser_setup_hal_output(Mpg4dParser ctx, RK_S32 *output)
mpp_buf_slot_get_unused(slots, &index); mpp_buf_slot_get_unused(slots, &index);
mpp_buf_slot_set_flag(slots, index, SLOT_HAL_OUTPUT); mpp_buf_slot_set_flag(slots, index, SLOT_HAL_OUTPUT);
mpp_frame_set_pts(frame, p->pts); mpp_frame_set_pts(frame, p->pts);
mpp_frame_set_eos(frame, p->eos);
if (hdr_curr->vol.interlacing) { if (hdr_curr->vol.interlacing) {
frame_mode = (hdr_curr->vop.top_field_first) ? frame_mode = (hdr_curr->vop.top_field_first) ?
@@ -1460,19 +1490,6 @@ MPP_RET mpp_mpg4_parser_update_dpb(Mpg4dParser ctx)
hdr_curr->pts = 0; hdr_curr->pts = 0;
} }
if (p->eos) {
index = hdr_ref0->slot_idx;
if (index >= 0) {
mpp_buf_slot_set_flag(slots, index, SLOT_QUEUE_USE);
mpp_buf_slot_enqueue(slots, index, QUEUE_DISPLAY);
mpp_buf_slot_clr_flag(slots, index, SLOT_CODEC_USE);
}
index = hdr_ref1->slot_idx;
if (index >= 0)
mpp_buf_slot_clr_flag(slots, index, SLOT_CODEC_USE);
}
p->last_pts = p->pts; p->last_pts = p->pts;
return MPP_OK; return MPP_OK;