From 43e66dd9cdbf4c75c71d2435c31a6746e6aa72ee Mon Sep 17 00:00:00 2001 From: DingWei Date: Fri, 6 May 2016 13:45:09 +0000 Subject: [PATCH] [hal_task] insert dpb_err_flag && used_for_ref_flag into valuable flags; when parse error, then dpb_err_flag is enable, and when next I slice or reorder right to disable. git-svn-id: https://10.10.10.66:8443/svn/MediaProcessPlatform/trunk/mpp@693 6e48237b-75ef-9749-8fc9-41990f28c85a --- mpp/codec/dec/h264/h264d_api.c | 20 ++++++++++------- mpp/codec/dec/h264/h264d_global.h | 4 ++-- mpp/codec/dec/h264/h264d_init.c | 30 +++++++++++++++++++------ mpp/codec/dec/h264/h264d_parse.c | 2 +- mpp/codec/dec/h264/h264d_sei.c | 2 +- mpp/codec/dec/h264/h264d_slice.c | 9 +++++++- mpp/hal/inc/hal_task.h | 8 +++---- mpp/hal/rkdec/h264d/hal_h264d_rkv_reg.c | 10 ++++----- 8 files changed, 56 insertions(+), 29 deletions(-) diff --git a/mpp/codec/dec/h264/h264d_api.c b/mpp/codec/dec/h264/h264d_api.c index 3843b4fd..463f7977 100644 --- a/mpp/codec/dec/h264/h264d_api.c +++ b/mpp/codec/dec/h264/h264d_api.c @@ -612,7 +612,7 @@ MPP_RET h264d_prepare(void *decoder, MppPacket pkt, HalDecTask *task) FunctionIn(p_Dec->logctx.parr[RUN_PARSE]); p_Inp = p_Dec->p_Inp; - if (p_Inp->has_get_eos) { + if (p_Inp->has_get_eos || p_Dec->errctx.un_spt_flag) { mpp_packet_set_length(pkt, 0); goto __RETURN; } @@ -691,18 +691,17 @@ __FAILED: MPP_RET h264d_parse(void *decoder, HalDecTask *in_task) { MPP_RET ret = MPP_ERR_UNKNOW; - + H264dErrCtx_t *p_err = NULL; H264_DecCtx_t *p_Dec = (H264_DecCtx_t *)decoder; INP_CHECK(ret, !decoder && !in_task); FunctionIn(p_Dec->logctx.parr[RUN_PARSE]); + p_err = &p_Dec->errctx; in_task->valid = 0; // prepare end flag p_Dec->in_task = in_task; - p_Dec->errctx.parse_err_flag = 0; - p_Dec->errctx.dpb_err_flag = 0; - p_Dec->errctx.used_for_ref_flag = 0; + p_err->used_ref_flag = 0; p_Dec->is_parser_end = 0; FUN_CHECK(ret = parse_loop(p_Dec)); @@ -720,8 +719,8 @@ MPP_RET h264d_parse(void *decoder, HalDecTask *in_task) in_task->valid = 1; // register valid flag in_task->syntax.number = p_Dec->dxva_ctx->syn.num; in_task->syntax.data = (void *)p_Dec->dxva_ctx->syn.buf; - in_task->dpb_err_flag = p_Dec->errctx.dpb_err_flag; - in_task->used_for_ref_flag = p_Dec->errctx.used_for_ref_flag; + in_task->flags.dpb_error = p_err->dpb_err_flag; + in_task->flags.used_for_ref = p_err->used_ref_flag; } __RETURN: FunctionOut(p_Dec->logctx.parr[RUN_PARSE]); @@ -738,7 +737,11 @@ __FAILED: MppFrame mframe = NULL; mpp_buf_slot_get_prop(p_Dec->frame_slots, dec_pic->mem_mark->slot_idx, SLOT_FRAME_PTR, &mframe); if (mframe) { - mpp_frame_set_errinfo(mframe, VPU_FRAME_ERR_UNKNOW); + if (p_err->used_ref_flag) { + mpp_frame_set_errinfo(mframe, VPU_FRAME_ERR_UNKNOW); + } else { + mpp_frame_set_discard(mframe, VPU_FRAME_ERR_UNKNOW); + } } mpp_buf_slot_set_flag(p_Dec->frame_slots, dec_pic->mem_mark->slot_idx, SLOT_QUEUE_USE); mpp_buf_slot_enqueue(p_Dec->frame_slots, dec_pic->mem_mark->slot_idx, QUEUE_DISPLAY); @@ -749,6 +752,7 @@ __FAILED: MPP_FREE(dec_pic); p_Dec->p_Vid->dec_pic = NULL; } + p_err->dpb_err_flag = p_err->used_ref_flag ? 1 : 0; } return ret; diff --git a/mpp/codec/dec/h264/h264d_global.h b/mpp/codec/dec/h264/h264d_global.h index a4bd6a4c..c5626c24 100644 --- a/mpp/codec/dec/h264/h264d_global.h +++ b/mpp/codec/dec/h264/h264d_global.h @@ -1034,9 +1034,9 @@ typedef enum slice_state_type { } SLICE_STATUS; typedef struct h264_err_ctx_t { - RK_U32 parse_err_flag; + RK_U32 un_spt_flag; RK_U32 dpb_err_flag; - RK_U32 used_for_ref_flag; + RK_U32 used_ref_flag; RK_U32 i_slice_no; RK_S32 first_iframe_poc; } H264dErrCtx_t; diff --git a/mpp/codec/dec/h264/h264d_init.c b/mpp/codec/dec/h264/h264d_init.c index 3d02d8c6..cf672d9d 100644 --- a/mpp/codec/dec/h264/h264d_init.c +++ b/mpp/codec/dec/h264/h264d_init.c @@ -1442,14 +1442,27 @@ static RK_U32 check_ref_dbp_err(H264_DecCtx_t *p_Dec, H264_RefPicInfo_t *pref) for (i = 0; i < MAX_REF_SIZE; i++) { if (pref[i].valid) { MppFrame mframe = NULL; - RK_U32 slot_idx = p_Dec->dpb_info[pref->dpb_idx].slot_index; + RK_U32 slot_idx = p_Dec->dpb_info[pref[i].dpb_idx].slot_index; mpp_buf_slot_get_prop(p_Dec->frame_slots, slot_idx, SLOT_FRAME_PTR, &mframe); - if(mframe) { + if (mframe) { dpb_error_flag |= mpp_frame_get_errinfo(mframe); H264D_DBG(H264D_DBG_DPB_REF_ERR, "[DPB_REF_ERR] slot_idx=%d, dpb_err[%d]=%d", slot_idx, i, mpp_frame_get_errinfo(mframe)); } } } + + //for (i = 0; i < MAX_DPB_SIZE; i++) { + // RK_S32 slot_idx = p_Dec->in_task->refer[i]; + // if (slot_idx >= 0) { + // MppFrame mframe = NULL; + // mpp_buf_slot_get_prop(p_Dec->frame_slots, slot_idx, SLOT_FRAME_PTR, &mframe); + // if (mframe) { + // dpb_error_flag |= mpp_frame_get_errinfo(mframe); + // H264D_DBG(H264D_DBG_DPB_REF_ERR, "[DPB_REF_ERR] slot_idx=%d, dpb_err[%d]=%d", slot_idx, i, mpp_frame_get_errinfo(mframe)); + // } + // } + //} + return dpb_error_flag; } @@ -1458,7 +1471,6 @@ static void check_refer_picture_lists(H264_SLICE_t *currSlice) H264_DecCtx_t *p_Dec = currSlice->p_Dec; if (I_SLICE == currSlice->slice_type) { - p_Dec->errctx.dpb_err_flag = 0; goto __RETURN; } #if 1 @@ -1466,14 +1478,20 @@ static void check_refer_picture_lists(H264_SLICE_t *currSlice) if ((currSlice->slice_type % 5) != I_SLICE && (currSlice->slice_type % 5) != SI_SLICE) { if (currSlice->ref_pic_list_reordering_flag[LIST_0]) { - p_Dec->errctx.dpb_err_flag |= check_ref_pic_list(currSlice, 0); + if (check_ref_pic_list(currSlice, 0)) { + p_Dec->errctx.dpb_err_flag |= VPU_FRAME_ERR_UNKNOW; + } else { + p_Dec->errctx.dpb_err_flag = 0; + } } else { p_Dec->errctx.dpb_err_flag |= check_ref_dbp_err(p_Dec, p_Dec->refpic_info_b[0]); } } if (currSlice->slice_type % 5 == B_SLICE) { if (currSlice->ref_pic_list_reordering_flag[LIST_1]) { - p_Dec->errctx.dpb_err_flag |= check_ref_pic_list(currSlice, 1); + if (check_ref_pic_list(currSlice, 1)) { + p_Dec->errctx.dpb_err_flag |= VPU_FRAME_ERR_UNKNOW; + } } else { p_Dec->errctx.dpb_err_flag |= check_ref_dbp_err(p_Dec, p_Dec->refpic_info_b[1]); } @@ -2065,11 +2083,9 @@ MPP_RET init_picture(H264_SLICE_t *currSlice) p_err->i_slice_no += ((!currSlice->layer_id) && (I_SLICE == currSlice->slice_type)) ? 1 : 0; if (!p_err->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; } - p_Dec->errctx.used_for_ref_flag = currSlice->nal_reference_idc ? 1 : 0; FUN_CHECK(ret = alloc_decpic(currSlice)); diff --git a/mpp/codec/dec/h264/h264d_parse.c b/mpp/codec/dec/h264/h264d_parse.c index 24df3216..c419191f 100644 --- a/mpp/codec/dec/h264/h264d_parse.c +++ b/mpp/codec/dec/h264/h264d_parse.c @@ -966,6 +966,7 @@ MPP_RET parse_loop(H264_DecCtx_t *p_Dec) break; case SliceSTATE_RegisterOneFrame: if (!p_Dec->is_parser_end){ + ret = MPP_NOK; goto __FAILED; } commit_buffer(p_Dec->dxva_ctx); @@ -991,7 +992,6 @@ __FAILED: p_Dec->dxva_ctx->strm_offset = 0; p_Dec->p_Vid->iNumOfSlicesDecoded = 0; p_Dec->p_Vid->exit_picture_flag = 0; - p_Dec->errctx.parse_err_flag |= VPU_FRAME_ERR_UNKNOW; return ret; } diff --git a/mpp/codec/dec/h264/h264d_sei.c b/mpp/codec/dec/h264/h264d_sei.c index b142b53c..49be3007 100644 --- a/mpp/codec/dec/h264/h264d_sei.c +++ b/mpp/codec/dec/h264/h264d_sei.c @@ -74,7 +74,7 @@ static MPP_RET interpret_user_data_unregistered_info(RK_U8 *payload, RK_S32 size sei_msg->user_data_DivX_flag = strstr(_strupr((char *)&payload[16]), "DIVX") ? 1 : 0; if (sei_msg->user_data_DivX_flag) { H264D_ERR("DivX is not supported. \n"); - sei_msg->p_Dec->errctx.parse_err_flag |= VPU_FRAME_ERR_UNSUPPORT; + sei_msg->p_Dec->errctx.un_spt_flag = 1; ret = MPP_NOK; goto __FAILED; } diff --git a/mpp/codec/dec/h264/h264d_slice.c b/mpp/codec/dec/h264/h264d_slice.c index df30d0cd..8faf36d5 100644 --- a/mpp/codec/dec/h264/h264d_slice.c +++ b/mpp/codec/dec/h264/h264d_slice.c @@ -322,7 +322,14 @@ static void init_slice_parmeters(H264_SLICE_t *currSlice) //--- init slice syntax currSlice->idr_flag = ((cur_nalu->nalu_type == NALU_TYPE_IDR) || (currSlice->mvcExt.valid && !currSlice->mvcExt.non_idr_flag)); - currSlice->nal_reference_idc = cur_nalu->nal_reference_idc; + currSlice->nal_reference_idc = cur_nalu->nal_reference_idc; + //!< set ref flag and dpb error flag + { + p_Vid->p_Dec->errctx.used_ref_flag = currSlice->nal_reference_idc ? 1 : 0; + if (currSlice->slice_type == I_SLICE) { + p_Vid->p_Dec->errctx.dpb_err_flag = 0; + } + } if ((!currSlice->svc_extension_flag) || currSlice->mvcExt.iPrefixNALU) { // MVC or have prefixNALU currSlice->view_id = currSlice->mvcExt.view_id; currSlice->inter_view_flag = currSlice->mvcExt.inter_view_flag; diff --git a/mpp/hal/inc/hal_task.h b/mpp/hal/inc/hal_task.h index fcab62b6..2df6a73e 100644 --- a/mpp/hal/inc/hal_task.h +++ b/mpp/hal/inc/hal_task.h @@ -83,8 +83,10 @@ typedef struct MppSyntax_t { typedef union HalDecTaskFlag_t { RK_U32 val; struct { - RK_U32 eos : 1; - RK_U32 info_change : 1; + RK_U32 eos : 1; + RK_U32 info_change : 1; + RK_U32 dpb_error : 1; + RK_U32 used_for_ref : 1; }; } HalDecTaskFlag; @@ -96,8 +98,6 @@ typedef struct HalDecTask_t { // previous task hardware working status // when hardware error happen status is not zero RK_U32 prev_status; - RK_U32 dpb_err_flag; - RK_U32 used_for_ref_flag; // current tesk protocol syntax information MppSyntax syntax; diff --git a/mpp/hal/rkdec/h264d/hal_h264d_rkv_reg.c b/mpp/hal/rkdec/h264d/hal_h264d_rkv_reg.c index 712e7e39..0dea64c7 100644 --- a/mpp/hal/rkdec/h264d/hal_h264d_rkv_reg.c +++ b/mpp/hal/rkdec/h264d/hal_h264d_rkv_reg.c @@ -321,7 +321,7 @@ MPP_RET rkv_h264d_gen_regs(void *hal, HalTaskInfo *task) INP_CHECK(ret, NULL == p_hal); FunctionIn(p_hal->logctx.parr[RUN_HAL]); - if (task->dec.dpb_err_flag) { + if (task->dec.flags.dpb_error) { goto __RETURN; } rkv_prepare_spspps_packet(hal, &pkts->spspps); @@ -369,7 +369,7 @@ MPP_RET rkv_h264d_start(void *hal, HalTaskInfo *task) INP_CHECK(ret, NULL == p_hal); FunctionIn(p_hal->logctx.parr[RUN_HAL]); - if (task->dec.dpb_err_flag) { + if (task->dec.flags.dpb_error) { goto __RETURN; } p_regs = (RK_U32 *)p_hal->regs; @@ -420,7 +420,7 @@ MPP_RET rkv_h264d_wait(void *hal, HalTaskInfo *task) FunctionIn(p_hal->logctx.parr[RUN_HAL]); p_regs = (H264dRkvRegs_t *)p_hal->regs; - if (task->dec.dpb_err_flag) { + if (task->dec.flags.dpb_error) { goto __SKIP_HARD; } #ifdef ANDROID @@ -450,8 +450,8 @@ MPP_RET rkv_h264d_wait(void *hal, HalTaskInfo *task) } __SKIP_HARD: p_regs->slot_idx = task->dec.output; - p_regs->dpb_err_flag = task->dec.dpb_err_flag; - p_regs->used_for_ref_flag = task->dec.used_for_ref_flag; + p_regs->dpb_err_flag = task->dec.flags.dpb_error; + p_regs->used_for_ref_flag = task->dec.flags.used_for_ref; if (p_hal->init_cb.callBack) { p_hal->init_cb.callBack(p_hal->init_cb.opaque, p_hal->regs); }