diff --git a/inc/mpp_frame.h b/inc/mpp_frame.h index efa37fe1..7fcb9db1 100644 --- a/inc/mpp_frame.h +++ b/inc/mpp_frame.h @@ -174,7 +174,8 @@ RK_S64 mpp_frame_get_pts(const MppFrame frame); void mpp_frame_set_pts(MppFrame frame, RK_S64 pts); RK_S64 mpp_frame_get_dts(const MppFrame frame); void mpp_frame_set_dts(MppFrame frame, RK_S64 dts); - +RK_U32 mpp_frame_get_errinfo(const MppFrame frame); +void mpp_frame_set_errinfo(MppFrame frame, RK_U32 errinfo); /* * flow control parmeter */ diff --git a/inc/vpu_api.h b/inc/vpu_api.h index 28575726..7d4a688e 100644 --- a/inc/vpu_api.h +++ b/inc/vpu_api.h @@ -205,6 +205,12 @@ typedef enum VPU_API_ERR { VPU_API_ERR_BUTT, } VPU_API_ERR; +typedef enum VPU_FRAME_ERR { + VPU_FRAME_ERR_UNKNOW = 0x0001, + VPU_FRAME_ERR_UNSUPPORT = 0x0002, + +} VPU_FRAME_ERR; + typedef struct EncParameter { RK_S32 width; RK_S32 height; diff --git a/mpp/codec/dec/h264/h264d_api.c b/mpp/codec/dec/h264/h264d_api.c index d32d797a..5fc9cd1b 100644 --- a/mpp/codec/dec/h264/h264d_api.c +++ b/mpp/codec/dec/h264/h264d_api.c @@ -23,6 +23,8 @@ #include "mpp_packet_impl.h" #include "mpp_mem.h" +#include "vpu_api.h" + #include "h264d_log.h" #include "h264d_api.h" #include "h264d_global.h" @@ -372,11 +374,14 @@ static MPP_RET init_dec_ctx(H264_DecCtx_t *p_Dec) //!< malloc mpp packet mpp_packet_init(&p_Dec->task_pkt, p_Dec->dxva_ctx->bitstream, p_Dec->dxva_ctx->max_strm_size); MEM_CHECK(ret, p_Dec->task_pkt); + //!< memset error context + memset(&p_Dec->err_ctx, 0, sizeof(H264dErrCtx_t)); //!< set Dec support decoder method p_Dec->spt_decode_mtds = MPP_DEC_BY_FRAME; p_Dec->next_state = SliceSTATE_ResetSlice; p_Dec->nalu_ret = NALU_NULL; p_Dec->is_first_frame = 1; + p_Dec->last_frame_slot_idx = -1; __RETURN: return ret = MPP_OK; @@ -405,6 +410,7 @@ static void get_pkt_timestamp(H264dCurStream_t *p_strm, H264dInputCtx_t *p_Inp, } } #endif + /*! *********************************************************************** * \brief @@ -636,7 +642,7 @@ MPP_RET h264d_prepare(void *decoder, MppPacket pkt, HalDecTask *task) FunctionIn(p_Dec->logctx.parr[RUN_PARSE]); //LogTrace(logctx, "Prepare In:len=%d, valid=%d ", mpp_packet_get_length(pkt), task->valid); - if (p_Dec->p_Inp->has_get_eos || p_Dec->error_flag) { + if (p_Dec->p_Inp->has_get_eos || p_Dec->err_ctx.err_flag) { ((MppPacketImpl *)pkt)->length = 0; goto __RETURN; } @@ -742,42 +748,21 @@ MPP_RET h264d_parse(void *decoder, HalDecTask *in_task) in_task->valid = 0; // prepare end flag p_Dec->in_task = in_task; - // mpp_packet_set_data(p_Dec->task_pkt, p_Dec->dxva_ctx->bitstream); - // mpp_packet_set_length(p_Dec->task_pkt, p_Dec->dxva_ctx->strm_offset); - // mpp_packet_set_size(p_Dec->task_pkt, p_Dec->dxva_ctx->max_strm_size); - // LogTrace(p_Dec->logctx.parr[RUN_PARSE], "[Parse_In] stream_len=%d, eos=%d, g_framecnt=%d", - //mpp_packet_get_length(p_Dec->task_pkt), in_task->flags.eos, p_Dec->p_Vid->g_framecnt); - - //FPRINT(g_debug_file0, "[Parse_In] stream_len=%d, eos=%d, g_framecnt=%d \n", - // mpp_packet_get_length(p_Dec->task_pkt), in_task->flags.eos, p_Dec->p_Vid->g_framecnt); - - // if (p_Dec->p_Inp->is_nalff && in_task->flags.eos) { - //h264d_flush(decoder); - //goto __RETURN; - // } - FUN_CHECK(ret = parse_loop(p_Dec)); if (p_Dec->is_parser_end) { p_Dec->is_parser_end = 0; - //LogTrace(p_Dec->logctx.parr[RUN_PARSE], "[Prarse loop end]"); 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; - FUN_CHECK(ret = update_dpb(p_Dec)); - //LogTrace(p_Dec->logctx.parr[RUN_PARSE], "[Update dpb end]"); - //mpp_log_f("[PARSE_OUT] line=%d, g_framecnt=%d",__LINE__, p_Dec->p_Vid->g_framecnt++/*in_task->g_framecnt*/); - //LogTrace(p_Dec->logctx.parr[RUN_PARSE], "[PARSE_OUT] line=%d, g_framecnt=%d", __LINE__, p_Dec->p_Vid->g_framecnt); - //FPRINT(g_debug_file0, "[PARSE_END] g_framecnt=%d \n", p_Dec->p_Vid->g_framecnt); + FUN_CHECK(ret = update_dpb(p_Dec)); + if (in_task->flags.eos) { h264d_flush(decoder); } p_Dec->p_Vid->g_framecnt++; } - - - __RETURN: FunctionOut(p_Dec->logctx.parr[RUN_PARSE]); return ret = MPP_OK; @@ -791,11 +776,41 @@ __FAILED: * callback *********************************************************************** */ + MPP_RET h264d_callback(void *decoder, void *err_info) { - (void) decoder; - (void) err_info; - return MPP_OK; + MPP_RET ret = MPP_ERR_UNKNOW; + MppFrame m_frame; + H264_DecCtx_t *p_Dec = (H264_DecCtx_t *)decoder; + H264dErrCtx_t *ctx = (H264dErrCtx_t *)err_info; + + INP_CHECK(ret, !decoder && !err_info); + FunctionIn(p_Dec->logctx.parr[RUN_PARSE]); + + ctx->err_flag |= VPU_FRAME_ERR_UNSUPPORT; + + if(ctx->err_flag & VPU_FRAME_ERR_UNSUPPORT) { + h264d_reset(decoder); + } + + if (p_Dec->last_frame_slot_idx < 0) { + mpp_frame_init(&m_frame); + mpp_slots_get_prop(p_Dec->frame_slots, SLOTS_FRAME_INFO, m_frame); + mpp_buf_slot_get_unused(p_Dec->frame_slots, &p_Dec->last_frame_slot_idx); + mpp_buf_slot_set_prop(p_Dec->frame_slots, p_Dec->last_frame_slot_idx, SLOT_FRAME, m_frame); + mpp_buf_slot_set_flag(p_Dec->frame_slots, p_Dec->last_frame_slot_idx, SLOT_QUEUE_USE); + mpp_buf_slot_enqueue(p_Dec->frame_slots, p_Dec->last_frame_slot_idx, QUEUE_DISPLAY); + mpp_buf_slot_clr_flag(p_Dec->frame_slots, p_Dec->last_frame_slot_idx, SLOT_HAL_OUTPUT); + mpp_buf_slot_clr_flag(p_Dec->frame_slots, p_Dec->last_frame_slot_idx, SLOT_CODEC_USE); + mpp_frame_deinit(&m_frame); + } + mpp_buf_slot_get_prop(p_Dec->frame_slots, p_Dec->last_frame_slot_idx, SLOT_FRAME_PTR, &m_frame); + if (m_frame) { + mpp_frame_set_errinfo(m_frame, ctx->err_flag); + } +__RETURN: + FunctionOut(p_Dec->logctx.parr[RUN_PARSE]); + return ret = MPP_OK; } /*! *********************************************************************** diff --git a/mpp/codec/dec/h264/h264d_dpb.c b/mpp/codec/dec/h264/h264d_dpb.c index 1b3ba003..c50d0a9f 100644 --- a/mpp/codec/dec/h264/h264d_dpb.c +++ b/mpp/codec/dec/h264/h264d_dpb.c @@ -1746,21 +1746,24 @@ RK_U32 get_filed_dpb_combine_flag(H264_DpbBuf_t *p_Dpb, H264_StorePic_t *p) MPP_RET init_dpb(H264dVideoCtx_t *p_Vid, H264_DpbBuf_t *p_Dpb, RK_S32 type) // type=1 AVC type=2 MVC { RK_U32 i = 0; - RK_S32 PicSizeInMbs = 0; MPP_RET ret = MPP_ERR_UNKNOW; H264_SPS_t *active_sps = p_Vid->active_sps; + if(!active_sps){ + ret = MPP_NOK; + goto __FAILED; + } p_Dpb->p_Vid = p_Vid; if (p_Dpb->init_done) { free_dpb(p_Dpb); } p_Dpb->size = getDpbSize(p_Vid, active_sps) + (type == 2 ? 0 : 1); p_Dpb->num_ref_frames = active_sps->max_num_ref_frames; - if (active_sps->max_dec_frame_buffering < active_sps->max_num_ref_frames) { + //if (active_sps->max_dec_frame_buffering < active_sps->max_num_ref_frames) { //H264D_LOG("DPB size at specified level is smaller than reference frames"); //LogError(runlog, "DPB size at specified level is smaller than reference frames"); //goto __FAILED; - } + //} p_Dpb->used_size = 0; p_Dpb->last_picture = NULL; p_Dpb->ref_frames_in_buffer = 0; @@ -1794,7 +1797,6 @@ MPP_RET init_dpb(H264dVideoCtx_t *p_Vid, H264_DpbBuf_t *p_Dpb, RK_S32 type) // } //!< allocate a dummy storable picture if (!p_Vid->no_ref_pic) { - PicSizeInMbs = (p_Vid->active_sps->pic_height_in_map_units_minus1 + 1) * (p_Vid->active_sps->pic_width_in_mbs_minus1 + 1); p_Vid->no_ref_pic = alloc_storable_picture(p_Vid, FRAME); MEM_CHECK(ret, p_Vid->no_ref_pic); p_Vid->no_ref_pic->top_field = p_Vid->no_ref_pic; @@ -1805,11 +1807,9 @@ MPP_RET init_dpb(H264dVideoCtx_t *p_Vid, H264_DpbBuf_t *p_Dpb, RK_S32 type) // p_Dpb->last_output_view_id = -1; p_Vid->last_has_mmco_5 = 0; p_Dpb->init_done = 1; - (void)PicSizeInMbs; return ret = MPP_OK; __FAILED: - ASSERT(0); return ret; } /*! diff --git a/mpp/codec/dec/h264/h264d_global.h b/mpp/codec/dec/h264/h264d_global.h index 61f43420..dcfedb28 100644 --- a/mpp/codec/dec/h264/h264d_global.h +++ b/mpp/codec/dec/h264/h264d_global.h @@ -693,6 +693,8 @@ typedef struct h264_sei_t { //---- follow is used in other parts RK_S32 mvc_scalable_nesting_flag; RK_S32 seq_parameter_set_id; + + struct h264_dec_ctx_t *p_Dec; } H264_SEI_t; //!< SLICE @@ -820,9 +822,6 @@ typedef struct h264d_dxva_ctx_t { struct h264_dec_ctx_t *p_Dec; } H264dDxvaCtx_t; - - - //!< input parameter typedef struct h264d_input_ctx_t { struct h264_dec_ctx_t *p_Dec; @@ -1045,6 +1044,13 @@ typedef enum slice_state_type { } SLICE_STATUS; +//!< decoder video parameter +typedef struct h264_err_ctx_t { + RK_U32 err_flag; + void *data; + RK_U32 length; +}H264dErrCtx_t; + //!< decoder video parameter typedef struct h264_dec_ctx_t { @@ -1079,8 +1085,7 @@ typedef struct h264_dec_ctx_t { RK_U32 task_eos; HalDecTask *in_task; RK_S32 last_frame_slot_idx; - - RK_U32 error_flag; + struct h264_err_ctx_t err_ctx; } H264_DecCtx_t; diff --git a/mpp/codec/dec/h264/h264d_parse.c b/mpp/codec/dec/h264/h264d_parse.c index 8c6ff5de..dd03b1c3 100644 --- a/mpp/codec/dec/h264/h264d_parse.c +++ b/mpp/codec/dec/h264/h264d_parse.c @@ -157,9 +157,9 @@ static MPP_RET parser_nalu_header(H264_SLICE_t *currSlice) ASSERT(cur_nal->forbidden_bit == 0); READ_BITS(p_bitctx, 2, (RK_S32 *)&cur_nal->nal_reference_idc, "nal_ref_idc"); READ_BITS(p_bitctx, 5, (RK_S32 *)&cur_nal->nalu_type, "nalu_type"); - if (g_nalu_cnt0 == 2384) { - g_nalu_cnt0 = g_nalu_cnt0; - } + //if (g_nalu_cnt0 == 2384) { + // g_nalu_cnt0 = g_nalu_cnt0; + //} cur_nal->ualu_header_bytes = 1; currSlice->svc_extension_flag = -1; //!< initialize to -1 @@ -189,9 +189,10 @@ static MPP_RET parser_nalu_header(H264_SLICE_t *currSlice) //FPRINT(logctx->parr[LOG_READ_NALU]->fp, "g_nalu_cnt=%d, nalu_type=%d, len=%d \n", g_nalu_cnt++, cur_nal->nalu_type, cur_nal->sodb_len); } cur_nal->ualu_header_bytes += 3; - } else { + } + //else { //FPRINT(logctx->parr[LOG_READ_NALU]->fp, "g_nalu_cnt=%d, nalu_type=%d, len=%d \n", g_nalu_cnt++, cur_nal->nalu_type, cur_nal->sodb_len); - } + //} mpp_set_bitread_ctx(p_bitctx, (cur_nal->sodb_buf + cur_nal->ualu_header_bytes), (cur_nal->sodb_len - cur_nal->ualu_header_bytes)); // reset p_Cur->p_Dec->nalu_ret = StartofNalu; @@ -242,7 +243,7 @@ static MPP_RET parser_one_nalu(H264_SLICE_t *currSlice) LogTrace(runlog, "nalu_type=SUB_SPS"); break; case NALU_TYPE_SEI: - //FUN_CHECK(ret = process_sei(currSlice)); + FUN_CHECK(ret = process_sei(currSlice)); LogTrace(runlog, "nalu_type=SEI"); currSlice->p_Dec->nalu_ret = NALU_SEI; break; @@ -630,7 +631,7 @@ MPP_RET parse_prepare_fast(H264dInputCtx_t *p_Inp, H264dCurCtx_t *p_Cur) if (!p_Inp->in_length) { p_strm->nalu_offset = 0; p_Dec->nalu_ret = HaveNoStream; - + p_strm->endcode_found = 1; p_Dec->nalu_ret = EndOfNalu; FUN_CHECK(ret = store_cur_nalu(&p_Dec->p_Cur->strm, p_Dec->dxva_ctx)); @@ -640,6 +641,7 @@ MPP_RET parse_prepare_fast(H264dInputCtx_t *p_Inp, H264dCurCtx_t *p_Cur) p_Cur->p_Inp->task_valid = 1; p_Cur->p_Dec->is_new_frame = 0; reset_nalu(p_strm); + p_strm->startcode_found = 0; p_Cur->last_dts = p_Cur->curr_dts; p_Cur->last_pts = p_Cur->curr_pts; @@ -867,7 +869,6 @@ MPP_RET parse_loop(H264_DecCtx_t *p_Dec) case SliceSTATE_ResetSlice: reset_slice(p_Dec->p_Vid); p_Dec->next_state = SliceSTATE_ReadNalu; - //H264D_LOG( "SliceSTATE_ResetSlice"); break; case SliceSTATE_ReadNalu: p_head = (H264dNaluHead_t *)p_curdata; @@ -883,7 +884,6 @@ MPP_RET parse_loop(H264_DecCtx_t *p_Dec) p_Dec->nalu_ret = EndOfNalu; p_Dec->next_state = SliceSTATE_ParseNalu; } - //H264D_LOG( "SliceSTATE_ReadNalu"); break; case SliceSTATE_ParseNalu: (ret = parser_one_nalu(&p_Dec->p_Cur->slice)); @@ -894,30 +894,30 @@ MPP_RET parse_loop(H264_DecCtx_t *p_Dec) } else { p_Dec->next_state = SliceSTATE_ReadNalu; } - //H264D_LOG("SliceSTATE_ParseNalu"); break; case SliceSTATE_InitPicture: (ret = init_picture(&p_Dec->p_Cur->slice)); p_Dec->next_state = SliceSTATE_GetSliceData; - //H264D_LOG("SliceSTATE_InitPicture"); break; case SliceSTATE_GetSliceData: (ret = fill_slice_syntax(&p_Dec->p_Cur->slice, p_Dec->dxva_ctx)); p_Dec->p_Vid->iNumOfSlicesDecoded++; p_Dec->next_state = SliceSTATE_ResetSlice; - //H264D_LOG("SliceSTATE_GetSliceData"); break; case SliceSTATE_RegisterOneFrame: commit_buffer(p_Dec->dxva_ctx); while_loop_flag = 0; p_Dec->is_parser_end = 1; p_Dec->next_state = SliceSTATE_ReadNalu; - //H264D_LOG("SliceSTATE_RegisterOneFrame"); break; default: ret = MPP_NOK; - goto __FAILED; + break; } + if (p_Dec->err_ctx.err_flag) { + h264d_callback((void *)p_Dec, (void*)&p_Dec->err_ctx); + goto __FAILED; + } } FunctionOut(p_Dec->logctx.parr[RUN_PARSE]); //__RETURN: diff --git a/mpp/codec/dec/h264/h264d_sei.c b/mpp/codec/dec/h264/h264d_sei.c index 17c77a4d..7127a12c 100644 --- a/mpp/codec/dec/h264/h264d_sei.c +++ b/mpp/codec/dec/h264/h264d_sei.c @@ -20,6 +20,8 @@ #include #include +#include "vpu_api.h" + #include "h264d_log.h" #include "h264d_sps.h" #include "h264d_sei.h" @@ -66,28 +68,37 @@ static MPP_RET interpret_user_data_unregistered_info(RK_U8 *payload, RK_S32 size { char *pdata = NULL; MPP_RET ret = MPP_ERR_UNKNOW; - + H264D_LOG("size=%d",size); ASSERT(size >= 16); - pdata = strupr((char *)payload); - sei_msg->user_data_DivX_flag = strstr(pdata, "DIVX") ? 1 : 0; - H264D_LOG("DivX is not supported. \n"); - #if 0 - RK_U32 offset = 0; - RK_U8 payload_byte; - mpp_log("User data unregistered SEI message\n"); - mpp_log("uuid_iso_11578 = 0x"); - for (offset = 0; offset < 16; offset++) { - mpp_log("%02x",payload[offset]); - } - while (offset < size) { - payload_byte = payload[offset]; - offset++; - mpp_log("Unreg data payload_byte = %d\n", payload_byte); + { + RK_U32 offset = 0; + RK_U8 payload_byte; + mpp_log("User data unregistered SEI message\n"); + mpp_log("uuid_iso_11578 = 0x"); + for (offset = 0; offset < 16; offset++) { + mpp_log("%02x",payload[offset]); + } + while (offset < size) { + payload_byte = payload[offset]; + offset++; + mpp_log("Unreg data payload_byte = %02x\n", payload_byte); + } } #endif + 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->err_ctx.err_flag |= VPU_FRAME_ERR_UNSUPPORT; + ret = MPP_NOK; + goto __FAILED; + } + + return ret = MPP_OK; +__FAILED: + return ret; } static void interpret_pan_scan_rect_info() @@ -176,7 +187,7 @@ __BITREAD_ERR: } -static MPP_RET interpret_mvc_scalable_nesting_info(RK_U8 *payload, RK_S32 size, BitReadCtx_t *p_bitctx, H264_SEI_t *sei_msg) +static MPP_RET interpret_mvc_scalable_nesting_info(RK_U8 *payload, RK_S32 size, BitReadCtx_t *p_bitctx) { RK_S32 i; RK_U32 operation_point_flag; @@ -207,8 +218,7 @@ static MPP_RET interpret_mvc_scalable_nesting_info(RK_U8 *payload, RK_S32 size, READ_BITS(p_strm, 3, &sei_op_temporal_id, "sei_op_temporal_id"); } - p_bitctx->used_bits = p_strm->used_bits; - sei_msg->mvc_scalable_nesting_flag = 1; + p_bitctx->used_bits = p_strm->used_bits; return ret = MPP_OK; __BITREAD_ERR: ret = p_bitctx->ret; @@ -246,15 +256,30 @@ static void interpret_reserved_info(RK_U8 *payload, RK_S32 size, BitReadCtx_t *p (void)payload_byte; } -static MPP_RET parserSEI(BitReadCtx_t *p_bitctx, H264_SEI_t *sei_msg, RK_U8 *msg) +static MPP_RET parserSEI(H264_SLICE_t *cur_slice, BitReadCtx_t *p_bitctx, H264_SEI_t *sei_msg, RK_U8 *msg) { MPP_RET ret = MPP_ERR_UNKNOW; - //!< sei_payload( type, size ); - H264D_LOG("[SEI_TYPE] type=%d \n", sei_msg->type); + H264dVideoCtx_t *p_Vid = cur_slice->p_Vid; + H264D_LOG("[SEI_TYPE] type=%d \n", sei_msg->type); switch (sei_msg->type) { case SEI_BUFFERING_PERIOD: FUN_CHECK(ret = interpret_buffering_period_info(msg, sei_msg->payload_size, p_bitctx, sei_msg)); + { + H264_SPS_t *sps = NULL; + H264_subSPS_t *subset_sps = NULL; + if (sei_msg->mvc_scalable_nesting_flag) { + p_Vid->active_mvc_sps_flag = 1; + sps = NULL; + subset_sps = &p_Vid->subspsSet[sei_msg->seq_parameter_set_id]; + } else { + p_Vid->active_mvc_sps_flag = 0; + sps = &p_Vid->spsSet[sei_msg->seq_parameter_set_id]; + subset_sps = NULL; + } + p_Vid->exit_picture_flag = 1; + FUN_CHECK(ret = activate_sps(p_Vid, sps, subset_sps)); + } break; case SEI_PIC_TIMING: interpret_picture_timing_info(); @@ -269,7 +294,7 @@ static MPP_RET parserSEI(BitReadCtx_t *p_bitctx, H264_SEI_t *sei_msg, RK_U8 *msg interpret_user_data_registered_itu_t_t35_info(); break; case SEI_USER_DATA_UNREGISTERED: - interpret_user_data_unregistered_info(msg, sei_msg->payload_size, sei_msg); + FUN_CHECK(ret = interpret_user_data_unregistered_info(msg, sei_msg->payload_size, sei_msg)); break; case SEI_RECOVERY_POINT: FUN_CHECK(ret = interpret_recovery_point_info(msg, sei_msg->payload_size, p_bitctx, sei_msg)); @@ -328,7 +353,8 @@ static MPP_RET parserSEI(BitReadCtx_t *p_bitctx, H264_SEI_t *sei_msg, RK_U8 *msg interpret_frame_packing_arrangement_info(); break; case SEI_MVC_SCALABLE_NESTING: - FUN_CHECK(ret = interpret_mvc_scalable_nesting_info(msg, sei_msg->payload_size, p_bitctx, sei_msg)); + FUN_CHECK(ret = interpret_mvc_scalable_nesting_info(msg, sei_msg->payload_size, p_bitctx)); + sei_msg->mvc_scalable_nesting_flag = 1; break; case SEI_VIEW_SCALABILITY_INFO: interpret_mvc_scalability_info(); @@ -342,40 +368,6 @@ static MPP_RET parserSEI(BitReadCtx_t *p_bitctx, H264_SEI_t *sei_msg, RK_U8 *msg __FAILED: return ret; } - -static MPP_RET analysisSEI(H264_SLICE_t *cur_slice) -{ - H264_SPS_t *sps = NULL; - H264_subSPS_t *subset_sps = NULL; - MPP_RET ret = MPP_ERR_UNKNOW; - H264dVideoCtx_t *p_Vid = cur_slice->p_Vid; - H264_SEI_t *sei_msg = &cur_slice->p_Cur->sei; - - switch (sei_msg->type) { // sei_payload( type, size ) - case SEI_BUFFERING_PERIOD: - if (sei_msg->mvc_scalable_nesting_flag) { - p_Vid->active_mvc_sps_flag = 1; - sps = NULL; - subset_sps = &p_Vid->subspsSet[sei_msg->seq_parameter_set_id]; - } else { - p_Vid->active_mvc_sps_flag = 0; - sps = &p_Vid->spsSet[sei_msg->seq_parameter_set_id]; - subset_sps = NULL; - } - p_Vid->exit_picture_flag = 1; - FUN_CHECK(ret = activate_sps(p_Vid, sps, subset_sps)); - break; - default: - - break; - } - - return ret = MPP_OK; - -__FAILED: - return ret; -} - /*! *********************************************************************** * \brief @@ -394,7 +386,7 @@ MPP_RET process_sei(H264_SLICE_t *currSlice) FunctionIn(currSlice->logctx->parr[RUN_PARSE]); memset(sei_msg, 0, sizeof(*sei_msg)); sei_msg->mvc_scalable_nesting_flag = 0; //init to false - + sei_msg->p_Dec = currSlice->p_Dec; do { sei_msg->type = 0; READ_BITS(p_bitctx, 8, &tmp_byte, "tmp_byte"); @@ -413,9 +405,7 @@ MPP_RET process_sei(H264_SLICE_t *currSlice) sei_msg->payload_size += tmp_byte; // this is the last byte //--- read sei info - FUN_CHECK(ret = parserSEI(p_bitctx, sei_msg, p_bitctx->data_)); - //--- analysis sei info - FUN_CHECK(ret = analysisSEI(currSlice)); + FUN_CHECK(ret = parserSEI(currSlice, p_bitctx, sei_msg, p_bitctx->data_)); //--- set offset to read next sei nal if (SEI_MVC_SCALABLE_NESTING == sei_msg->type) { sei_msg->payload_size = ((p_bitctx->used_bits + 0x07) >> 3); @@ -432,6 +422,5 @@ MPP_RET process_sei(H264_SLICE_t *currSlice) __BITREAD_ERR: ret = p_bitctx->ret; __FAILED: - ASSERT(0); return ret; } diff --git a/mpp/codec/dec/h264/h264d_sps.c b/mpp/codec/dec/h264/h264d_sps.c index 635ad971..3608b0ed 100644 --- a/mpp/codec/dec/h264/h264d_sps.c +++ b/mpp/codec/dec/h264/h264d_sps.c @@ -21,6 +21,8 @@ #include "mpp_mem.h" +#include "vpu_api.h" + #include "h264d_log.h" #include "h264d_sps.h" #include "h264d_scalist.h" @@ -179,7 +181,7 @@ static MPP_RET parser_sps(BitReadCtx_t *p_bitctx, H264_SPS_t *cur_sps, H264_DecC ASSERT(cur_sps->chroma_format_idc < 4); if (cur_sps->chroma_format_idc >= 3) { H264D_ERR("ERROR: Not support chroma_format_idc=%d.", cur_sps->chroma_format_idc); - p_Dec->error_flag = 1; + p_Dec->err_ctx.err_flag |= VPU_FRAME_ERR_UNSUPPORT; goto __FAILED; } //if (cur_sps->chroma_format_idc == 3) { diff --git a/mpp/codec/mpp_dec.cpp b/mpp/codec/mpp_dec.cpp index 90b80519..5ead737e 100644 --- a/mpp/codec/mpp_dec.cpp +++ b/mpp/codec/mpp_dec.cpp @@ -282,10 +282,11 @@ static MPP_RET try_proc_dec_task(Mpp *mpp, DecTask *task) } } - if (task_dec->flags.eos && task_dec->valid == 0) { + //if (task_dec->flags.eos && task_dec->valid == 0) + { RK_S32 index; - while (MPP_OK == mpp_buf_slot_dequeue(frame_slots, &index, QUEUE_DISPLAY)) { + MppFrame frame; RK_U32 discard; mpp_buf_slot_get_prop(frame_slots, index, SLOT_FRAME, &frame); @@ -650,31 +651,26 @@ void *mpp_dec_hal_thread(void *data) if (index >= 0) mpp_buf_slot_clr_flag(frame_slots, index, SLOT_HAL_INPUT); } - //mpp_log("--- task_dec->flags.eos=%d, out_frame=%d ---\n", task_dec->flags.eos, g_hal_out_frame); if (task_dec->flags.eos) { - //mpp_log("--- mpp_dec flush ---\n"); mpp_dec_flush(dec); } RK_S32 index; - while (MPP_OK == mpp_buf_slot_dequeue(frame_slots, &index, QUEUE_DISPLAY)) { - + while (MPP_OK == mpp_buf_slot_dequeue(frame_slots, &index, QUEUE_DISPLAY)) { MppFrame frame; RK_U32 discard; mpp_buf_slot_get_prop(frame_slots, index, SLOT_FRAME, &frame); discard = mpp_frame_get_discard(frame); if (!dec->reset_flag && !discard) { mpp_put_frame(mpp, frame); - //mpp_log("discard=%d \n",0); } else { mpp_frame_deinit(&frame); - //mpp_log("discard=%d \n",1); } mpp_buf_slot_clr_flag(frame_slots, index, SLOT_QUEUE_USE); } } } - //mpp_log("------- hal thread end ----------- \n"); + return NULL; } diff --git a/mpp/legacy/vpu_api_legacy.cpp b/mpp/legacy/vpu_api_legacy.cpp index 53ac1228..e279a1fe 100644 --- a/mpp/legacy/vpu_api_legacy.cpp +++ b/mpp/legacy/vpu_api_legacy.cpp @@ -134,9 +134,11 @@ RK_S32 VpuApi:: decode_getoutframe(DecoderOut_t *aDecOut) vframe->DisplayHeight = mpp_frame_get_height(mframe); vframe->FrameWidth = mpp_frame_get_hor_stride(mframe); vframe->FrameHeight = mpp_frame_get_ver_stride(mframe); + vframe->ErrorInfo = mpp_frame_get_errinfo(mframe); + //mpp_err("vframe->ErrorInfo = %08x \n", vframe->ErrorInfo); pts = mpp_frame_get_pts(mframe); aDecOut->timeUs = pts; - // mpp_err("get one frame timeUs %lld",aDecOut->timeUs); + //mpp_err("get one frame timeUs %lld, errinfo=%08x",aDecOut->timeUs, vframe->ErrorInfo); vframe->ShowTime.TimeHigh = (RK_U32)(pts >> 32); vframe->ShowTime.TimeLow = (RK_U32)pts; buf = mpp_frame_get_buffer(mframe); diff --git a/mpp/mpp_frame.cpp b/mpp/mpp_frame.cpp index 84c28aa4..6d2a595b 100644 --- a/mpp/mpp_frame.cpp +++ b/mpp/mpp_frame.cpp @@ -171,4 +171,4 @@ MPP_FRAME_ACCESSORS(MppFrameChromaLocation, chroma_location) MPP_FRAME_ACCESSORS(MppFrameFormat, fmt) MPP_FRAME_ACCESSORS(MppBuffer, buffer) MPP_FRAME_ACCESSORS(size_t, buf_size) - +MPP_FRAME_ACCESSORS(RK_U32, errinfo) diff --git a/mpp/mpp_frame_impl.h b/mpp/mpp_frame_impl.h index 52a5b51d..e44ffa4d 100644 --- a/mpp/mpp_frame_impl.h +++ b/mpp/mpp_frame_impl.h @@ -71,7 +71,7 @@ struct MppFrameImpl_t { */ RK_U32 eos; RK_U32 info_change; - + RK_U32 errinfo; MppFrameColorRange color_range; MppFrameColorPrimaries color_primaries; MppFrameColorTransferCharacteristic color_trc;