diff --git a/mpp/codec/dec/h264/h264d_api.c b/mpp/codec/dec/h264/h264d_api.c index 1f938ddd..6a85261c 100644 --- a/mpp/codec/dec/h264/h264d_api.c +++ b/mpp/codec/dec/h264/h264d_api.c @@ -653,10 +653,14 @@ MPP_RET h264d_prepare(void *decoder, MppPacket pkt, HalDecTask *task) p_Inp->in_dts = mpp_packet_get_dts(pkt); if (mpp_packet_get_eos(pkt)) { + if (p_Inp->in_length < 4) { + h264d_flush(decoder); + } p_Inp->in_buf = NULL; p_Inp->in_length = 0; p_Inp->pkt_eos = 1; p_Inp->has_get_eos = 1; + } else { p_Inp->in_buf = (RK_U8 *)mpp_packet_get_pos(pkt); p_Inp->in_length = mpp_packet_get_length(pkt); @@ -673,13 +677,12 @@ MPP_RET h264d_prepare(void *decoder, MppPacket pkt, HalDecTask *task) } H264D_DBG(H264D_DBG_INPUT, "[pkt_in_timeUs] is_avcC=%d, in_pts=%lld, pkt_eos=%d, len=%d, g_framecnt=%d \n", p_Inp->is_nalff, p_Inp->in_pts, p_Inp->pkt_eos, p_Inp->in_length, p_Dec->p_Vid->g_framecnt); - if (p_Inp->is_nalff) { (ret = parse_prepare_extra_data(p_Inp, p_Dec->p_Cur)); task->valid = p_Inp->task_valid; //!< prepare valid flag } else { do { - (ret = parse_prepare(p_Inp, p_Dec->p_Cur)); + (ret = parse_prepare_fast(p_Inp, p_Dec->p_Cur)); task->valid = p_Inp->task_valid; //!< prepare valid flag } while (mpp_packet_get_length(pkt) && !task->valid); } diff --git a/mpp/codec/dec/h264/h264d_parse.c b/mpp/codec/dec/h264/h264d_parse.c index 79327523..a4cd00f9 100644 --- a/mpp/codec/dec/h264/h264d_parse.c +++ b/mpp/codec/dec/h264/h264d_parse.c @@ -33,6 +33,7 @@ #include "h264d_sei.h" #include "h264d_init.h" #include "h264d_fill.h" +#include "h264d_log.h" #define HEAD_MAX_SIZE 12800 @@ -332,7 +333,6 @@ static MPP_RET store_cur_nalu(H264dCurStream_t *p_strm, H264dDxvaCtx_t *dxva_ctx RK_U32 add_size = 0; //!< fill head buffer - //mpp_log("store_cur_nalu function In \n"); if ( (p_strm->nalu_type == NALU_TYPE_SLICE) || (p_strm->nalu_type == NALU_TYPE_IDR) || (p_strm->nalu_type == NALU_TYPE_SPS) @@ -365,6 +365,8 @@ static MPP_RET store_cur_nalu(H264dCurStream_t *p_strm, H264dDxvaCtx_t *dxva_ctx memcpy(p_des + sizeof(g_start_precode), p_strm->nalu_buf, p_strm->nalu_len); dxva_ctx->strm_offset += p_strm->nalu_len + sizeof(g_start_precode); } + + return ret = MPP_OK; __FAILED: return ret; @@ -573,7 +575,6 @@ MPP_RET parse_prepare_fast(H264dInputCtx_t *p_Inp, H264dCurCtx_t *p_Cur) p_Dec->p_Inp->task_valid = 1; p_Dec->p_Inp->task_eos = 1; LogInfo(p_Inp->p_Dec->logctx.parr[RUN_PARSE], "----- end of stream ----"); - //mpp_log("----- eos: end of stream ----\n"); goto __RETURN; } //!< check input @@ -592,11 +593,6 @@ MPP_RET parse_prepare_fast(H264dInputCtx_t *p_Inp, H264dCurCtx_t *p_Cur) p_strm->nalu_buf[p_strm->nalu_len++] = *p_strm->curdata; if (p_strm->nalu_len == 1) { p_strm->nalu_type = p_strm->nalu_buf[0] & 0x1F; - //nalu_header_bytes += 1; - //if ((p_strm->nalu_type == NALU_TYPE_PREFIX) - // || (p_strm->nalu_type == NALU_TYPE_SLC_EXT)) { - // nalu_header_bytes += 3; - //} if (p_strm->nalu_type == NALU_TYPE_SLICE || p_strm->nalu_type == NALU_TYPE_IDR || p_strm->nalu_type == NALU_TYPE_SLC_EXT) { @@ -633,11 +629,14 @@ MPP_RET parse_prepare_fast(H264dInputCtx_t *p_Inp, H264dCurCtx_t *p_Cur) p_Inp->in_length = pkt_impl->length; //!< check input if (!p_Inp->in_length) { + if (!p_Cur->p_Inp->task_valid) { + p_Dec->nalu_ret = EndOfNalu; + FUN_CHECK(ret = store_cur_nalu(&p_Dec->p_Cur->strm, p_Dec->dxva_ctx)); + } else { + p_Dec->nalu_ret = HaveNoStream; + } p_strm->nalu_offset = 0; - p_Dec->nalu_ret = HaveNoStream; - p_strm->endcode_found = 1; - p_Dec->nalu_ret = EndOfNalu; reset_nalu(p_strm); p_strm->startcode_found = 0; diff --git a/mpp/common/h264d_log.h b/mpp/common/h264d_log.h index 0e8dd22b..cd539ae2 100644 --- a/mpp/common/h264d_log.h +++ b/mpp/common/h264d_log.h @@ -30,23 +30,23 @@ #define H264D_DBG_ASSERT (0x00000002) #define H264D_DBG_WARNNING (0x00000004) #define H264D_DBG_LOG (0x00000008) -#define H264D_DBG_ERR_DUMP (0x00000010) -//!< parse marco -#define H264D_DBG_INPUT (0x00000020) //!< input packet -#define H264D_DBG_PPS_SPS (0x00000040) -#define H264D_DBG_LOOP_STATE (0x00000080) -#define H264D_DBG_PARSE_NALU (0x00000100) -#define H264D_DBG_DPB_INFO (0x00000200) //!< size, -#define H264D_DBG_DPB_MALLIC (0x00000400) //!< malloc -#define H264D_DBG_DPB_FREE (0x00000800) //!< free +#define H264D_DBG_INPUT (0x00000010) //!< input packet +#define H264D_DBG_PPS_SPS (0x00000020) +#define H264D_DBG_LOOP_STATE (0x00000040) +#define H264D_DBG_PARSE_NALU (0x00000080) -#define H264D_DBG_DPB_DISPLAY (0x00001000) //!< display -#define H264D_DBG_DPB_REF_ERR (0x00002000) -#define H264D_DBG_SLOT_FLUSH (0x00004000) //!< dpb buffer slot remain -#define H264D_DBG_SEI (0x00008000) +#define H264D_DBG_DPB_INFO (0x00000100) //!< size, +#define H264D_DBG_DPB_MALLIC (0x00000200) //!< malloc +#define H264D_DBG_DPB_FREE (0x00000400) //!< free +#define H264D_DBG_DPB_DISPLAY (0x00000800) //!< display -#define H264D_DBG_CALLBACK (0x00010000) +#define H264D_DBG_DPB_REF_ERR (0x00001000) +#define H264D_DBG_SLOT_FLUSH (0x00002000) //!< dpb buffer slot remain +#define H264D_DBG_SEI (0x00004000) +#define H264D_DBG_CALLBACK (0x00008000) + +#define H264D_DBG_ERR_DUMP (0x00010000) //!< hal marco #define H264D_DBG_GEN_REGS (0x01000000) #define H264D_DBG_RET_REGS (0x02000000) @@ -247,6 +247,7 @@ typedef struct h264d_logctx_t { //!< function return check #define FUN_CHECK(val)\ do{ if((val) < 0) {\ + H264D_WARNNING("Function error(%d).\n", __LINE__); \ goto __FAILED;\ } } while (0) diff --git a/mpp/legacy/vpu_api_legacy.cpp b/mpp/legacy/vpu_api_legacy.cpp index e9198f0b..837449e5 100644 --- a/mpp/legacy/vpu_api_legacy.cpp +++ b/mpp/legacy/vpu_api_legacy.cpp @@ -159,8 +159,8 @@ RK_S32 VpuApi:: decode_getoutframe(DecoderOut_t *aDecOut) pts = mpp_frame_get_pts(mframe); aDecOut->timeUs = pts; if (vpu_api_debug & VPU_API_DBG_OUTPUT) { - mpp_log("get one frame timeUs %lld, poc=%d, errinfo=%d, discard=%d", aDecOut->timeUs, - mpp_frame_get_poc(mframe), mpp_frame_get_errinfo(mframe), mpp_frame_get_discard(mframe)); + mpp_log("get one frame timeUs %lld, poc=%d, errinfo=%d, discard=%d, eos=%d", aDecOut->timeUs, + mpp_frame_get_poc(mframe), mpp_frame_get_errinfo(mframe), mpp_frame_get_discard(mframe), mpp_frame_get_eos(mframe)); } vframe->ShowTime.TimeHigh = (RK_U32)(pts >> 32); vframe->ShowTime.TimeLow = (RK_U32)pts;