[h264d] remove muti_view_output; add first_iframe_poc;

git-svn-id: https://10.10.10.66:8443/svn/MediaProcessPlatform/trunk/mpp@602 6e48237b-75ef-9749-8fc9-41990f28c85a
This commit is contained in:
DingWei
2016-04-11 08:04:52 +00:00
parent 3a4ff17332
commit b77afe0474
5 changed files with 39 additions and 171 deletions

View File

@@ -248,9 +248,6 @@ static MPP_RET init_vid_ctx(H264dVideoCtx_t *p_Vid)
p_Vid->p_Dpb_layer[i]->layer_id = i;
p_Vid->p_Dpb_layer[i]->p_Vid = p_Vid;
p_Vid->p_Dpb_layer[i]->init_done = 0;
memset(&p_Vid->outlist[i], 0, sizeof(p_Vid->outlist[i]));
p_Vid->outlist[i].max_size = MAX_MARK_SIZE;
p_Vid->last_outputpoc[i] = -1;
}
//!< init video pars
for (i = 0; i < MAXSPS; i++) {
@@ -272,9 +269,6 @@ static MPP_RET init_vid_ctx(H264dVideoCtx_t *p_Vid)
p_Vid->subspsSet[i].num_views_minus1 = -1;
p_Vid->subspsSet[i].num_level_values_signalled_minus1 = -1;
}
p_Vid->iframe_cnt = 0;
//!< memset error context
FunctionOut(p_Vid->p_Dec->logctx.parr[RUN_PARSE]);
__RETURN:
return ret = MPP_OK;
@@ -499,7 +493,6 @@ MPP_RET h264d_reset(void *decoder)
// layer_id == 1
FUN_CHECK(ret = flush_dpb(p_Dec->p_Vid->p_Dpb_layer[1], 1));
FUN_CHECK(ret = init_dpb(p_Dec->p_Vid, p_Dec->p_Vid->p_Dpb_layer[1], 2));
flush_muti_view_output(p_Dec->frame_slots, p_Dec->p_Vid->outlist, p_Dec->p_Vid);
}
flush_dpb_buf_slot(p_Dec);
//!< reset input parameter
@@ -513,11 +506,8 @@ MPP_RET h264d_reset(void *decoder)
p_Dec->p_Inp->has_get_eos = 0;
//!< reset video parameter
p_Dec->p_Vid->g_framecnt = 0;
p_Dec->p_Vid->last_outputpoc[0] = -1;
p_Dec->p_Vid->last_outputpoc[1] = -1;
p_Dec->p_Vid->iframe_cnt = 0;
memset(&p_Dec->errctx, 0, sizeof(H264dErrCtx_t));
memset(&p_Dec->errctx, 0, sizeof(H264dErrCtx_t));
//!< reset current time stamp
p_Dec->p_Cur->last_dts = 0;
p_Dec->p_Cur->last_pts = 0;
@@ -580,7 +570,6 @@ MPP_RET h264d_flush(void *decoder)
FUN_CHECK(ret = flush_dpb(p_Dec->p_Vid->p_Dpb_layer[1], 2));
FUN_CHECK(ret = init_dpb(p_Dec->p_Vid, p_Dec->p_Vid->p_Dpb_layer[1], 2));
//free_dpb(p_Dec->p_Vid->p_Dpb_layer[1]);
flush_muti_view_output(p_Dec->frame_slots, p_Dec->p_Vid->outlist, p_Dec->p_Vid);
}
flush_dpb_buf_slot(p_Dec);
p_Dec->p_Inp->task_eos = 1;

View File

@@ -833,89 +833,11 @@ __FAILED:
return ret ;
}
static void muti_view_output(MppBufSlots frame_slots, H264_DpbMark_t *p_mark, H264dVideoCtx_t *p_Vid)
{
//!< add slot
{
MppFrame frame;
RK_S32 layer_id = -1;
H264dOutList_t *p_cur = NULL;
mpp_buf_slot_get_prop(frame_slots, p_mark->slot_idx, SLOT_FRAME_PTR, &frame);
layer_id = mpp_frame_get_viewid(frame);
p_cur = &p_Vid->outlist[layer_id];
p_cur->list[p_cur->end] = p_mark;
p_cur->end = (p_cur->end + 1) % p_cur->max_size;
}
//!< enqueue
{
RK_S64 pts = 0;
MppFrame frame0;
MppFrame frame1;
H264_DpbMark_t *p_mark0 = NULL;
H264_DpbMark_t *p_mark1 = NULL;
H264dOutList_t *p_out[MAX_NUM_DPB_LAYERS] = { NULL };
p_out[0] = &p_Vid->outlist[0];
p_out[1] = &p_Vid->outlist[1];
p_mark0 = p_out[0]->list[p_out[0]->begin];
p_mark1 = p_out[1]->list[p_out[1]->begin];
#if 1
while (p_mark0 && p_mark1) {
mpp_buf_slot_get_prop(frame_slots, p_mark0->slot_idx, SLOT_FRAME_PTR, &frame0);
mpp_buf_slot_get_prop(frame_slots, p_mark1->slot_idx, SLOT_FRAME_PTR, &frame1);
if (mpp_frame_get_poc(frame0) == mpp_frame_get_poc(frame1)) {
pts = MPP_MIN(mpp_frame_get_pts(frame0), mpp_frame_get_pts(frame1));
mpp_frame_set_pts(frame0, pts);
mpp_frame_set_pts(frame1, pts);
mpp_buf_slot_enqueue(frame_slots, p_mark0->slot_idx, QUEUE_DISPLAY);
mpp_buf_slot_enqueue(frame_slots, p_mark1->slot_idx, QUEUE_DISPLAY);
p_mark0->out_flag = 0;
p_mark1->out_flag = 0;
p_Vid->p_Dec->last_frame_slot_idx = p_mark1->slot_idx;
free_dpb_mark(p_Vid->p_Dec, p_mark0, FRAME);
free_dpb_mark(p_Vid->p_Dec, p_mark1, FRAME);
p_out[0]->list[p_out[0]->begin] = NULL;
p_out[1]->list[p_out[1]->begin] = NULL;
p_out[0]->begin = (p_out[0]->begin + 1) % p_out[0]->max_size;
p_out[1]->begin = (p_out[1]->begin + 1) % p_out[1]->max_size;
} else if (mpp_frame_get_poc(frame0) > mpp_frame_get_poc(frame1)) {
mpp_buf_slot_enqueue(frame_slots, p_mark1->slot_idx, QUEUE_DISPLAY);
p_mark1->out_flag = 0;
free_dpb_mark(p_Vid->p_Dec, p_mark1, FRAME);
p_out[1]->list[p_out[1]->begin] = NULL;
p_out[1]->begin = (p_out[1]->begin + 1) % p_out[1]->max_size;
mpp_frame_set_discard(frame1, 1);
} else { //!< mpp_frame_get_poc(frame0) < mpp_frame_get_poc(frame1)
mpp_buf_slot_enqueue(frame_slots, p_mark0->slot_idx, QUEUE_DISPLAY);
p_mark0->out_flag = 0;
free_dpb_mark(p_Vid->p_Dec, p_mark0, FRAME);
p_out[0]->list[p_out[0]->begin] = NULL;
p_out[0]->begin = (p_out[0]->begin + 1) % p_out[0]->max_size;
mpp_frame_set_discard(frame0, 1);
}
p_mark0 = p_out[0]->list[p_out[0]->begin];
p_mark1 = p_out[1]->list[p_out[1]->begin];
}
}
#else
mpp_buf_slot_enqueue(frame_slots, p_mark->slot_idx, QUEUE_DISPLAY);
p_Vid->p_Dec->last_frame_slot_idx = p_mark->slot_idx;
p_mark->out_flag = 0;
#endif
}
static void write_picture(H264_StorePic_t *p, H264dVideoCtx_t *p_Vid)
{
MppFrame mframe = NULL;
H264_DpbMark_t *p_mark = NULL;
H264dErrCtx_t *p_err = &p_Vid->p_Dec->errctx;
p_mark = p->mem_mark;
H264D_DBG(H264D_DBG_DPB_FREE, "[write_picture] type=%d", p->mem_malloc_type);
@@ -937,41 +859,25 @@ static void write_picture(H264_StorePic_t *p, H264dVideoCtx_t *p_Vid)
//else {
// mpp_frame_set_discard(frame, 1);
//}
//!< discard unpaired
//!< discard unpaired && less than first i frame poc
if (p->mem_malloc_type == Mem_TopOnly
|| p->mem_malloc_type == Mem_BotOnly) {
mpp_frame_set_discard(mframe, VPU_FRAME_ERR_UNKNOW);
H264D_DBG(H264D_DBG_DPB_FREE, "[write_picture] error, malloc_type unpaired, type=%d", p->mem_malloc_type);
}
p_Vid->iframe_cnt += (p->slice_type == I_SLICE) ? 1 : 0;
if (!p_Vid->iframe_cnt) {
//mpp_frame_set_errinfo(mframe, VPU_FRAME_ERR_UNKNOW);
} else {
//if (1 == p_Vid->iframe_cnt) {
// p_Vid->first_iframe_poc = p->poc;
//}
//if (p->poc < p_Vid->first_iframe_poc) {
// mpp_frame_set_errinfo(mframe, VPU_FRAME_ERR_UNKNOW);
//}
//if (p->poc < p_Vid->last_outputpoc[p->layer_id]) {
// mpp_frame_set_discard(mframe, VPU_FRAME_ERR_UNKNOW);
//}
//p_Vid->last_outputpoc[p->layer_id] = p->poc;
}
if (p->poc < p_err->first_iframe_poc) {
mpp_frame_set_discard(mframe, VPU_FRAME_ERR_UNKNOW);
H264D_DBG(H264D_DBG_DPB_FREE, "[write_picture] error, cur_poc=%d, first_iframe_poc=%d", p->poc, p_err->first_iframe_poc);
}
mpp_buf_slot_set_flag(p_Vid->p_Dec->frame_slots, p_mark->slot_idx, SLOT_QUEUE_USE);
if (p_Vid->p_Dec->mvc_valid && !p_Vid->p_Inp->mvc_disable) {
muti_view_output(p_Vid->p_Dec->frame_slots, p_mark, p_Vid);
//muti_view_output(p_Vid->p_Dec->frame_slots, p_mark, p_Vid);
} else {
mpp_buf_slot_enqueue(p_Vid->p_Dec->frame_slots, p_mark->slot_idx, QUEUE_DISPLAY);
p_Vid->p_Dec->last_frame_slot_idx = p_mark->slot_idx;
p_mark->out_flag = 0;
}
{
MppBuffer mbuffer = NULL;
mpp_buf_slot_get_prop(p_Vid->p_Dec->frame_slots, p_mark->slot_idx, SLOT_BUFFER, &mbuffer);
H264D_DBG(H264D_DBG_DPB_DISPLAY, "[DPB_dispaly] layer_id=%d, pic_num=%d, poc=%d, last_poc=%d, slice_type=%d(idr=%d), slot_idx=%d(%p), pts=%lld, g_framecnt=%d \n",
p->layer_id, p->pic_num, p->poc, p_Vid->last_outputpoc[p->layer_id], p->slice_type, p->idr_flag, p_mark->slot_idx, mbuffer, mpp_frame_get_pts(mframe), p_Vid->g_framecnt);
}
H264D_DBG(H264D_DBG_DPB_FREE, "[write_picture] Out, out_flag=%d", p_mark->out_flag);
}
}
@@ -1388,37 +1294,6 @@ __FAILED:
return ret;
}
/*!
***********************************************************************
* \brief
* free frame store picture
***********************************************************************
*/
//extern "C"
void flush_muti_view_output(MppBufSlots frame_slots, H264dOutList_t *p_list, H264dVideoCtx_t *p_Vid)
{
RK_U32 i = 0;
MppFrame frame;
H264_DpbMark_t *p_mark = NULL;
H264dOutList_t *p_out = NULL;
//!< flush unpaired
for (i = 0; i < MAX_NUM_DPB_LAYERS; i++) {
p_out = &p_list[i];
p_mark = p_out->list[p_out->begin];
while (p_mark) {
mpp_buf_slot_get_prop(frame_slots, p_mark->slot_idx, SLOT_FRAME_PTR, &frame);
mpp_buf_slot_enqueue(frame_slots, p_mark->slot_idx, QUEUE_DISPLAY);
p_mark->out_flag = 0;
free_dpb_mark(p_Vid->p_Dec, p_mark, FRAME);
p_out->list[p_out->begin] = NULL;
p_out->begin = (p_out->begin + 1) % p_out->max_size;
p_mark = p_out->list[p_out->begin];
mpp_frame_set_discard(frame, 1);
}
}
}
/*!
***********************************************************************
* \brief

View File

@@ -45,7 +45,6 @@ MPP_RET exit_picture(H264dVideoCtx_t *p_Vid, H264_StorePic_t **dec_pic);
RK_U32 get_filed_dpb_combine_flag(H264_DpbBuf_t *p_Dpb, H264_StorePic_t *p);
H264_StorePic_t *alloc_storable_picture(H264dVideoCtx_t *p_Vid, RK_S32 structure);
void flush_muti_view_output(MppBufSlots frame_slots, H264dOutList_t *p_list, H264dVideoCtx_t *p_Vid);
#ifdef __cplusplus
}

View File

@@ -917,14 +917,6 @@ typedef struct h264d_cur_ctx_t {
RK_S64 curr_dts;
} H264dCurCtx_t;
//!< decoder video parameter
//!< output list marking
typedef struct h264d_outlist_t {
RK_U32 begin;
RK_U32 end;
RK_U32 max_size;
H264_DpbMark_t *list[MAX_MARK_SIZE];
} H264dOutList_t;
//!< parameters for video decoder
typedef struct h264d_video_ctx_t {
struct h264_sps_t spsSet[MAXSPS]; //!< MAXSPS, all sps storage
@@ -995,10 +987,6 @@ typedef struct h264d_video_ctx_t {
RK_U32 g_framecnt;
RK_U32 dpb_size[MAX_NUM_DPB_LAYERS];
RK_S32 last_outputpoc[MAX_NUM_DPB_LAYERS];
RK_U32 iframe_cnt;
RK_S32 first_iframe_poc;
struct h264d_outlist_t outlist[MAX_NUM_DPB_LAYERS];
} H264dVideoCtx_t;
typedef struct h264d_mem_t {
@@ -1056,9 +1044,8 @@ typedef struct h264_err_ctx_t {
RK_U32 parse_err_flag;
RK_U32 dpb_err_flag;
RK_U32 used_for_ref_flag;
RK_U32 i_slice_no;
RK_U32 dpb_err[MAX_NUM_DPB_LAYERS];
RK_U32 pre_status[MAX_NUM_DPB_LAYERS];
RK_U32 has_i_slice_flag;
RK_S32 first_iframe_poc;
} H264dErrCtx_t;
//!< decoder video parameter
typedef struct h264_dec_ctx_t {

View File

@@ -1396,6 +1396,12 @@ static void check_refer_picture_lists(H264_SLICE_t *currSlice)
} else {
p_Dec->errctx.dpb_err_flag |= check_ref_dbp_err(p_Dec, p_Dec->refpic_info_b[1]);
}
//!< B_SLICE only has one refer
if ((currSlice->active_sps->vui_seq_parameters.num_reorder_frames > 1)
&& (currSlice->p_Dpb->ref_frames_in_buffer < 2)) {
p_Dec->errctx.dpb_err_flag |= VPU_FRAME_ERR_UNKNOW;
H264D_DBG(H264D_DBG_DPB_REF_ERR, "[DPB_REF_ERR] error, B frame only has one refer");
}
}
#endif
@@ -1911,19 +1917,31 @@ MPP_RET reset_dpb_mark(H264_DpbMark_t *p_mark)
//extern "C"
MPP_RET init_picture(H264_SLICE_t *currSlice)
{
MPP_RET ret = MPP_ERR_UNKNOW;
H264_DecCtx_t *p_Dec = currSlice->p_Vid->p_Dec;
RK_U32 recoder_flag = 0;
MPP_RET ret = MPP_ERR_UNKNOW;
H264_DecCtx_t *p_Dec = currSlice->p_Vid->p_Dec;
H264dVideoCtx_t *p_Vid = currSlice->p_Vid;
H264dErrCtx_t *p_err = &p_Dec->errctx;
p_Dec->errctx.i_slice_no += ((!currSlice->layer_id) && (I_SLICE == currSlice->slice_type)) ? 1 : 0;
if (!p_Dec->errctx.i_slice_no) {
H264D_WARNNING("[Discard] Discard slice before I Slice.");
p_Dec->errctx.parse_err_flag |= VPU_FRAME_ERR_UNKNOW;
ret = MPP_NOK;
goto __FAILED;
}
//!< discard stream before I_SLICE
if (!p_err->has_i_slice_flag) {
if ((!currSlice->layer_id) && (I_SLICE == currSlice->slice_type)) {
recoder_flag = 1; //!< recode
p_err->has_i_slice_flag = 1;
} else {
H264D_WARNNING("[Discard] Discard slice before I Slice.");
p_Dec->errctx.parse_err_flag |= VPU_FRAME_ERR_UNKNOW;
ret = MPP_NOK;
goto __FAILED;
}
}
p_Dec->errctx.used_for_ref_flag = currSlice->nal_reference_idc ? 1 : 0;
FUN_CHECK(ret = alloc_decpic(currSlice));
if (p_err->has_i_slice_flag && recoder_flag) {
p_err->first_iframe_poc = p_Vid->dec_pic->poc; //!< recoder first i frame poc
}
//!< idr_memory_management MVC_layer, idr_flag==1
if (currSlice->layer_id && !currSlice->svc_extension_flag && !currSlice->mvcExt.non_idr_flag) {
ASSERT(currSlice->layer_id == 1);