[h264d] 1.h264d_init picbuf => refpic; astyle format

git-svn-id: https://10.10.10.66:8443/svn/MediaProcessPlatform/trunk/mpp@591 6e48237b-75ef-9749-8fc9-41990f28c85a
This commit is contained in:
DingWei
2016-03-18 03:51:32 +00:00
parent a31b8ceebf
commit a9b5219f97
32 changed files with 933 additions and 958 deletions

View File

@@ -79,7 +79,7 @@ typedef enum {
MPP_DEC_SET_VC1_EXTRA_DATA, MPP_DEC_SET_VC1_EXTRA_DATA,
MPP_DEC_SET_VP6_ID, MPP_DEC_SET_VP6_ID,
MPP_DEC_USE_FAST_MODE, MPP_DEC_USE_FAST_MODE,
MPP_DEC_GET_STREAM_COUNT, MPP_DEC_GET_STREAM_COUNT,
MPP_ENC_CMD_BASE = 0x50000, MPP_ENC_CMD_BASE = 0x50000,
MPP_ENC_SETCFG, MPP_ENC_SETCFG,

View File

@@ -56,7 +56,7 @@ typedef enum VPU_API_CMD {
VPU_API_SET_DEFAULT_WIDTH_HEIGH, VPU_API_SET_DEFAULT_WIDTH_HEIGH,
VPU_API_SET_INFO_CHANGE, VPU_API_SET_INFO_CHANGE,
VPU_API_USE_FAST_MODE, VPU_API_USE_FAST_MODE,
VPU_API_DEC_GET_STREAM_COUNT, VPU_API_DEC_GET_STREAM_COUNT,
} VPU_API_CMD; } VPU_API_CMD;
typedef struct { typedef struct {

View File

@@ -153,7 +153,7 @@ static MPP_RET init_input_ctx(H264dInputCtx_t *p_Inp, ParserCfg *init)
FunctionIn(p_Inp->p_Dec->logctx.parr[RUN_PARSE]); FunctionIn(p_Inp->p_Dec->logctx.parr[RUN_PARSE]);
p_Inp->init = *init; p_Inp->init = *init;
mpp_env_get_u32("rkv_h264d_mvc_disable", &p_Inp->mvc_disable, 1); mpp_env_get_u32("rkv_h264d_mvc_disable", &p_Inp->mvc_disable, 1);
FunctionOut(p_Inp->p_Dec->logctx.parr[RUN_PARSE]); FunctionOut(p_Inp->p_Dec->logctx.parr[RUN_PARSE]);
__RETURN: __RETURN:
return ret = MPP_OK; return ret = MPP_OK;
@@ -168,7 +168,7 @@ static MPP_RET free_cur_ctx(H264dCurCtx_t *p_Cur)
INP_CHECK(ret, !p_Cur); INP_CHECK(ret, !p_Cur);
FunctionIn(p_Cur->p_Dec->logctx.parr[RUN_PARSE]); FunctionIn(p_Cur->p_Dec->logctx.parr[RUN_PARSE]);
if (p_Cur) { if (p_Cur) {
free_ref_pic_list_reordering_buffer(&p_Cur->slice); free_ref_pic_list_reordering_buffer(&p_Cur->slice);
recycle_slice(&p_Cur->slice); recycle_slice(&p_Cur->slice);
for (i = 0; i < MAX_NUM_DPB_LAYERS; i++) { for (i = 0; i < MAX_NUM_DPB_LAYERS; i++) {
MPP_FREE(p_Cur->listP[i]); MPP_FREE(p_Cur->listP[i]);
@@ -276,7 +276,7 @@ static MPP_RET init_vid_ctx(H264dVideoCtx_t *p_Vid)
p_Vid->subspsSet[i].num_level_values_signalled_minus1 = -1; p_Vid->subspsSet[i].num_level_values_signalled_minus1 = -1;
} }
p_Vid->iframe_cnt = 0; p_Vid->iframe_cnt = 0;
//!< memset error context //!< memset error context
FunctionOut(p_Vid->p_Dec->logctx.parr[RUN_PARSE]); FunctionOut(p_Vid->p_Dec->logctx.parr[RUN_PARSE]);
__RETURN: __RETURN:
@@ -368,7 +368,7 @@ static MPP_RET init_dec_ctx(H264_DecCtx_t *p_Dec)
p_Dec->dpb_mark[i].bot_used = 0; p_Dec->dpb_mark[i].bot_used = 0;
p_Dec->dpb_mark[i].mark_idx = i; p_Dec->dpb_mark[i].mark_idx = i;
p_Dec->dpb_mark[i].slot_idx = -1; p_Dec->dpb_mark[i].slot_idx = -1;
p_Dec->dpb_mark[i].pic = NULL; p_Dec->dpb_mark[i].pic = NULL;
} }
mpp_buf_slot_setup(p_Dec->frame_slots, MAX_MARK_SIZE); mpp_buf_slot_setup(p_Dec->frame_slots, MAX_MARK_SIZE);
//!< malloc mpp packet //!< malloc mpp packet
@@ -380,7 +380,7 @@ static MPP_RET init_dec_ctx(H264_DecCtx_t *p_Dec)
p_Dec->nalu_ret = NALU_NULL; p_Dec->nalu_ret = NALU_NULL;
p_Dec->is_first_frame = 1; p_Dec->is_first_frame = 1;
p_Dec->last_frame_slot_idx = -1; p_Dec->last_frame_slot_idx = -1;
memset(&p_Dec->errctx, 0, sizeof(H264dErrCtx_t)); memset(&p_Dec->errctx, 0, sizeof(H264dErrCtx_t));
__RETURN: __RETURN:
return ret = MPP_OK; return ret = MPP_OK;
@@ -392,25 +392,25 @@ __FAILED:
static void flush_dpb_buf_slot(H264_DecCtx_t *p_Dec) static void flush_dpb_buf_slot(H264_DecCtx_t *p_Dec)
{ {
RK_U32 i = 0; RK_U32 i = 0;
H264_DpbMark_t *p_mark = NULL; H264_DpbMark_t *p_mark = NULL;
for(i = 0; i < MAX_MARK_SIZE; i++) { for (i = 0; i < MAX_MARK_SIZE; i++) {
p_mark = &p_Dec->dpb_mark[i]; p_mark = &p_Dec->dpb_mark[i];
if (p_mark->out_flag && (p_mark->slot_idx >= 0)) { if (p_mark->out_flag && (p_mark->slot_idx >= 0)) {
MppFrame mframe = NULL; MppFrame mframe = NULL;
mpp_buf_slot_get_prop(p_Dec->frame_slots, p_mark->slot_idx, SLOT_FRAME_PTR, &mframe); mpp_buf_slot_get_prop(p_Dec->frame_slots, p_mark->slot_idx, SLOT_FRAME_PTR, &mframe);
if (mframe) { if (mframe) {
H264D_DBG(H264D_DBG_SLOT_FLUSH, "[DPB_BUF_FLUSH] p_mark->slot_idx=%d", p_mark->slot_idx); H264D_DBG(H264D_DBG_SLOT_FLUSH, "[DPB_BUF_FLUSH] p_mark->slot_idx=%d", p_mark->slot_idx);
mpp_buf_slot_set_flag(p_Dec->frame_slots, p_mark->slot_idx, SLOT_QUEUE_USE); mpp_buf_slot_set_flag(p_Dec->frame_slots, p_mark->slot_idx, SLOT_QUEUE_USE);
mpp_buf_slot_enqueue(p_Dec->frame_slots, p_mark->slot_idx, QUEUE_DISPLAY); mpp_buf_slot_enqueue(p_Dec->frame_slots, p_mark->slot_idx, QUEUE_DISPLAY);
mpp_buf_slot_clr_flag(p_Dec->frame_slots, p_mark->slot_idx, SLOT_CODEC_USE); mpp_buf_slot_clr_flag(p_Dec->frame_slots, p_mark->slot_idx, SLOT_CODEC_USE);
// mpp_frame_set_errinfo(mframe, VPU_FRAME_ERR_UNKNOW); // mpp_frame_set_errinfo(mframe, VPU_FRAME_ERR_UNKNOW);
// p_Dec->last_frame_slot_idx = p_mark->slot_idx; // p_Dec->last_frame_slot_idx = p_mark->slot_idx;
} }
} }
p_mark->out_flag = 0; p_mark->out_flag = 0;
} }
} }
@@ -430,7 +430,7 @@ MPP_RET h264d_init(void *decoder, ParserCfg *init)
memset(p_Dec, 0, sizeof(H264_DecCtx_t)); memset(p_Dec, 0, sizeof(H264_DecCtx_t));
// init logctx // init logctx
FUN_CHECK(ret = logctx_init(&p_Dec->logctx, p_Dec->logctxbuf)); FUN_CHECK(ret = logctx_init(&p_Dec->logctx, p_Dec->logctxbuf));
mpp_env_get_u32("rkv_h264d_debug", &rkv_h264d_parse_debug, H264D_DBG_ERROR); mpp_env_get_u32("rkv_h264d_debug", &rkv_h264d_parse_debug, H264D_DBG_ERROR);
FunctionIn(p_Dec->logctx.parr[RUN_PARSE]); FunctionIn(p_Dec->logctx.parr[RUN_PARSE]);
//!< get init frame_slots and packet_slots //!< get init frame_slots and packet_slots
p_Dec->frame_slots = init->frame_slots; p_Dec->frame_slots = init->frame_slots;
@@ -506,15 +506,15 @@ MPP_RET h264d_reset(void *decoder)
INP_CHECK(ret, !decoder); INP_CHECK(ret, !decoder);
FunctionIn(p_Dec->logctx.parr[RUN_PARSE]); FunctionIn(p_Dec->logctx.parr[RUN_PARSE]);
FUN_CHECK(ret = flush_dpb(p_Dec->p_Vid->p_Dpb_layer[0], 1)); FUN_CHECK(ret = flush_dpb(p_Dec->p_Vid->p_Dpb_layer[0], 1));
FUN_CHECK(ret = init_dpb(p_Dec->p_Vid, p_Dec->p_Vid->p_Dpb_layer[0], 1)); FUN_CHECK(ret = init_dpb(p_Dec->p_Vid, p_Dec->p_Vid->p_Dpb_layer[0], 1));
if (p_Dec->mvc_valid) if (p_Dec->mvc_valid) {
{ // layer_id == 1 // layer_id == 1
FUN_CHECK(ret = flush_dpb(p_Dec->p_Vid->p_Dpb_layer[1], 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)); 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_muti_view_output(p_Dec->frame_slots, p_Dec->p_Vid->outlist, p_Dec->p_Vid);
} }
flush_dpb_buf_slot(p_Dec); flush_dpb_buf_slot(p_Dec);
//!< reset input parameter //!< reset input parameter
p_Dec->p_Inp->in_buf = NULL; p_Dec->p_Inp->in_buf = NULL;
p_Dec->p_Inp->pkt_eos = 0; p_Dec->p_Inp->pkt_eos = 0;
@@ -529,7 +529,7 @@ MPP_RET h264d_reset(void *decoder)
p_Dec->p_Vid->last_outputpoc[0] = -1; p_Dec->p_Vid->last_outputpoc[0] = -1;
p_Dec->p_Vid->last_outputpoc[1] = -1; p_Dec->p_Vid->last_outputpoc[1] = -1;
p_Dec->p_Vid->iframe_cnt = 0; 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 //!< reset current time stamp
p_Dec->p_Cur->last_dts = 0; p_Dec->p_Cur->last_dts = 0;
@@ -563,7 +563,7 @@ MPP_RET h264d_reset(void *decoder)
memset(p_Dec->dpb_old[1], 0, MAX_DPB_SIZE * sizeof(H264_DpbInfo_t)); memset(p_Dec->dpb_old[1], 0, MAX_DPB_SIZE * sizeof(H264_DpbInfo_t));
//!< reset dpb //!< reset dpb
// layer_id == 1 // layer_id == 1
for (i = 0; i < MAX_MARK_SIZE; i++) { for (i = 0; i < MAX_MARK_SIZE; i++) {
p_Dec->dpb_mark[i].top_used = 0; p_Dec->dpb_mark[i].top_used = 0;
p_Dec->dpb_mark[i].bot_used = 0; p_Dec->dpb_mark[i].bot_used = 0;
@@ -586,19 +586,19 @@ __FAILED:
*/ */
MPP_RET h264d_flush(void *decoder) MPP_RET h264d_flush(void *decoder)
{ {
MPP_RET ret = MPP_ERR_UNKNOW; MPP_RET ret = MPP_ERR_UNKNOW;
H264_DecCtx_t *p_Dec = (H264_DecCtx_t *)decoder; H264_DecCtx_t *p_Dec = (H264_DecCtx_t *)decoder;
INP_CHECK(ret, !decoder); INP_CHECK(ret, !decoder);
FunctionIn(p_Dec->logctx.parr[RUN_PARSE]); FunctionIn(p_Dec->logctx.parr[RUN_PARSE]);
if (p_Dec->last_frame_slot_idx < 0) { if (p_Dec->last_frame_slot_idx < 0) {
IOInterruptCB *cb = &p_Dec->p_Inp->init.notify_cb; IOInterruptCB *cb = &p_Dec->p_Inp->init.notify_cb;
if (cb->callBack) { if (cb->callBack) {
cb->callBack(cb->opaque, NULL); cb->callBack(cb->opaque, NULL);
} }
goto __RETURN; goto __RETURN;
} }
FUN_CHECK(ret = flush_dpb(p_Dec->p_Vid->p_Dpb_layer[0], 1)); FUN_CHECK(ret = flush_dpb(p_Dec->p_Vid->p_Dpb_layer[0], 1));
FUN_CHECK(ret = init_dpb(p_Dec->p_Vid, p_Dec->p_Vid->p_Dpb_layer[0], 1)); FUN_CHECK(ret = init_dpb(p_Dec->p_Vid, p_Dec->p_Vid->p_Dpb_layer[0], 1));
//free_dpb(p_Dec->p_Vid->p_Dpb_layer[0]); //free_dpb(p_Dec->p_Vid->p_Dpb_layer[0]);
@@ -608,12 +608,12 @@ MPP_RET h264d_flush(void *decoder)
FUN_CHECK(ret = init_dpb(p_Dec->p_Vid, 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]); //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_muti_view_output(p_Dec->frame_slots, p_Dec->p_Vid->outlist, p_Dec->p_Vid);
} }
flush_dpb_buf_slot(p_Dec); flush_dpb_buf_slot(p_Dec);
p_Dec->p_Inp->task_eos = 1; p_Dec->p_Inp->task_eos = 1;
mpp_buf_slot_set_prop(p_Dec->frame_slots, p_Dec->last_frame_slot_idx, SLOT_EOS, &p_Dec->p_Inp->task_eos); mpp_buf_slot_set_prop(p_Dec->frame_slots, p_Dec->last_frame_slot_idx, SLOT_EOS, &p_Dec->p_Inp->task_eos);
__RETURN: __RETURN:
H264D_DBG(H264D_DBG_DPB_DISPLAY, "[DPB display] flush end, task_eos=%d, last_slot_idx=%d", p_Dec->p_Inp->task_eos, p_Dec->last_frame_slot_idx); H264D_DBG(H264D_DBG_DPB_DISPLAY, "[DPB display] flush end, task_eos=%d, last_slot_idx=%d", p_Dec->p_Inp->task_eos, p_Dec->last_frame_slot_idx);
FunctionOut(p_Dec->logctx.parr[RUN_PARSE]); FunctionOut(p_Dec->logctx.parr[RUN_PARSE]);
return ret = MPP_OK; return ret = MPP_OK;
__FAILED: __FAILED:
@@ -651,13 +651,13 @@ __RETURN:
MPP_RET h264d_prepare(void *decoder, MppPacket pkt, HalDecTask *task) MPP_RET h264d_prepare(void *decoder, MppPacket pkt, HalDecTask *task)
{ {
MPP_RET ret = MPP_ERR_UNKNOW; MPP_RET ret = MPP_ERR_UNKNOW;
H264dInputCtx_t *p_Inp = NULL; H264dInputCtx_t *p_Inp = NULL;
H264_DecCtx_t *p_Dec = (H264_DecCtx_t *)decoder; H264_DecCtx_t *p_Dec = (H264_DecCtx_t *)decoder;
INP_CHECK(ret, !decoder && !pkt && !task); INP_CHECK(ret, !decoder && !pkt && !task);
FunctionIn(p_Dec->logctx.parr[RUN_PARSE]); FunctionIn(p_Dec->logctx.parr[RUN_PARSE]);
p_Inp = p_Dec->p_Inp; p_Inp = p_Dec->p_Inp;
if (p_Inp->has_get_eos) { if (p_Inp->has_get_eos) {
((MppPacketImpl *)pkt)->length = 0; ((MppPacketImpl *)pkt)->length = 0;
goto __RETURN; goto __RETURN;
@@ -676,7 +676,7 @@ MPP_RET h264d_prepare(void *decoder, MppPacket pkt, HalDecTask *task)
p_Inp->in_length = mpp_packet_get_length(pkt); p_Inp->in_length = mpp_packet_get_length(pkt);
p_Inp->pkt_eos = 0; p_Inp->pkt_eos = 0;
} }
//!< avcC stream //!< avcC stream
if (mpp_packet_get_flag(pkt)& MPP_PACKET_FLAG_EXTRA_DATA) { if (mpp_packet_get_flag(pkt)& MPP_PACKET_FLAG_EXTRA_DATA) {
RK_U8 *pdata = p_Inp->in_buf; RK_U8 *pdata = p_Inp->in_buf;
p_Inp->is_nalff = (p_Inp->in_length > 3) && (pdata[0] && pdata[1]); p_Inp->is_nalff = (p_Inp->in_length > 3) && (pdata[0] && pdata[1]);
@@ -685,7 +685,7 @@ MPP_RET h264d_prepare(void *decoder, MppPacket pkt, HalDecTask *task)
goto __RETURN; goto __RETURN;
} }
} }
H264D_DBG(H264D_DBG_INPUT, "[pkt_in timeUs] is_avcC=%d, in_pts=%lld, pkt_eos=%d, len=%d, g_framecnt=%d \n", 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); 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) { if (p_Inp->is_nalff) {
@@ -723,9 +723,9 @@ __RETURN:
*/ */
MPP_RET h264d_parse(void *decoder, HalDecTask *in_task) MPP_RET h264d_parse(void *decoder, HalDecTask *in_task)
{ {
MPP_RET ret = MPP_ERR_UNKNOW; MPP_RET ret = MPP_ERR_UNKNOW;
H264_DecCtx_t *p_Dec = (H264_DecCtx_t *)decoder; H264_DecCtx_t *p_Dec = (H264_DecCtx_t *)decoder;
INP_CHECK(ret, !decoder && !in_task); INP_CHECK(ret, !decoder && !in_task);
FunctionIn(p_Dec->logctx.parr[RUN_PARSE]); FunctionIn(p_Dec->logctx.parr[RUN_PARSE]);
@@ -733,48 +733,47 @@ MPP_RET h264d_parse(void *decoder, HalDecTask *in_task)
in_task->valid = 0; // prepare end flag in_task->valid = 0; // prepare end flag
p_Dec->in_task = in_task; p_Dec->in_task = in_task;
p_Dec->errctx.parse_err_flag = 0; p_Dec->errctx.parse_err_flag = 0;
p_Dec->errctx.dpb_err_flag = 0; p_Dec->errctx.dpb_err_flag = 0;
p_Dec->errctx.used_for_ref_flag = 0; p_Dec->errctx.used_for_ref_flag = 0;
FUN_CHECK(ret = parse_loop(p_Dec)); FUN_CHECK(ret = parse_loop(p_Dec));
if (p_Dec->is_parser_end) { if (p_Dec->is_parser_end) {
p_Dec->is_parser_end = 0; p_Dec->is_parser_end = 0;
p_Dec->p_Vid->g_framecnt++; p_Dec->p_Vid->g_framecnt++;
ret = update_dpb(p_Dec); ret = update_dpb(p_Dec);
if (in_task->flags.eos) { if (in_task->flags.eos) {
h264d_flush(decoder); h264d_flush(decoder);
goto __RETURN; goto __RETURN;
} }
if (ret) { if (ret) {
goto __FAILED; goto __FAILED;
} }
in_task->valid = 1; // register valid flag in_task->valid = 1; // register valid flag
in_task->syntax.number = p_Dec->dxva_ctx->syn.num; in_task->syntax.number = p_Dec->dxva_ctx->syn.num;
in_task->syntax.data = (void *)p_Dec->dxva_ctx->syn.buf; in_task->syntax.data = (void *)p_Dec->dxva_ctx->syn.buf;
in_task->dpb_err_flag = p_Dec->errctx.dpb_err_flag; 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->used_for_ref_flag = p_Dec->errctx.used_for_ref_flag;
} }
__RETURN: __RETURN:
FunctionOut(p_Dec->logctx.parr[RUN_PARSE]); FunctionOut(p_Dec->logctx.parr[RUN_PARSE]);
return ret = MPP_OK; return ret = MPP_OK;
__FAILED: __FAILED: {
{ H264_StorePic_t *dec_pic = p_Dec->p_Vid->dec_pic;
H264_StorePic_t *dec_pic = p_Dec->p_Vid->dec_pic; if (dec_pic && dec_pic->mem_mark->out_flag) {
if (dec_pic && dec_pic->mem_mark->out_flag) { MppFrame mframe = NULL;
MppFrame mframe = NULL; mpp_buf_slot_get_prop(p_Dec->frame_slots, dec_pic->mem_mark->slot_idx, SLOT_FRAME_PTR, &mframe);
mpp_buf_slot_get_prop(p_Dec->frame_slots, dec_pic->mem_mark->slot_idx, SLOT_FRAME_PTR, &mframe); mpp_buf_slot_set_flag(p_Dec->frame_slots, dec_pic->mem_mark->slot_idx, SLOT_QUEUE_USE);
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);
mpp_buf_slot_enqueue (p_Dec->frame_slots, dec_pic->mem_mark->slot_idx, QUEUE_DISPLAY); mpp_buf_slot_clr_flag(p_Dec->frame_slots, dec_pic->mem_mark->slot_idx, SLOT_CODEC_USE);
mpp_buf_slot_clr_flag(p_Dec->frame_slots, dec_pic->mem_mark->slot_idx, SLOT_CODEC_USE); dec_pic->mem_mark->out_flag = 0;
dec_pic->mem_mark->out_flag = 0; p_Dec->p_Vid->dec_pic = NULL;
p_Dec->p_Vid->dec_pic = NULL; mpp_frame_set_discard(mframe, 1);
mpp_frame_set_discard(mframe, 1); }
} }
}
return ret; return ret;
} }
/*! /*!
@@ -785,35 +784,34 @@ __FAILED:
*/ */
MPP_RET h264d_callback(void *decoder, void *errinfo) MPP_RET h264d_callback(void *decoder, void *errinfo)
{ {
MPP_RET ret = MPP_ERR_UNKNOW; MPP_RET ret = MPP_ERR_UNKNOW;
MppFrame mframe = NULL; MppFrame mframe = NULL;
RK_U32 *p_regs = NULL; RK_U32 *p_regs = NULL;
RK_U32 out_slot_idx = 0; RK_U32 out_slot_idx = 0;
RK_U32 dpb_err_flag = 0; RK_U32 dpb_err_flag = 0;
RK_U32 used_for_ref_flag = 0; RK_U32 used_for_ref_flag = 0;
H264_DecCtx_t *p_Dec = (H264_DecCtx_t *)decoder; H264_DecCtx_t *p_Dec = (H264_DecCtx_t *)decoder;
INP_CHECK(ret, !decoder); INP_CHECK(ret, !decoder);
FunctionIn(p_Dec->logctx.parr[RUN_PARSE]); FunctionIn(p_Dec->logctx.parr[RUN_PARSE]);
p_regs = (RK_U32*)errinfo; p_regs = (RK_U32*)errinfo;
out_slot_idx = p_regs[78]; out_slot_idx = p_regs[78];
dpb_err_flag = p_regs[79]; dpb_err_flag = p_regs[79];
used_for_ref_flag = p_regs[80]; used_for_ref_flag = p_regs[80];
mpp_buf_slot_get_prop(p_Dec->frame_slots, out_slot_idx, SLOT_FRAME_PTR, &mframe); mpp_buf_slot_get_prop(p_Dec->frame_slots, out_slot_idx, SLOT_FRAME_PTR, &mframe);
if (used_for_ref_flag) { if (used_for_ref_flag) {
mpp_frame_set_errinfo(mframe, VPU_FRAME_ERR_UNKNOW); mpp_frame_set_errinfo(mframe, VPU_FRAME_ERR_UNKNOW);
} } else {
else { mpp_frame_set_discard(mframe, VPU_FRAME_ERR_UNKNOW);
mpp_frame_set_discard(mframe, VPU_FRAME_ERR_UNKNOW); }
} H264D_DBG(H264D_DBG_CALLBACK, "g_frame_no=%d, out_slot_idx=%d, swreg[01]=%08x, swreg[45]=%08x, dpb_err=%d, used_for_ref=%d",
H264D_DBG(H264D_DBG_CALLBACK, "g_frame_no=%d, out_slot_idx=%d, swreg[01]=%08x, swreg[45]=%08x, dpb_err=%d, used_for_ref=%d", p_Dec->p_Vid->g_framecnt, out_slot_idx, p_regs[1], p_regs[45], dpb_err_flag, used_for_ref_flag);
p_Dec->p_Vid->g_framecnt, out_slot_idx, p_regs[1], p_regs[45], dpb_err_flag, used_for_ref_flag);
__RETURN: __RETURN:
FunctionOut(p_Dec->logctx.parr[RUN_PARSE]); FunctionOut(p_Dec->logctx.parr[RUN_PARSE]);
return ret = MPP_OK; return ret = MPP_OK;
} }
/*! /*!
*********************************************************************** ***********************************************************************

View File

@@ -110,8 +110,8 @@ static RK_S32 getDpbSize(H264dVideoCtx_t *p_Vid, H264_SPS_t *active_sps)
size = 70778880; size = 70778880;
break; break;
default: default:
H264D_ERR("dpb_size error."); H264D_ERR("dpb_size error.");
return size = 0; return size = 0;
break; break;
} }
size /= pic_size; size /= pic_size;
@@ -124,13 +124,13 @@ static RK_S32 getDpbSize(H264dVideoCtx_t *p_Vid, H264_SPS_t *active_sps)
} }
if (active_sps->vui_parameters_present_flag && active_sps->vui_seq_parameters.bitstream_restriction_flag) { if (active_sps->vui_parameters_present_flag && active_sps->vui_seq_parameters.bitstream_restriction_flag) {
RK_S32 size_vui = 0; RK_S32 size_vui = 0;
if ((RK_S32)active_sps->vui_seq_parameters.max_dec_frame_buffering > size) { if ((RK_S32)active_sps->vui_seq_parameters.max_dec_frame_buffering > size) {
H264D_WARNNING("warnnig: max_dec_frame_buffering larger than MaxDpbSize"); H264D_WARNNING("warnnig: max_dec_frame_buffering larger than MaxDpbSize");
} }
size_vui = MPP_MAX(1, active_sps->vui_seq_parameters.max_dec_frame_buffering); size_vui = MPP_MAX(1, active_sps->vui_seq_parameters.max_dec_frame_buffering);
if (size_vui < size) { if (size_vui < size) {
H264D_WARNNING("warning: max_dec_frame_buffering(%d) is less than dpb_size(%d) calculated from Profile/Level.\n", size_vui, size); H264D_WARNNING("warning: max_dec_frame_buffering(%d) is less than dpb_size(%d) calculated from Profile/Level.\n", size_vui, size);
} }
size = size_vui; size = size_vui;
} }
@@ -151,7 +151,7 @@ static RK_S32 get_pic_num_x(H264_StorePic_t *p, RK_S32 difference_of_pic_nums_mi
static void unmark_for_reference(H264_DecCtx_t *p_Dec, H264_FrameStore_t* fs) static void unmark_for_reference(H264_DecCtx_t *p_Dec, H264_FrameStore_t* fs)
{ {
H264_StorePic_t *cur_pic = NULL; H264_StorePic_t *cur_pic = NULL;
if (fs->is_used & 1) { if (fs->is_used & 1) {
if (fs->top_field) { if (fs->top_field) {
fs->top_field->used_for_reference = 0; fs->top_field->used_for_reference = 0;
@@ -173,7 +173,7 @@ static void unmark_for_reference(H264_DecCtx_t *p_Dec, H264_FrameStore_t* fs)
cur_pic = fs->frame; cur_pic = fs->frame;
} }
fs->is_reference = 0; fs->is_reference = 0;
(void)cur_pic; (void)cur_pic;
(void)p_Dec; (void)p_Dec;
} }
@@ -627,31 +627,29 @@ static RK_U32 is_used_for_reference(H264_FrameStore_t* fs)
static void free_dpb_mark(H264_DecCtx_t *p_Dec, H264_DpbMark_t *p, RK_S32 structure) static void free_dpb_mark(H264_DecCtx_t *p_Dec, H264_DpbMark_t *p, RK_S32 structure)
{ {
if (structure == FRAME) { if (structure == FRAME) {
p->top_used = (p->top_used > 0) ? (p->top_used - 1) : 0; p->top_used = (p->top_used > 0) ? (p->top_used - 1) : 0;
p->bot_used = (p->bot_used > 0) ? (p->bot_used - 1) : 0; p->bot_used = (p->bot_used > 0) ? (p->bot_used - 1) : 0;
} } else if (structure == TOP_FIELD) {
else if (structure == TOP_FIELD) { p->top_used = (p->top_used > 0) ? (p->top_used - 1) : 0;
p->top_used = (p->top_used > 0) ? (p->top_used - 1) : 0; } else if (structure == BOTTOM_FIELD) {
} p->bot_used = (p->bot_used > 0) ? (p->bot_used - 1) : 0;
else if (structure == BOTTOM_FIELD) { }
p->bot_used = (p->bot_used > 0) ? (p->bot_used - 1) : 0; if (p->top_used == 0 && p->bot_used == 0
} && p->out_flag == 0 && (p->slot_idx >= 0)) {
if (p->top_used == 0 && p->bot_used == 0 mpp_buf_slot_clr_flag(p_Dec->frame_slots, p->slot_idx, SLOT_CODEC_USE);
&& p->out_flag == 0 && (p->slot_idx >= 0)) { {
mpp_buf_slot_clr_flag(p_Dec->frame_slots, p->slot_idx, SLOT_CODEC_USE); MppFrame frame = NULL;
{ MppBuffer mbuffer = NULL;
MppFrame frame = NULL; mpp_buf_slot_get_prop(p_Dec->frame_slots, p->slot_idx, SLOT_FRAME_PTR, &frame);
MppBuffer mbuffer = NULL; RK_U64 pts = frame ? mpp_frame_get_pts(frame) : 0;
mpp_buf_slot_get_prop(p_Dec->frame_slots, p->slot_idx, SLOT_FRAME_PTR, &frame); RK_U32 poc = frame ? mpp_frame_get_poc(frame) : 0;
RK_U64 pts = frame ? mpp_frame_get_pts(frame) : 0; mpp_buf_slot_get_prop(p_Dec->frame_slots, p->slot_idx, SLOT_BUFFER, &mbuffer);
RK_U32 poc = frame ? mpp_frame_get_poc(frame) : 0; H264D_DBG(H264D_DBG_DPB_FREE, "[DPB free] g_frame_no=%d, structure=%d, mark_idx=%d, slot_idx=%d(%p), poc=%d, pts=%lld, %p \n",
mpp_buf_slot_get_prop(p_Dec->frame_slots, p->slot_idx, SLOT_BUFFER, &mbuffer); p_Dec->p_Vid->g_framecnt, structure, p->mark_idx, p->slot_idx, mbuffer, poc, pts, frame);
H264D_DBG(H264D_DBG_DPB_FREE, "[DPB free] g_frame_no=%d, structure=%d, mark_idx=%d, slot_idx=%d(%p), poc=%d, pts=%lld, %p \n", }
p_Dec->p_Vid->g_framecnt, structure, p->mark_idx, p->slot_idx, mbuffer, poc, pts, frame); p->slot_idx = -1;
} }
p->slot_idx = -1;
}
} }
static MPP_RET remove_frame_from_dpb(H264_DpbBuf_t *p_Dpb, RK_S32 pos) static MPP_RET remove_frame_from_dpb(H264_DpbBuf_t *p_Dpb, RK_S32 pos)
@@ -921,36 +919,35 @@ static void write_picture(H264_StorePic_t *p, H264dVideoCtx_t *p_Vid)
// mpp_frame_set_discard(frame, 1); // mpp_frame_set_discard(frame, 1);
//} //}
p_Vid->iframe_cnt += (p->slice_type == I_SLICE) ? 1 : 0; p_Vid->iframe_cnt += (p->slice_type == I_SLICE) ? 1 : 0;
if (!p_Vid->iframe_cnt) { if (!p_Vid->iframe_cnt) {
//mpp_frame_set_errinfo(mframe, VPU_FRAME_ERR_UNKNOW); //mpp_frame_set_errinfo(mframe, VPU_FRAME_ERR_UNKNOW);
} else { } else {
//if (1 == p_Vid->iframe_cnt) { //if (1 == p_Vid->iframe_cnt) {
// p_Vid->first_iframe_poc = p->poc; // p_Vid->first_iframe_poc = p->poc;
//} //}
//if (p->poc < p_Vid->first_iframe_poc) { //if (p->poc < p_Vid->first_iframe_poc) {
// mpp_frame_set_errinfo(mframe, VPU_FRAME_ERR_UNKNOW); // mpp_frame_set_errinfo(mframe, VPU_FRAME_ERR_UNKNOW);
//} //}
//if (p->poc < p_Vid->last_outputpoc[p->layer_id]) { //if (p->poc < p_Vid->last_outputpoc[p->layer_id]) {
// mpp_frame_set_discard(mframe, VPU_FRAME_ERR_UNKNOW); // mpp_frame_set_discard(mframe, VPU_FRAME_ERR_UNKNOW);
//} //}
//p_Vid->last_outputpoc[p->layer_id] = p->poc; //p_Vid->last_outputpoc[p->layer_id] = p->poc;
} }
mpp_buf_slot_set_flag(p_Vid->p_Dec->frame_slots, p_mark->slot_idx, SLOT_QUEUE_USE); 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) { 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 } else {
{ mpp_buf_slot_enqueue(p_Vid->p_Dec->frame_slots, p_mark->slot_idx, QUEUE_DISPLAY);
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_Vid->p_Dec->last_frame_slot_idx = p_mark->slot_idx; p_mark->out_flag = 0;
p_mark->out_flag = 0; }
} {
{ MppBuffer mbuffer = NULL;
MppBuffer mbuffer = NULL; mpp_buf_slot_get_prop(p_Vid->p_Dec->frame_slots, p_mark->slot_idx, SLOT_BUFFER, &mbuffer);
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",
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);
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); }
}
} }
} }
@@ -1092,10 +1089,10 @@ static MPP_RET adaptive_memory_management(H264_DpbBuf_t *p_Dpb, H264_StorePic_t
p_Vid->last_has_mmco_5 = 1; p_Vid->last_has_mmco_5 = 1;
break; break;
case 6: case 6:
//!< conceal max_long_term_frame_idx_plus1 //!< conceal max_long_term_frame_idx_plus1
if (!tmp_drpm->max_long_term_frame_idx_plus1) { if (!tmp_drpm->max_long_term_frame_idx_plus1) {
tmp_drpm->max_long_term_frame_idx_plus1 = p_Dpb->num_ref_frames; tmp_drpm->max_long_term_frame_idx_plus1 = p_Dpb->num_ref_frames;
} }
mm_mark_current_picture_long_term(p_Dpb, p, tmp_drpm->long_term_frame_idx); mm_mark_current_picture_long_term(p_Dpb, p, tmp_drpm->long_term_frame_idx);
check_num_ref(p_Dpb); check_num_ref(p_Dpb);
break; break;
@@ -1316,31 +1313,31 @@ MPP_RET store_picture_in_dpb(H264_DpbBuf_t *p_Dpb, H264_StorePic_t *p)
p->is_long_term = 0; p->is_long_term = 0;
} }
//!< when is full, first try to remove unused frames //!< when is full, first try to remove unused frames
//if (p_Dpb->used_size == p_Dpb->size) //if (p_Dpb->used_size == p_Dpb->size)
{ {
remove_unused_frame_from_dpb(p_Dpb); remove_unused_frame_from_dpb(p_Dpb);
} }
//!< then output frames until one can be removed //!< then output frames until one can be removed
while ((p_Dpb->used_size == p_Dpb->size) while ((p_Dpb->used_size == p_Dpb->size)
//|| (p_Dpb->used_size >= p_Vid->active_sps->vui_seq_parameters.num_reorder_frames) //|| (p_Dpb->used_size >= p_Vid->active_sps->vui_seq_parameters.num_reorder_frames)
) { ) {
{ {
//!< non-reference frames may be output directly //!< non-reference frames may be output directly
FUN_CHECK(ret = get_smallest_poc(p_Dpb, &min_poc, &min_pos)); FUN_CHECK(ret = get_smallest_poc(p_Dpb, &min_poc, &min_pos));
//!< current not used reference //!< current not used reference
if (!p->used_for_reference) { if (!p->used_for_reference) {
if ((-1 == min_pos) || (p->poc < min_poc)) { if ((-1 == min_pos) || (p->poc < min_poc)) {
FUN_CHECK(ret = direct_output(p_Vid, p)); //!< output frame FUN_CHECK(ret = direct_output(p_Vid, p)); //!< output frame
goto __RETURN; goto __RETURN;
} }
} }
//!< used for reference, but not find, then flush a frame in the first //!< used for reference, but not find, then flush a frame in the first
if ((-1 == min_pos) || (p->poc < min_poc)) { if ((-1 == min_pos) || (p->poc < min_poc)) {
FUN_CHECK(ret = remove_frame_from_dpb(p_Dpb, 0)); FUN_CHECK(ret = remove_frame_from_dpb(p_Dpb, 0));
} }
} }
FUN_CHECK(ret = output_one_frame_from_dpb(p_Dpb)); FUN_CHECK(ret = output_one_frame_from_dpb(p_Dpb));
} }
//!< store current decoder picture at end of dpb //!< store current decoder picture at end of dpb
@@ -1732,7 +1729,7 @@ MPP_RET init_dpb(H264dVideoCtx_t *p_Vid, H264_DpbBuf_t *p_Dpb, RK_S32 type) //
free_dpb(p_Dpb); free_dpb(p_Dpb);
} }
VAL_CHECK(ret, p_Dpb->size = getDpbSize(p_Vid, active_sps)); VAL_CHECK(ret, p_Dpb->size = getDpbSize(p_Vid, active_sps));
p_Dpb->size += (type == 2 ? 0 : 1); p_Dpb->size += (type == 2 ? 0 : 1);
p_Dpb->num_ref_frames = active_sps->max_num_ref_frames; 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"); //H264D_LOG("DPB size at specified level is smaller than reference frames");
@@ -1850,7 +1847,7 @@ __FAILED:
static void reset_dpb_info(H264_DpbInfo_t *p) static void reset_dpb_info(H264_DpbInfo_t *p)
{ {
p->picbuf = NULL; p->refpic = NULL;
p->TOP_POC = 0; p->TOP_POC = 0;
p->BOT_POC = 0; p->BOT_POC = 0;
p->field_flag = 0; p->field_flag = 0;
@@ -1877,7 +1874,7 @@ static MPP_RET adjust_input(H264_SLICE_t *currSlice)
//for (i = 0; i < MAX_DPB_SIZE; i++) { //for (i = 0; i < MAX_DPB_SIZE; i++) {
// if (new_dpb[i].picbuf) { // if (new_dpb[i].refpic) {
// FPRINT(g_debug_file0, "i=%2d, picnum=%d, framenum=%2d, ", i, new_dpb[i].frame_num, new_dpb[i].frame_num); // FPRINT(g_debug_file0, "i=%2d, picnum=%d, framenum=%2d, ", i, new_dpb[i].frame_num, new_dpb[i].frame_num);
// FPRINT(g_debug_file0, " dbp_idx=%d, longterm=%d, poc=%d \n", new_dpb[i].slot_index, new_dpb[i].is_long_term, // FPRINT(g_debug_file0, " dbp_idx=%d, longterm=%d, poc=%d \n", new_dpb[i].slot_index, new_dpb[i].is_long_term,
// new_dpb[i].TOP_POC); // new_dpb[i].TOP_POC);
@@ -1885,7 +1882,7 @@ static MPP_RET adjust_input(H264_SLICE_t *currSlice)
//} //}
//FPRINT(g_debug_file0, "--------- [new DPB] -------- \n"); //FPRINT(g_debug_file0, "--------- [new DPB] -------- \n");
//for (i = 0; i < MAX_DPB_SIZE; i++) { //for (i = 0; i < MAX_DPB_SIZE; i++) {
// if (old_dpb[i].picbuf) { // if (old_dpb[i].refpic) {
// FPRINT(g_debug_file0, "i=%2d, picnum=%d, framenum=%2d, ", i, old_dpb[i].frame_num, old_dpb[i].frame_num); // FPRINT(g_debug_file0, "i=%2d, picnum=%d, framenum=%2d, ", i, old_dpb[i].frame_num, old_dpb[i].frame_num);
// FPRINT(g_debug_file0, " dbp_idx=%d, longterm=%d, poc=%d \n", old_dpb[i].slot_index, old_dpb[i].is_long_term, // FPRINT(g_debug_file0, " dbp_idx=%d, longterm=%d, poc=%d \n", old_dpb[i].slot_index, old_dpb[i].is_long_term,
// old_dpb[i].TOP_POC); // old_dpb[i].TOP_POC);
@@ -1896,9 +1893,9 @@ static MPP_RET adjust_input(H264_SLICE_t *currSlice)
//!< delete old dpb //!< delete old dpb
for (i = 0; i < MAX_DPB_SIZE; i++) { for (i = 0; i < MAX_DPB_SIZE; i++) {
find_flag = 0; find_flag = 0;
if (old_dpb[i].picbuf) { if (old_dpb[i].refpic) {
for (j = 0; j < MAX_DPB_SIZE; j++) { for (j = 0; j < MAX_DPB_SIZE; j++) {
if (new_dpb[j].picbuf) { if (new_dpb[j].refpic) {
find_flag = (old_dpb[i].frame_num == new_dpb[j].frame_num) ? 1 : 0; find_flag = (old_dpb[i].frame_num == new_dpb[j].frame_num) ? 1 : 0;
find_flag = (old_dpb[i].slot_index == new_dpb[j].slot_index) ? find_flag : 0; find_flag = (old_dpb[i].slot_index == new_dpb[j].slot_index) ? find_flag : 0;
if (new_dpb[j].is_used & 0x1) { if (new_dpb[j].is_used & 0x1) {
@@ -1921,11 +1918,11 @@ static MPP_RET adjust_input(H264_SLICE_t *currSlice)
} }
//!< add new dpb //!< add new dpb
for (j = 0; j < MAX_DPB_SIZE; j++) { for (j = 0; j < MAX_DPB_SIZE; j++) {
if ((new_dpb[j].picbuf == 0) || new_dpb[j].have_same) { if ((new_dpb[j].refpic == 0) || new_dpb[j].have_same) {
continue; continue;
} }
for (i = 0; i < MAX_DPB_SIZE; i++) { for (i = 0; i < MAX_DPB_SIZE; i++) {
if (old_dpb[i].picbuf == 0) { if (old_dpb[i].refpic == 0) {
old_dpb[i] = new_dpb[j]; old_dpb[i] = new_dpb[j];
break; break;
} }
@@ -1934,7 +1931,7 @@ static MPP_RET adjust_input(H264_SLICE_t *currSlice)
//memcpy(new_dpb, old_dpb, MAX_DPB_SIZE*sizeof(H264_DpbInfo_t)); //memcpy(new_dpb, old_dpb, MAX_DPB_SIZE*sizeof(H264_DpbInfo_t));
memset(new_dpb, 0, MAX_DPB_SIZE * sizeof(H264_DpbInfo_t)); memset(new_dpb, 0, MAX_DPB_SIZE * sizeof(H264_DpbInfo_t));
for (i = 0, j = 0; i < MAX_DPB_SIZE; i++) { for (i = 0, j = 0; i < MAX_DPB_SIZE; i++) {
if (old_dpb[i].picbuf) { if (old_dpb[i].refpic) {
new_dpb[j] = old_dpb[i]; new_dpb[j] = old_dpb[i];
//FPRINT(g_debug_file0, "i=%2d, picnum=%d, framenum=%2d, ", j, old_dpb[j].frame_num, old_dpb[j].frame_num); //FPRINT(g_debug_file0, "i=%2d, picnum=%d, framenum=%2d, ", j, old_dpb[j].frame_num, old_dpb[j].frame_num);
//FPRINT(g_debug_file0, " dbp_idx=%d, longterm=%d, poc=%d \n", old_dpb[j].slot_index, old_dpb[j].is_long_term, //FPRINT(g_debug_file0, " dbp_idx=%d, longterm=%d, poc=%d \n", old_dpb[j].slot_index, old_dpb[j].is_long_term,
@@ -1973,9 +1970,10 @@ MPP_RET prepare_init_dpb_info(H264_SLICE_t *currSlice)
goto __RETURN; goto __RETURN;
} }
//!<---- reference //!<---- reference
#if 1
for (i = 0, j = 0; j < p_Dpb->ref_frames_in_buffer; i++, j++) { for (i = 0, j = 0; j < p_Dpb->ref_frames_in_buffer; i++, j++) {
if (p_Dpb->fs_ref[j]->is_used == 3) { if (p_Dpb->fs_ref[j]->is_used == 3) {
p_Dec->dpb_info[i].picbuf = p_Dpb->fs_ref[j]->frame; p_Dec->dpb_info[i].refpic = p_Dpb->fs_ref[j]->frame;
if (p_Dpb->fs_ref[j]->frame->iCodingType == FIELD_CODING) { if (p_Dpb->fs_ref[j]->frame->iCodingType == FIELD_CODING) {
p_Dec->dpb_info[i].TOP_POC = p_Dpb->fs_ref[j]->top_field->poc; p_Dec->dpb_info[i].TOP_POC = p_Dpb->fs_ref[j]->top_field->poc;
p_Dec->dpb_info[i].BOT_POC = p_Dpb->fs_ref[j]->bottom_field->poc; p_Dec->dpb_info[i].BOT_POC = p_Dpb->fs_ref[j]->bottom_field->poc;
@@ -1993,7 +1991,7 @@ MPP_RET prepare_init_dpb_info(H264_SLICE_t *currSlice)
p_Dec->dpb_info[i].colmv_is_used = (p_Dpb->fs_ref[j]->frame->colmv_no_used_flag ? 0 : 1); p_Dec->dpb_info[i].colmv_is_used = (p_Dpb->fs_ref[j]->frame->colmv_no_used_flag ? 0 : 1);
} else if (p_Dpb->fs_ref[j]->is_used) { } else if (p_Dpb->fs_ref[j]->is_used) {
if (p_Dpb->fs_ref[j]->is_used & 0x1) { // top if (p_Dpb->fs_ref[j]->is_used & 0x1) { // top
p_Dec->dpb_info[i].picbuf = p_Dpb->fs_ref[j]->top_field; p_Dec->dpb_info[i].refpic = p_Dpb->fs_ref[j]->top_field;
p_Dec->dpb_info[i].TOP_POC = p_Dpb->fs_ref[j]->top_field->poc; p_Dec->dpb_info[i].TOP_POC = p_Dpb->fs_ref[j]->top_field->poc;
p_Dec->dpb_info[i].BOT_POC = 0; p_Dec->dpb_info[i].BOT_POC = 0;
@@ -2001,7 +1999,7 @@ MPP_RET prepare_init_dpb_info(H264_SLICE_t *currSlice)
p_Dec->dpb_info[i].slot_index = p_Dpb->fs_ref[j]->top_field->mem_mark->slot_idx; p_Dec->dpb_info[i].slot_index = p_Dpb->fs_ref[j]->top_field->mem_mark->slot_idx;
p_Dec->dpb_info[i].colmv_is_used = (p_Dpb->fs_ref[j]->top_field->colmv_no_used_flag ? 0 : 1); p_Dec->dpb_info[i].colmv_is_used = (p_Dpb->fs_ref[j]->top_field->colmv_no_used_flag ? 0 : 1);
} else { // if(p_Dpb->fs_ref[j]->is_used & 0x2) // bottom } else { // if(p_Dpb->fs_ref[j]->is_used & 0x2) // bottom
p_Dec->dpb_info[i].picbuf = p_Dpb->fs_ref[j]->bottom_field; p_Dec->dpb_info[i].refpic = p_Dpb->fs_ref[j]->bottom_field;
p_Dec->dpb_info[i].TOP_POC = 0; p_Dec->dpb_info[i].TOP_POC = 0;
p_Dec->dpb_info[i].BOT_POC = p_Dpb->fs_ref[j]->bottom_field->poc; p_Dec->dpb_info[i].BOT_POC = p_Dpb->fs_ref[j]->bottom_field->poc;
p_Dec->dpb_info[i].field_flag = 1; p_Dec->dpb_info[i].field_flag = 1;
@@ -2017,10 +2015,12 @@ MPP_RET prepare_init_dpb_info(H264_SLICE_t *currSlice)
p_Dec->dpb_info[i].view_id = p_Dpb->fs_ref[j]->view_id; p_Dec->dpb_info[i].view_id = p_Dpb->fs_ref[j]->view_id;
p_Dec->dpb_info[i].is_used = p_Dpb->fs_ref[j]->is_used; p_Dec->dpb_info[i].is_used = p_Dpb->fs_ref[j]->is_used;
} }
#endif
//!<---- long term reference //!<---- long term reference
#if 1
for (j = 0; j < p_Dpb->ltref_frames_in_buffer; i++, j++) { for (j = 0; j < p_Dpb->ltref_frames_in_buffer; i++, j++) {
if (p_Dpb->fs_ltref[j]->is_used == 3) { if (p_Dpb->fs_ltref[j]->is_used == 3) {
p_Dec->dpb_info[i].picbuf = p_Dpb->fs_ltref[j]->frame; p_Dec->dpb_info[i].refpic = p_Dpb->fs_ltref[j]->frame;
if (p_Dpb->fs_ltref[j]->frame->iCodingType == FIELD_CODING) { if (p_Dpb->fs_ltref[j]->frame->iCodingType == FIELD_CODING) {
p_Dec->dpb_info[i].TOP_POC = p_Dpb->fs_ltref[j]->top_field->poc; p_Dec->dpb_info[i].TOP_POC = p_Dpb->fs_ltref[j]->top_field->poc;
@@ -2041,7 +2041,7 @@ MPP_RET prepare_init_dpb_info(H264_SLICE_t *currSlice)
p_Dec->dpb_info[i].long_term_pic_num = p_Dpb->fs_ltref[j]->frame->long_term_pic_num; p_Dec->dpb_info[i].long_term_pic_num = p_Dpb->fs_ltref[j]->frame->long_term_pic_num;
} else if (p_Dpb->fs_ltref[j]->is_used) { } else if (p_Dpb->fs_ltref[j]->is_used) {
if (p_Dpb->fs_ltref[j]->is_used & 0x1) { if (p_Dpb->fs_ltref[j]->is_used & 0x1) {
p_Dec->dpb_info[i].picbuf = p_Dpb->fs_ltref[j]->top_field; p_Dec->dpb_info[i].refpic = p_Dpb->fs_ltref[j]->top_field;
p_Dec->dpb_info[i].TOP_POC = p_Dpb->fs_ltref[j]->top_field->poc; p_Dec->dpb_info[i].TOP_POC = p_Dpb->fs_ltref[j]->top_field->poc;
p_Dec->dpb_info[i].BOT_POC = 0; p_Dec->dpb_info[i].BOT_POC = 0;
p_Dec->dpb_info[i].field_flag = 1; p_Dec->dpb_info[i].field_flag = 1;
@@ -2049,7 +2049,7 @@ MPP_RET prepare_init_dpb_info(H264_SLICE_t *currSlice)
p_Dec->dpb_info[i].colmv_is_used = (p_Dpb->fs_ltref[j]->top_field->colmv_no_used_flag ? 0 : 1); p_Dec->dpb_info[i].colmv_is_used = (p_Dpb->fs_ltref[j]->top_field->colmv_no_used_flag ? 0 : 1);
p_Dec->dpb_info[i].long_term_pic_num = p_Dpb->fs_ltref[j]->top_field->long_term_pic_num; p_Dec->dpb_info[i].long_term_pic_num = p_Dpb->fs_ltref[j]->top_field->long_term_pic_num;
} else { // if(p_Dpb->fs_ref[j]->is_used & 0x2) } else { // if(p_Dpb->fs_ref[j]->is_used & 0x2)
p_Dec->dpb_info[i].picbuf = p_Dpb->fs_ltref[j]->bottom_field; p_Dec->dpb_info[i].refpic = p_Dpb->fs_ltref[j]->bottom_field;
p_Dec->dpb_info[i].TOP_POC = 0; p_Dec->dpb_info[i].TOP_POC = 0;
p_Dec->dpb_info[i].BOT_POC = p_Dpb->fs_ltref[j]->bottom_field->poc; p_Dec->dpb_info[i].BOT_POC = p_Dpb->fs_ltref[j]->bottom_field->poc;
p_Dec->dpb_info[i].field_flag = 1; p_Dec->dpb_info[i].field_flag = 1;
@@ -2065,14 +2065,14 @@ MPP_RET prepare_init_dpb_info(H264_SLICE_t *currSlice)
p_Dec->dpb_info[i].view_id = p_Dpb->fs_ltref[j]->view_id; p_Dec->dpb_info[i].view_id = p_Dpb->fs_ltref[j]->view_id;
p_Dec->dpb_info[i].is_used = p_Dpb->fs_ltref[j]->is_used; p_Dec->dpb_info[i].is_used = p_Dpb->fs_ltref[j]->is_used;
} }
#endif
#if 1
//!< inter-layer reference (for multi-layered codecs) //!< inter-layer reference (for multi-layered codecs)
#if 1
for (j = 0; j < p_Dpb->used_size_il; i++, j++) { for (j = 0; j < p_Dpb->used_size_il; i++, j++) {
if (currSlice->structure == FRAME && p_Dpb->fs_ilref[j]->is_used == 3) { if (currSlice->structure == FRAME && p_Dpb->fs_ilref[j]->is_used == 3) {
if (p_Dpb->fs_ilref[j]->inter_view_flag[0] == 0 && p_Dpb->fs_ilref[j]->inter_view_flag[1] == 0) if (p_Dpb->fs_ilref[j]->inter_view_flag[0] == 0 && p_Dpb->fs_ilref[j]->inter_view_flag[1] == 0)
break; break;
p_Dec->dpb_info[i].picbuf = p_Dpb->fs_ilref[j]->frame; p_Dec->dpb_info[i].refpic = p_Dpb->fs_ilref[j]->frame;
if (p_Dpb->fs_ilref[j]->frame->is_mmco_5) { if (p_Dpb->fs_ilref[j]->frame->is_mmco_5) {
p_Dec->dpb_info[i].TOP_POC = p_Dpb->fs_ilref[j]->frame->top_poc_mmco5; p_Dec->dpb_info[i].TOP_POC = p_Dpb->fs_ilref[j]->frame->top_poc_mmco5;
@@ -2088,7 +2088,7 @@ MPP_RET prepare_init_dpb_info(H264_SLICE_t *currSlice)
if (p_Dpb->fs_ilref[j]->is_used == 0x3) { if (p_Dpb->fs_ilref[j]->is_used == 0x3) {
if (p_Dpb->fs_ilref[j]->inter_view_flag[currSlice->structure == BOTTOM_FIELD] == 0) if (p_Dpb->fs_ilref[j]->inter_view_flag[currSlice->structure == BOTTOM_FIELD] == 0)
break; break;
p_Dec->dpb_info[i].picbuf = p_Dpb->fs_ilref[j]->top_field; p_Dec->dpb_info[i].refpic = p_Dpb->fs_ilref[j]->top_field;
if (p_Dpb->fs_ilref[j]->top_field->is_mmco_5) { if (p_Dpb->fs_ilref[j]->top_field->is_mmco_5) {
p_Dec->dpb_info[i].TOP_POC = p_Dpb->fs_ilref[j]->top_field->top_poc_mmco5; p_Dec->dpb_info[i].TOP_POC = p_Dpb->fs_ilref[j]->top_field->top_poc_mmco5;
@@ -2107,7 +2107,7 @@ MPP_RET prepare_init_dpb_info(H264_SLICE_t *currSlice)
if (p_Dpb->fs_ilref[j]->is_used & 0x1) { if (p_Dpb->fs_ilref[j]->is_used & 0x1) {
if (p_Dpb->fs_ilref[j]->inter_view_flag[0] == 0) if (p_Dpb->fs_ilref[j]->inter_view_flag[0] == 0)
break; break;
p_Dec->dpb_info[i].picbuf = p_Dpb->fs_ilref[j]->top_field; p_Dec->dpb_info[i].refpic = p_Dpb->fs_ilref[j]->top_field;
if (p_Dpb->fs_ilref[j]->top_field->is_mmco_5) { if (p_Dpb->fs_ilref[j]->top_field->is_mmco_5) {
p_Dec->dpb_info[i].TOP_POC = p_Dpb->fs_ilref[j]->top_field->top_poc_mmco5; p_Dec->dpb_info[i].TOP_POC = p_Dpb->fs_ilref[j]->top_field->top_poc_mmco5;
@@ -2121,7 +2121,7 @@ MPP_RET prepare_init_dpb_info(H264_SLICE_t *currSlice)
} else { // if(p_Dpb->fs_ref[j]->is_used & 0x2) } else { // if(p_Dpb->fs_ref[j]->is_used & 0x2)
if (p_Dpb->fs_ilref[j]->inter_view_flag[1] == 0) if (p_Dpb->fs_ilref[j]->inter_view_flag[1] == 0)
break; break;
p_Dec->dpb_info[i].picbuf = p_Dpb->fs_ilref[j]->bottom_field; p_Dec->dpb_info[i].refpic = p_Dpb->fs_ilref[j]->bottom_field;
p_Dec->dpb_info[i].TOP_POC = 0; p_Dec->dpb_info[i].TOP_POC = 0;
if (p_Dpb->fs_ilref[j]->bottom_field->is_mmco_5) { if (p_Dpb->fs_ilref[j]->bottom_field->is_mmco_5) {
@@ -2144,44 +2144,24 @@ MPP_RET prepare_init_dpb_info(H264_SLICE_t *currSlice)
p_Dec->dpb_info[i].is_used = p_Dpb->fs_ilref[j]->is_used; p_Dec->dpb_info[i].is_used = p_Dpb->fs_ilref[j]->is_used;
} }
#endif #endif
//!< dump dpb_init info
//for(j = 0; j < i; j++) { H264D_DBG(H264D_DBG_DPB_INFO, "---- DPB INFO ----");
// FPRINT(g_debug_file1, "i=%2d, picnum=%d, framenum=%2d, ", j, p_Dec->dpb_info[j].frame_num, p_Dec->dpb_info[j].frame_num); for (j = 0; j < i; j++) {
// FPRINT(g_debug_file1, " dbp_idx=%d, longterm=%d, poc=%d \n", p_Dec->dpb_info[j].slot_index, p_Dec->dpb_info[j].is_long_term, H264D_DBG(H264D_DBG_DPB_INFO, "j=%d, top_poc=%d, bot_poc=%d, frame_num=%d, is_lt=%d, layer_id=%d\n", j, p_Dec->dpb_info[j].TOP_POC,
// p_Dec->dpb_info[j].TOP_POC); p_Dec->dpb_info[j].BOT_POC, p_Dec->dpb_info[j].frame_num, p_Dec->dpb_info[j].is_ilt_flag, p_Dec->dpb_info[j].voidx);
//} }
//FPRINT(g_debug_file1, "--------- [FLUSH_CNT] flush framecnt=%d -------- \n", p_Dec->p_Vid->g_framecnt);
//if (p_Dec->p_Vid->g_framecnt == 255) {
// i = i;
//}
//!< reset left parameters //!< reset left parameters
for (; i < MAX_DPB_SIZE; i++) { for (; i < MAX_DPB_SIZE; i++) {
reset_dpb_info(&p_Dec->dpb_info[i]); reset_dpb_info(&p_Dec->dpb_info[i]);
} }
//FPRINT(g_debug_file0, "---g_framecnt=%d\n", p_Dec->p_Vid->g_framecnt);
//for (i = 0; i< 16; i++)
//{
// FPRINT(g_debug_file0, "i=%d, top_poc=%d, bot_poc=%d, frame_num=%d, is_lt=%d, voidx=%d\n", i, p_Dec->dpb_info[i].TOP_POC,
// p_Dec->dpb_info[i].BOT_POC, p_Dec->dpb_info[i].frame_num, p_Dec->dpb_info[i].is_ilt_flag, p_Dec->dpb_info[i].voidx);
//}
//adjust_input(currSlice); //adjust_input(currSlice);
for (i = 0; i < MAX_DPB_SIZE; i++) { for (i = 0; i < MAX_DPB_SIZE; i++) {
if ((NULL != p_Dec->dpb_info[i].picbuf) && (p_Dec->dpb_info[i].slot_index >= 0)) { if ((NULL != p_Dec->dpb_info[i].refpic) && (p_Dec->dpb_info[i].slot_index >= 0)) {
p_Dec->in_task->refer[i] = p_Dec->dpb_info[i].slot_index; p_Dec->in_task->refer[i] = p_Dec->dpb_info[i].slot_index;
mpp_buf_slot_set_flag(p_Dec->frame_slots, p_Dec->dpb_info[i].slot_index, SLOT_HAL_INPUT); mpp_buf_slot_set_flag(p_Dec->frame_slots, p_Dec->dpb_info[i].slot_index, SLOT_HAL_INPUT);
mpp_buf_slot_set_flag(p_Dec->frame_slots, p_Dec->dpb_info[i].slot_index, SLOT_CODEC_USE); mpp_buf_slot_set_flag(p_Dec->frame_slots, p_Dec->dpb_info[i].slot_index, SLOT_CODEC_USE);
} }
} }
__RETURN: __RETURN:
return MPP_OK; return MPP_OK;
} }
@@ -2196,7 +2176,7 @@ __RETURN:
//extern "C" //extern "C"
MPP_RET prepare_init_ref_info(H264_SLICE_t *currSlice) MPP_RET prepare_init_ref_info(H264_SLICE_t *currSlice)
{ {
void *picbuf = NULL; void *refpic = NULL;
RK_U32 i = 0, j = 0, k = 0; RK_U32 i = 0, j = 0, k = 0;
RK_S32 poc = 0, TOP_POC = 0, BOT_POC = 0; RK_S32 poc = 0, TOP_POC = 0, BOT_POC = 0;
RK_S32 layer_id = 0, voidx = 0, is_used = 0; RK_S32 layer_id = 0, voidx = 0, is_used = 0;
@@ -2226,12 +2206,12 @@ MPP_RET prepare_init_ref_info(H264_SLICE_t *currSlice)
? currSlice->listP[0][j]->bot_poc_mmco5 : currSlice->listP[0][j]->bottom_poc; ? currSlice->listP[0][j]->bot_poc_mmco5 : currSlice->listP[0][j]->bottom_poc;
} }
for (i = 0; i < 16; i++) { for (i = 0; i < 16; i++) {
picbuf = p_Dec->dpb_info[i].picbuf; refpic = p_Dec->dpb_info[i].refpic;
TOP_POC = p_Dec->dpb_info[i].TOP_POC; TOP_POC = p_Dec->dpb_info[i].TOP_POC;
BOT_POC = p_Dec->dpb_info[i].BOT_POC; BOT_POC = p_Dec->dpb_info[i].BOT_POC;
voidx = p_Dec->dpb_info[i].voidx; voidx = p_Dec->dpb_info[i].voidx;
is_used = p_Dec->dpb_info[i].is_used; is_used = p_Dec->dpb_info[i].is_used;
if (currSlice->structure == FRAME && picbuf) { if (currSlice->structure == FRAME && refpic) {
if (poc == MPP_MIN(TOP_POC, BOT_POC) && (layer_id == voidx)) if (poc == MPP_MIN(TOP_POC, BOT_POC) && (layer_id == voidx))
break; break;
} else { } else {
@@ -2249,7 +2229,6 @@ MPP_RET prepare_init_ref_info(H264_SLICE_t *currSlice)
} }
ASSERT(i < 16); ASSERT(i < 16);
p_Dec->refpic_info_p[j].dpb_idx = i; p_Dec->refpic_info_p[j].dpb_idx = i;
if (currSlice->listP[0][j]->structure == BOTTOM_FIELD) { if (currSlice->listP[0][j]->structure == BOTTOM_FIELD) {
p_Dec->refpic_info_p[j].bottom_flag = 1; p_Dec->refpic_info_p[j].bottom_flag = 1;
} else { } else {
@@ -2279,12 +2258,12 @@ MPP_RET prepare_init_ref_info(H264_SLICE_t *currSlice)
? currSlice->listB[k][j]->bot_poc_mmco5 : currSlice->listB[k][j]->bottom_poc; ? currSlice->listB[k][j]->bot_poc_mmco5 : currSlice->listB[k][j]->bottom_poc;
} }
for (i = 0; i < 16; i++) { for (i = 0; i < 16; i++) {
picbuf = p_Dec->dpb_info[i].picbuf; refpic = p_Dec->dpb_info[i].refpic;
TOP_POC = p_Dec->dpb_info[i].TOP_POC; TOP_POC = p_Dec->dpb_info[i].TOP_POC;
BOT_POC = p_Dec->dpb_info[i].BOT_POC; BOT_POC = p_Dec->dpb_info[i].BOT_POC;
voidx = p_Dec->dpb_info[i].voidx; voidx = p_Dec->dpb_info[i].voidx;
is_used = p_Dec->dpb_info[i].is_used; is_used = p_Dec->dpb_info[i].is_used;
if (currSlice->structure == FRAME && picbuf) { if (currSlice->structure == FRAME && refpic) {
if (poc == MPP_MIN(TOP_POC, BOT_POC) && (layer_id == voidx)) if (poc == MPP_MIN(TOP_POC, BOT_POC) && (layer_id == voidx))
break; break;
} else { } else {
@@ -2302,13 +2281,11 @@ MPP_RET prepare_init_ref_info(H264_SLICE_t *currSlice)
} }
ASSERT(i < 16); ASSERT(i < 16);
p_Dec->refpic_info_b[k][j].dpb_idx = i; p_Dec->refpic_info_b[k][j].dpb_idx = i;
if (currSlice->listB[k][j]->structure == BOTTOM_FIELD) { if (currSlice->listB[k][j]->structure == BOTTOM_FIELD) {
p_Dec->refpic_info_b[k][j].bottom_flag = 1; p_Dec->refpic_info_b[k][j].bottom_flag = 1;
} else { } else {
p_Dec->refpic_info_b[k][j].bottom_flag = 0; p_Dec->refpic_info_b[k][j].bottom_flag = 0;
} }
p_Dec->refpic_info_b[k][j].valid = 1; p_Dec->refpic_info_b[k][j].valid = 1;
} else { } else {
p_Dec->refpic_info_b[k][j].valid = 0; p_Dec->refpic_info_b[k][j].valid = 0;
@@ -2338,7 +2315,7 @@ MPP_RET update_dpb(H264_DecCtx_t *p_Dec)
p_Dec->p_Vid->exit_picture_flag = 1; p_Dec->p_Vid->exit_picture_flag = 1;
p_Dec->p_Vid->have_outpicture_flag = 1; p_Dec->p_Vid->have_outpicture_flag = 1;
ret = exit_picture(p_Dec->p_Vid, &p_Dec->p_Vid->dec_pic); ret = exit_picture(p_Dec->p_Vid, &p_Dec->p_Vid->dec_pic);
p_Dec->p_Vid->iNumOfSlicesDecoded = 0; p_Dec->p_Vid->iNumOfSlicesDecoded = 0;
p_Dec->p_Vid->exit_picture_flag = 0; p_Dec->p_Vid->exit_picture_flag = 0;

View File

@@ -149,7 +149,7 @@ void fill_picparams(H264dVideoCtx_t *p_Vid, DXVA_PicParams_H264_MVC *pp)
pp->UsedForReferenceFlags = 0; pp->UsedForReferenceFlags = 0;
pp->NonExistingFrameFlags = 0; pp->NonExistingFrameFlags = 0;
for (i = 0; i < MPP_ARRAY_ELEMS(pp->RefFrameList); i++) { for (i = 0; i < MPP_ARRAY_ELEMS(pp->RefFrameList); i++) {
if (dpb_info[i].picbuf) { if (dpb_info[i].refpic) {
fill_picture_entry(&pp->RefFrameList[i], dpb_info[i].slot_index, dpb_info[i].is_long_term); fill_picture_entry(&pp->RefFrameList[i], dpb_info[i].slot_index, dpb_info[i].is_long_term);
pp->FieldOrderCntList[i][0] = dpb_info[i].TOP_POC; pp->FieldOrderCntList[i][0] = dpb_info[i].TOP_POC;
pp->FieldOrderCntList[i][1] = dpb_info[i].BOT_POC; pp->FieldOrderCntList[i][1] = dpb_info[i].BOT_POC;
@@ -327,7 +327,7 @@ MPP_RET fill_slice_syntax(H264_SLICE_t *currSlice, H264dDxvaCtx_t *dxva_ctx)
for (i = 0; i < MPP_ARRAY_ELEMS(p_long->RefPicList[0]); i++) { for (i = 0; i < MPP_ARRAY_ELEMS(p_long->RefPicList[0]); i++) {
dpb_idx = currSlice->p_Dec->refpic_info_p[i].dpb_idx; dpb_idx = currSlice->p_Dec->refpic_info_p[i].dpb_idx;
dpb_valid = currSlice->p_Dec->refpic_info_p[i].valid; dpb_valid = currSlice->p_Dec->refpic_info_p[i].valid;
//dpb_valid = (currSlice->p_Dec->dpb_info[dpb_idx].picbuf ? 1 : 0); //dpb_valid = (currSlice->p_Dec->dpb_info[dpb_idx].refpic ? 1 : 0);
if (dpb_valid) { if (dpb_valid) {
bottom_flag = currSlice->p_Dec->refpic_info_p[i].bottom_flag; bottom_flag = currSlice->p_Dec->refpic_info_p[i].bottom_flag;
fill_picture_entry(&p_long->RefPicList[0][i], dpb_idx, bottom_flag); fill_picture_entry(&p_long->RefPicList[0][i], dpb_idx, bottom_flag);
@@ -340,7 +340,7 @@ MPP_RET fill_slice_syntax(H264_SLICE_t *currSlice, H264dDxvaCtx_t *dxva_ctx)
for (i = 0; i < MPP_ARRAY_ELEMS(p_long->RefPicList[list + 1]); i++) { for (i = 0; i < MPP_ARRAY_ELEMS(p_long->RefPicList[list + 1]); i++) {
dpb_idx = currSlice->p_Dec->refpic_info_b[list][i].dpb_idx; dpb_idx = currSlice->p_Dec->refpic_info_b[list][i].dpb_idx;
dpb_valid = currSlice->p_Dec->refpic_info_b[list][i].valid; dpb_valid = currSlice->p_Dec->refpic_info_b[list][i].valid;
//dpb_valid = (currSlice->p_Dec->dpb_info[dpb_idx].picbuf ? 1 : 0); //dpb_valid = (currSlice->p_Dec->dpb_info[dpb_idx].refpic ? 1 : 0);
if (dpb_valid) { if (dpb_valid) {
bottom_flag = currSlice->p_Dec->refpic_info_b[list][i].bottom_flag; bottom_flag = currSlice->p_Dec->refpic_info_b[list][i].bottom_flag;
fill_picture_entry(&p_long->RefPicList[list + 1][i], dpb_idx, bottom_flag); fill_picture_entry(&p_long->RefPicList[list + 1][i], dpb_idx, bottom_flag);

View File

@@ -190,7 +190,7 @@ typedef enum {
Mem_Malloc = 1, Mem_Malloc = 1,
Mem_Clone = 2, Mem_Clone = 2,
Mem_UnPaired = 3, Mem_UnPaired = 3,
Mem_Fake = 4, Mem_Fake = 4,
Mem_Max, Mem_Max,
} H264_Mem_type; } H264_Mem_type;
@@ -225,7 +225,7 @@ typedef struct h264_dpb_info_t {
RK_U32 is_used; RK_U32 is_used;
RK_U32 top_valid; RK_U32 top_valid;
RK_U32 bot_valid; RK_U32 bot_valid;
struct h264_store_pic_t *picbuf; struct h264_store_pic_t *refpic;
RK_U32 have_same; RK_U32 have_same;
} H264_DpbInfo_t; } H264_DpbInfo_t;
@@ -293,7 +293,7 @@ typedef struct h264_store_pic_t {
RK_S32 poc_mmco5; RK_S32 poc_mmco5;
RK_S32 top_poc_mmco5; RK_S32 top_poc_mmco5;
RK_S32 bot_poc_mmco5; RK_S32 bot_poc_mmco5;
RK_S32 combine_flag; // top && bottom field combined flag RK_S32 combine_flag; // top && bottom field combined flag
H264_Mem_type mem_malloc_type; H264_Mem_type mem_malloc_type;
struct h264_dpb_mark_t *mem_mark; struct h264_dpb_mark_t *mem_mark;
} H264_StorePic_t; } H264_StorePic_t;
@@ -841,7 +841,7 @@ typedef struct h264d_input_ctx_t {
RK_S64 in_pts; RK_S64 in_pts;
RK_S64 in_dts; RK_S64 in_dts;
RK_U8 has_get_eos; RK_U8 has_get_eos;
RK_U32 mvc_disable; RK_U32 mvc_disable;
//!< output data //!< output data
RK_U8 *out_buf; RK_U8 *out_buf;
RK_U32 out_length; RK_U32 out_length;
@@ -989,14 +989,14 @@ typedef struct h264d_video_ctx_t {
RK_S32 have_outpicture_flag; RK_S32 have_outpicture_flag;
RK_S32 exit_picture_flag; RK_S32 exit_picture_flag;
RK_S32 active_mvc_sps_flag; RK_S32 active_mvc_sps_flag;
//!< for error tolerance //!< for error tolerance
RK_U32 g_framecnt; RK_U32 g_framecnt;
RK_U32 dpb_size[MAX_NUM_DPB_LAYERS]; RK_U32 dpb_size[MAX_NUM_DPB_LAYERS];
RK_S32 last_outputpoc[MAX_NUM_DPB_LAYERS]; RK_S32 last_outputpoc[MAX_NUM_DPB_LAYERS];
RK_U32 iframe_cnt; RK_U32 iframe_cnt;
RK_S32 first_iframe_poc; RK_S32 first_iframe_poc;
struct h264d_outlist_t outlist[MAX_NUM_DPB_LAYERS]; struct h264d_outlist_t outlist[MAX_NUM_DPB_LAYERS];
} H264dVideoCtx_t; } H264dVideoCtx_t;
typedef struct h264d_mem_t { typedef struct h264d_mem_t {
@@ -1051,12 +1051,12 @@ typedef enum slice_state_type {
} SLICE_STATUS; } SLICE_STATUS;
typedef struct h264_err_ctx_t { typedef struct h264_err_ctx_t {
RK_U32 parse_err_flag; RK_U32 parse_err_flag;
RK_U32 dpb_err_flag; RK_U32 dpb_err_flag;
RK_U32 used_for_ref_flag; RK_U32 used_for_ref_flag;
RK_U32 i_slice_no; RK_U32 i_slice_no;
RK_U32 dpb_err[MAX_NUM_DPB_LAYERS]; RK_U32 dpb_err[MAX_NUM_DPB_LAYERS];
RK_U32 pre_status[MAX_NUM_DPB_LAYERS]; RK_U32 pre_status[MAX_NUM_DPB_LAYERS];
} H264dErrCtx_t; } H264dErrCtx_t;
//!< decoder video parameter //!< decoder video parameter
typedef struct h264_dec_ctx_t { typedef struct h264_dec_ctx_t {
@@ -1091,7 +1091,7 @@ typedef struct h264_dec_ctx_t {
RK_U32 task_eos; RK_U32 task_eos;
HalDecTask *in_task; HalDecTask *in_task;
RK_S32 last_frame_slot_idx; RK_S32 last_frame_slot_idx;
struct h264_err_ctx_t errctx; struct h264_err_ctx_t errctx;
} H264_DecCtx_t; } H264_DecCtx_t;

View File

@@ -384,8 +384,8 @@ static void dpb_mark_malloc(H264dVideoCtx_t *p_Vid, H264_StorePic_t *dec_pic)
RK_U32 hor_stride = 0, ver_stride = 0; RK_U32 hor_stride = 0, ver_stride = 0;
H264_DecCtx_t *p_Dec = p_Vid->p_Dec; H264_DecCtx_t *p_Dec = p_Vid->p_Dec;
H264_DpbMark_t *p_mark = p_Vid->p_Dec->dpb_mark; H264_DpbMark_t *p_mark = p_Vid->p_Dec->dpb_mark;
RK_S32 structure = dec_pic->structure; RK_S32 structure = dec_pic->structure;
RK_S32 layer_id = dec_pic->layer_id; RK_S32 layer_id = dec_pic->layer_id;
if (!dec_pic->combine_flag) { if (!dec_pic->combine_flag) {
while (p_mark[idx].out_flag || p_mark[idx].top_used || p_mark[idx].bot_used) { while (p_mark[idx].out_flag || p_mark[idx].top_used || p_mark[idx].bot_used) {
idx++; idx++;
@@ -394,39 +394,36 @@ static void dpb_mark_malloc(H264dVideoCtx_t *p_Vid, H264_StorePic_t *dec_pic)
mpp_buf_slot_get_unused(p_Vid->p_Dec->frame_slots, &p_mark[idx].slot_idx); mpp_buf_slot_get_unused(p_Vid->p_Dec->frame_slots, &p_mark[idx].slot_idx);
cur_mark = &p_mark[idx]; cur_mark = &p_mark[idx];
cur_mark->out_flag = 1; cur_mark->out_flag = 1;
{ {
MppFrame mframe = NULL; MppFrame mframe = NULL;
mpp_frame_init(&mframe); mpp_frame_init(&mframe);
if ((YUV420 == p_Vid->yuv_format) && (8 == p_Vid->bit_depth_luma)) { if ((YUV420 == p_Vid->yuv_format) && (8 == p_Vid->bit_depth_luma)) {
mpp_frame_set_fmt(mframe, MPP_FMT_YUV420SP); mpp_frame_set_fmt(mframe, MPP_FMT_YUV420SP);
} } else if ((YUV420 == p_Vid->yuv_format) && (10 == p_Vid->bit_depth_luma)) {
else if ((YUV420 == p_Vid->yuv_format) && (10 == p_Vid->bit_depth_luma)) { mpp_frame_set_fmt(mframe, MPP_FMT_YUV420SP_10BIT);
mpp_frame_set_fmt(mframe, MPP_FMT_YUV420SP_10BIT); } else if ((YUV422 == p_Vid->yuv_format) && (8 == p_Vid->bit_depth_luma)) {
} mpp_frame_set_fmt(mframe, MPP_FMT_YUV422SP);
else if ((YUV422 == p_Vid->yuv_format) && (8 == p_Vid->bit_depth_luma)) { } else if ((YUV422 == p_Vid->yuv_format) && (10 == p_Vid->bit_depth_luma)) {
mpp_frame_set_fmt(mframe, MPP_FMT_YUV422SP); mpp_frame_set_fmt(mframe, MPP_FMT_YUV422SP_10BIT);
} }
else if ((YUV422 == p_Vid->yuv_format) && (10 == p_Vid->bit_depth_luma)) { hor_stride = ((p_Vid->width * p_Vid->bit_depth_luma + 127) & (~127)) / 8;
mpp_frame_set_fmt(mframe, MPP_FMT_YUV422SP_10BIT); ver_stride = p_Vid->height;
} mpp_frame_set_hor_stride(mframe, hor_stride); // before crop
hor_stride = ((p_Vid->width * p_Vid->bit_depth_luma + 127) & (~127)) / 8; mpp_frame_set_ver_stride(mframe, ver_stride);
ver_stride = p_Vid->height; mpp_frame_set_width(mframe, p_Vid->width_after_crop); // after crop
mpp_frame_set_hor_stride(mframe, hor_stride); // before crop mpp_frame_set_height(mframe, p_Vid->height_after_crop);
mpp_frame_set_ver_stride(mframe, ver_stride); mpp_frame_set_pts(mframe, p_Vid->p_Cur->last_pts);
mpp_frame_set_width(mframe, p_Vid->width_after_crop); // after crop mpp_frame_set_dts(mframe, p_Vid->p_Cur->last_dts);
mpp_frame_set_height(mframe, p_Vid->height_after_crop); mpp_buf_slot_set_prop(p_Dec->frame_slots, cur_mark->slot_idx, SLOT_FRAME, mframe);
mpp_frame_set_pts(mframe, p_Vid->p_Cur->last_pts); mpp_frame_deinit(&mframe);
mpp_frame_set_dts(mframe, p_Vid->p_Cur->last_dts); mpp_buf_slot_get_prop(p_Dec->frame_slots, cur_mark->slot_idx, SLOT_FRAME_PTR, &cur_mark->mframe);
mpp_buf_slot_set_prop(p_Dec->frame_slots, cur_mark->slot_idx, SLOT_FRAME, mframe); }
mpp_frame_deinit(&mframe); {
mpp_buf_slot_get_prop(p_Dec->frame_slots, cur_mark->slot_idx, SLOT_FRAME_PTR, &cur_mark->mframe); MppBuffer mbuffer = NULL;
} mpp_buf_slot_get_prop(p_Dec->frame_slots, cur_mark->slot_idx, SLOT_BUFFER, &mbuffer);
{ H264D_DBG(H264D_DBG_DPB_MALLIC, "[DPB malloc] g_framecnt=%d, mark_idx=%d, slot_idx=%d, slice_type=%d, lay_id=%d, pts=%lld \n",
MppBuffer mbuffer = NULL; p_Vid->g_framecnt, cur_mark->mark_idx, cur_mark->slot_idx, dec_pic->slice_type, layer_id, p_Vid->p_Inp->in_pts);
mpp_buf_slot_get_prop(p_Dec->frame_slots, cur_mark->slot_idx, SLOT_BUFFER, &mbuffer); }
H264D_DBG(H264D_DBG_DPB_MALLIC, "[DPB malloc] g_framecnt=%d, mark_idx=%d, slot_idx=%d, slice_type=%d, lay_id=%d, pts=%lld \n",
p_Vid->g_framecnt, cur_mark->mark_idx, cur_mark->slot_idx, dec_pic->slice_type, layer_id, p_Vid->p_Inp->in_pts);
}
p_Vid->active_dpb_mark[layer_id] = cur_mark; p_Vid->active_dpb_mark[layer_id] = cur_mark;
} }
@@ -439,13 +436,13 @@ static void dpb_mark_malloc(H264dVideoCtx_t *p_Vid, H264_StorePic_t *dec_pic)
} }
p_Vid->p_Dec->in_task->output = cur_mark->slot_idx; p_Vid->p_Dec->in_task->output = cur_mark->slot_idx;
mpp_buf_slot_set_flag(p_Dec->frame_slots, cur_mark->slot_idx, SLOT_HAL_OUTPUT); mpp_buf_slot_set_flag(p_Dec->frame_slots, cur_mark->slot_idx, SLOT_HAL_OUTPUT);
p_Dec->last_frame_slot_idx = cur_mark->slot_idx; p_Dec->last_frame_slot_idx = cur_mark->slot_idx;
dec_pic->mem_mark = p_Vid->active_dpb_mark[layer_id]; dec_pic->mem_mark = p_Vid->active_dpb_mark[layer_id];
dec_pic->mem_mark->pic = dec_pic; dec_pic->mem_mark->pic = dec_pic;
} }
static MPP_RET alloc_decpic(H264_SLICE_t *currSlice) static MPP_RET alloc_decpic(H264_SLICE_t *currSlice)
{ {
MPP_RET ret = MPP_ERR_UNKNOW; MPP_RET ret = MPP_ERR_UNKNOW;
H264_StorePic_t *dec_pic = NULL; H264_StorePic_t *dec_pic = NULL;
H264dVideoCtx_t *p_Vid = currSlice->p_Vid; H264dVideoCtx_t *p_Vid = currSlice->p_Vid;
@@ -530,7 +527,7 @@ static MPP_RET alloc_decpic(H264_SLICE_t *currSlice)
dec_pic->height = p_Vid->height; dec_pic->height = p_Vid->height;
dec_pic->width_after_crop = p_Vid->width_after_crop; dec_pic->width_after_crop = p_Vid->width_after_crop;
dec_pic->height_after_crop = p_Vid->height_after_crop; dec_pic->height_after_crop = p_Vid->height_after_crop;
dec_pic->combine_flag = get_filed_dpb_combine_flag(p_Dpb, dec_pic); dec_pic->combine_flag = get_filed_dpb_combine_flag(p_Dpb, dec_pic);
dec_pic->mem_malloc_type = Mem_Malloc; dec_pic->mem_malloc_type = Mem_Malloc;
dpb_mark_malloc(p_Vid, dec_pic); // malloc dpb_memory dpb_mark_malloc(p_Vid, dec_pic); // malloc dpb_memory
@@ -538,7 +535,7 @@ static MPP_RET alloc_decpic(H264_SLICE_t *currSlice)
p_Vid->last_pic_structure = dec_pic->structure; p_Vid->last_pic_structure = dec_pic->structure;
p_Vid->dec_pic = dec_pic; p_Vid->dec_pic = dec_pic;
return ret = MPP_OK; return ret = MPP_OK;
__FAILED: __FAILED:
MPP_FREE(dec_pic); MPP_FREE(dec_pic);
@@ -1167,246 +1164,243 @@ __FAILED:
static RK_U32 get_short_term_pic(H264_SLICE_t *currSlice, RK_S32 picNum, H264_StorePic_t **find_pic) static RK_U32 get_short_term_pic(H264_SLICE_t *currSlice, RK_S32 picNum, H264_StorePic_t **find_pic)
{ {
RK_U32 i = 0; RK_U32 i = 0;
H264_StorePic_t *ret_pic = NULL; H264_StorePic_t *ret_pic = NULL;
H264_StorePic_t *near_pic = NULL; H264_StorePic_t *near_pic = NULL;
H264_DpbBuf_t *p_Dpb = currSlice->p_Dpb; H264_DpbBuf_t *p_Dpb = currSlice->p_Dpb;
for (i = 0; i < p_Dpb->ref_frames_in_buffer; i++) { for (i = 0; i < p_Dpb->ref_frames_in_buffer; i++) {
if (currSlice->structure == FRAME) { if (currSlice->structure == FRAME) {
if ((p_Dpb->fs_ref[i]->is_reference == 3) if ((p_Dpb->fs_ref[i]->is_reference == 3)
&& (!p_Dpb->fs_ref[i]->frame->is_long_term)) { && (!p_Dpb->fs_ref[i]->frame->is_long_term)) {
if (p_Dpb->fs_ref[i]->frame->pic_num == picNum) { if (p_Dpb->fs_ref[i]->frame->pic_num == picNum) {
ret_pic = p_Dpb->fs_ref[i]->frame; ret_pic = p_Dpb->fs_ref[i]->frame;
break; break;
} else { } else {
near_pic = p_Dpb->fs_ref[i]->frame; near_pic = p_Dpb->fs_ref[i]->frame;
} }
} }
} else { } else {
if ((p_Dpb->fs_ref[i]->is_reference & 1) if ((p_Dpb->fs_ref[i]->is_reference & 1)
&& (!p_Dpb->fs_ref[i]->top_field->is_long_term)) { && (!p_Dpb->fs_ref[i]->top_field->is_long_term)) {
if(p_Dpb->fs_ref[i]->top_field->pic_num == picNum){ if (p_Dpb->fs_ref[i]->top_field->pic_num == picNum) {
ret_pic = p_Dpb->fs_ref[i]->top_field; ret_pic = p_Dpb->fs_ref[i]->top_field;
break; break;
}else { } else {
near_pic = p_Dpb->fs_ref[i]->top_field; near_pic = p_Dpb->fs_ref[i]->top_field;
} }
} }
if ((p_Dpb->fs_ref[i]->is_reference & 2) if ((p_Dpb->fs_ref[i]->is_reference & 2)
&& (!p_Dpb->fs_ref[i]->bottom_field->is_long_term)) { && (!p_Dpb->fs_ref[i]->bottom_field->is_long_term)) {
if (p_Dpb->fs_ref[i]->bottom_field->pic_num == picNum) { if (p_Dpb->fs_ref[i]->bottom_field->pic_num == picNum) {
ret_pic = p_Dpb->fs_ref[i]->bottom_field; ret_pic = p_Dpb->fs_ref[i]->bottom_field;
break; break;
} else { } else {
near_pic = p_Dpb->fs_ref[i]->bottom_field; near_pic = p_Dpb->fs_ref[i]->bottom_field;
} }
} }
} }
} }
*find_pic = ret_pic ? ret_pic : near_pic; *find_pic = ret_pic ? ret_pic : near_pic;
return (ret_pic ? 1 : 0); return (ret_pic ? 1 : 0);
} }
static H264_StorePic_t *get_long_term_pic(H264_SLICE_t *currSlice, RK_S32 LongtermPicNum) static H264_StorePic_t *get_long_term_pic(H264_SLICE_t *currSlice, RK_S32 LongtermPicNum)
{ {
RK_U32 i = 0; RK_U32 i = 0;
H264_DpbBuf_t *p_Dpb = currSlice->p_Dpb; H264_DpbBuf_t *p_Dpb = currSlice->p_Dpb;
for (i = 0; i < p_Dpb->ltref_frames_in_buffer; i++) { for (i = 0; i < p_Dpb->ltref_frames_in_buffer; i++) {
if (currSlice->structure == FRAME) { if (currSlice->structure == FRAME) {
if (p_Dpb->fs_ltref[i]->is_reference == 3) if (p_Dpb->fs_ltref[i]->is_reference == 3)
if ((p_Dpb->fs_ltref[i]->frame->is_long_term) if ((p_Dpb->fs_ltref[i]->frame->is_long_term)
&& (p_Dpb->fs_ltref[i]->frame->long_term_pic_num == LongtermPicNum)) && (p_Dpb->fs_ltref[i]->frame->long_term_pic_num == LongtermPicNum))
return p_Dpb->fs_ltref[i]->frame; return p_Dpb->fs_ltref[i]->frame;
} else { } else {
if (p_Dpb->fs_ltref[i]->is_reference & 1) if (p_Dpb->fs_ltref[i]->is_reference & 1)
if ((p_Dpb->fs_ltref[i]->top_field->is_long_term) if ((p_Dpb->fs_ltref[i]->top_field->is_long_term)
&& (p_Dpb->fs_ltref[i]->top_field->long_term_pic_num == LongtermPicNum)) && (p_Dpb->fs_ltref[i]->top_field->long_term_pic_num == LongtermPicNum))
return p_Dpb->fs_ltref[i]->top_field; return p_Dpb->fs_ltref[i]->top_field;
if (p_Dpb->fs_ltref[i]->is_reference & 2) if (p_Dpb->fs_ltref[i]->is_reference & 2)
if ((p_Dpb->fs_ltref[i]->bottom_field->is_long_term) if ((p_Dpb->fs_ltref[i]->bottom_field->is_long_term)
&& (p_Dpb->fs_ltref[i]->bottom_field->long_term_pic_num == LongtermPicNum)) && (p_Dpb->fs_ltref[i]->bottom_field->long_term_pic_num == LongtermPicNum))
return p_Dpb->fs_ltref[i]->bottom_field; return p_Dpb->fs_ltref[i]->bottom_field;
} }
} }
return NULL; return NULL;
} }
#if 0
static H264_StorePic_t *fake_short_term_pic(H264_SLICE_t *currSlice, RK_S32 picNumLX, H264_StorePic_t *tmp) static void fake_short_term_pic(H264_SLICE_t *currSlice, RK_S32 picNumLX, H264_StorePic_t *tmp)
{ {
H264_StorePic_t *fake = NULL; #if 0
H264_StorePic_t *dec_pic = NULL; H264_StorePic_t *fake = NULL;
H264_StorePic_t *dec_pic = NULL;
fake = alloc_storable_picture(currSlice->p_Vid, FRAME);
if (fake == NULL) {
H264D_ERR("failed to alloc new dpb buffer");
goto __FAILED;
}
fake->is_long_term = 0;
fake->view_id = fake->view_id;
fake->layer_id = currSlice->layer_id;
fake->frame_num = fake->pic_num = picNumLX;
dec_pic = currSlice->p_Vid->dec_pic;
fake->poc = dec_pic->poc - (dec_pic->pic_num - picNumLX) * 2;
fake->used_for_reference = 1;
fake->mem_malloc_type = Mem_Fake;
#if 1 #if 1
fake->mem_mark = tmp->mem_mark; fake = alloc_storable_picture(currSlice->p_Vid, FRAME);
fake->mem_mark->top_used += 1; if (fake == NULL) {
fake->mem_mark->bot_used += 1; H264D_ERR("failed to alloc new dpb buffer.");
fake->mem_mark->pic = fake; return;
}
fake->frame_mbs_only_flag = 0;
//fs_top = fs->top_field = alloc_storable_picture(p_Vid, TOP_FIELD);
fake->is_long_term = 0;
fake->view_id = fake->view_id;
fake->layer_id = currSlice->layer_id;
fake->frame_num = fake->pic_num = picNumLX;
dec_pic = currSlice->p_Vid->dec_pic;
fake->poc = dec_pic->poc - (dec_pic->pic_num - picNumLX) * 2;
fake->used_for_reference = 1;
fake->mem_malloc_type = Mem_Fake;
fake->mem_mark = tmp->mem_mark;
fake->mem_mark->pic = fake;
fake->is_output = 1;
#else #else
fake->mem_mark = mpp_calloc(H264_DpbMark_t, 1); fake = clone_storable_picture(currSlice->p_Vid, tmp);
if (fake->mem_mark == NULL) { if (fake == NULL) {
H264D_ERR("failed to alloc a fake memory"); H264D_ERR("failed to alloc new dpb buffer.");
goto __FAILED; return;
} }
fake->mem_mark->top_used = 1; fake->is_long_term = 0;
fake->mem_mark->bot_used = 1; fake->view_id = fake->view_id;
fake->mem_mark->out_flag = 0; fake->layer_id = currSlice->layer_id;
fake->mem_mark->mark_idx = tmp->mem_mark->mark_idx; fake->frame_num = fake->pic_num = picNumLX;
fake->mem_mark->slot_idx = tmp->mem_mark->slot_idx; dec_pic = currSlice->p_Vid->dec_pic;
fake->mem_mark->mark_idx = tmp->mem_mark->mark_idx; fake->poc = dec_pic->poc - (dec_pic->pic_num - picNumLX) * 2;
fake->mem_mark->pts = tmp->mem_mark->pts; fake->used_for_reference = 1;
fake->mem_mark->mframe = tmp->mem_mark->mframe; fake->mem_malloc_type = Mem_Fake;
fake->mem_mark->poc = fake->poc; fake->mem_mark = tmp->mem_mark;
fake->mem_mark->pic = fake; fake->mem_mark->pic = fake;
store_picture_in_dpb(currSlice->p_Dpb, fake);
#endif #endif
mpp_log_f("p_Dpb->used_size=%d, p_Dpb->size=%d", currSlice->p_Dpb->used_size, currSlice->p_Dpb->size); #endif
store_picture_in_dpb(currSlice->p_Vid->p_Dpb_layer[currSlice->layer_id], fake); (void)currSlice;
return fake; (void)picNumLX;
__FAILED: (void)tmp;
if (fake) {
MPP_FREE(fake->mem_mark);
MPP_FREE(fake);
}
return NULL;
} }
#endif
static RK_U32 check_ref_pic_list(H264_SLICE_t *currSlice, RK_S32 cur_list) static RK_U32 check_ref_pic_list(H264_SLICE_t *currSlice, RK_S32 cur_list)
{ {
RK_S32 i = 0; RK_S32 i = 0;
RK_U32 dpb_error_flag = 0; RK_U32 dpb_error_flag = 0;
RK_S32 maxPicNum = 0, currPicNum = 0; RK_S32 maxPicNum = 0, currPicNum = 0;
RK_S32 picNumLXNoWrap = 0, picNumLXPred = 0, picNumLX = 0; RK_S32 picNumLXNoWrap = 0, picNumLXPred = 0, picNumLX = 0;
RK_U32 *modification_of_pic_nums_idc = currSlice->modification_of_pic_nums_idc[cur_list]; RK_U32 *modification_of_pic_nums_idc = currSlice->modification_of_pic_nums_idc[cur_list];
RK_U32 *abs_diff_pic_num_minus1 = currSlice->abs_diff_pic_num_minus1[cur_list]; RK_U32 *abs_diff_pic_num_minus1 = currSlice->abs_diff_pic_num_minus1[cur_list];
RK_U32 *long_term_pic_idx = currSlice->long_term_pic_idx[cur_list]; RK_U32 *long_term_pic_idx = currSlice->long_term_pic_idx[cur_list];
H264dVideoCtx_t *p_Vid = currSlice->p_Vid; H264dVideoCtx_t *p_Vid = currSlice->p_Vid;
if (currSlice->structure == FRAME) { if (currSlice->structure == FRAME) {
maxPicNum = p_Vid->max_frame_num; maxPicNum = p_Vid->max_frame_num;
currPicNum = currSlice->frame_num; currPicNum = currSlice->frame_num;
} else { } else {
maxPicNum = 2 * p_Vid->max_frame_num; maxPicNum = 2 * p_Vid->max_frame_num;
currPicNum = 2 * currSlice->frame_num + 1; currPicNum = 2 * currSlice->frame_num + 1;
} }
picNumLXPred = currPicNum; picNumLXPred = currPicNum;
for (i = 0; modification_of_pic_nums_idc[i] != 3; i++) { for (i = 0; modification_of_pic_nums_idc[i] != 3; i++) {
H264_StorePic_t *tmp = NULL; H264_StorePic_t *tmp = NULL;
if (modification_of_pic_nums_idc[i] > 3) if (modification_of_pic_nums_idc[i] > 3)
continue; continue;
if (modification_of_pic_nums_idc[i] < 2) { if (modification_of_pic_nums_idc[i] < 2) {
if (modification_of_pic_nums_idc[i] == 0) { if (modification_of_pic_nums_idc[i] == 0) {
if( (picNumLXPred - (RK_S32)(abs_diff_pic_num_minus1[i] + 1)) < 0) if ( (picNumLXPred - (RK_S32)(abs_diff_pic_num_minus1[i] + 1)) < 0)
picNumLXNoWrap = picNumLXPred - (abs_diff_pic_num_minus1[i] + 1) + maxPicNum; picNumLXNoWrap = picNumLXPred - (abs_diff_pic_num_minus1[i] + 1) + maxPicNum;
else else
picNumLXNoWrap = picNumLXPred - (abs_diff_pic_num_minus1[i] + 1); picNumLXNoWrap = picNumLXPred - (abs_diff_pic_num_minus1[i] + 1);
} else { // (modification_of_pic_nums_idc[i] == 1) } else { // (modification_of_pic_nums_idc[i] == 1)
if(picNumLXPred + (abs_diff_pic_num_minus1[i] + 1) >= (RK_U32)maxPicNum) if (picNumLXPred + (abs_diff_pic_num_minus1[i] + 1) >= (RK_U32)maxPicNum)
picNumLXNoWrap = picNumLXPred + (abs_diff_pic_num_minus1[i] + 1) - maxPicNum; picNumLXNoWrap = picNumLXPred + (abs_diff_pic_num_minus1[i] + 1) - maxPicNum;
else else
picNumLXNoWrap = picNumLXPred + (abs_diff_pic_num_minus1[i] + 1); picNumLXNoWrap = picNumLXPred + (abs_diff_pic_num_minus1[i] + 1);
} }
picNumLXPred = picNumLXNoWrap; picNumLXPred = picNumLXNoWrap;
picNumLX = (picNumLXNoWrap > currPicNum) ? (picNumLXNoWrap - maxPicNum) : picNumLXNoWrap; picNumLX = (picNumLXNoWrap > currPicNum) ? (picNumLXNoWrap - maxPicNum) : picNumLXNoWrap;
if (currSlice->field_pic_flag) { if (currSlice->field_pic_flag) {
picNumLX = (picNumLX - (picNumLX & 0x1)) >> 1; picNumLX = (picNumLX - (picNumLX & 0x1)) >> 1;
picNumLX = picNumLX < 0 ? (picNumLX + (maxPicNum >> 1)) : picNumLX; picNumLX = picNumLX < 0 ? (picNumLX + (maxPicNum >> 1)) : picNumLX;
} }
picNumLX = (picNumLX < 0) ? (picNumLX + maxPicNum) : picNumLX; picNumLX = (picNumLX < 0) ? (picNumLX + maxPicNum) : picNumLX;
#if 1 #if 1
if (get_short_term_pic(currSlice, picNumLX, &tmp)) { //!< find short reference if (get_short_term_pic(currSlice, picNumLX, &tmp)) { //!< find short reference
MppFrame mframe = NULL; MppFrame mframe = NULL;
mpp_buf_slot_get_prop(p_Vid->p_Dec->frame_slots, tmp->mem_mark->slot_idx, SLOT_FRAME_PTR, &mframe); mpp_buf_slot_get_prop(p_Vid->p_Dec->frame_slots, tmp->mem_mark->slot_idx, SLOT_FRAME_PTR, &mframe);
if (mpp_frame_get_errinfo(mframe)) { if (mpp_frame_get_errinfo(mframe)) {
dpb_error_flag |= 1; dpb_error_flag |= 1;
H264D_DBG(H264D_DBG_DPB_REF_ERR, "[DPB_REF_ERR] frame_no=%d, slot_idx=%d, dpb_err[%d]=%d", H264D_DBG(H264D_DBG_DPB_REF_ERR, "[DPB_REF_ERR] frame_no=%d, slot_idx=%d, dpb_err[%d]=%d",
p_Vid->p_Dec->p_Vid->g_framecnt, tmp->mem_mark->slot_idx, i, mpp_frame_get_errinfo(mframe)); p_Vid->p_Dec->p_Vid->g_framecnt, tmp->mem_mark->slot_idx, i, mpp_frame_get_errinfo(mframe));
} }
} else { //!< missing short reference, and fake a reference } else { //!< missing short reference, and fake a reference
H264D_DBG(H264D_DBG_DPB_REF_ERR, "[DPB_REF_ERR] missing short ref, structure=%d, pic_num=%d", H264D_DBG(H264D_DBG_DPB_REF_ERR, "[DPB_REF_ERR] missing short ref, structure=%d, pic_num=%d", currSlice->structure, picNumLX);
currSlice->structure, picNumLX); ASSERT(tmp != NULL);
ASSERT(tmp != NULL); if (tmp) {
if (tmp) { fake_short_term_pic(currSlice, picNumLX, tmp);
//fake_short_term_pic(currSlice, picNumLX, tmp); }
} dpb_error_flag |= 0;
dpb_error_flag |= 0; }
}
#endif #endif
} else { //(modification_of_pic_nums_idc[i] == 2) } else { //(modification_of_pic_nums_idc[i] == 2)
tmp = get_long_term_pic(currSlice, long_term_pic_idx[i]); tmp = get_long_term_pic(currSlice, long_term_pic_idx[i]);
} }
} }
return dpb_error_flag; return dpb_error_flag;
} }
static RK_U32 check_ref_dbp_err(H264_DecCtx_t *p_Dec, H264_RefPicInfo_t *pref) static RK_U32 check_ref_dbp_err(H264_DecCtx_t *p_Dec, H264_RefPicInfo_t *pref)
{ {
RK_U32 i = 0; RK_U32 i = 0;
RK_U32 dpb_error_flag = 0; RK_U32 dpb_error_flag = 0;
for (i = 0; i < MAX_REF_SIZE; i++) { for (i = 0; i < MAX_REF_SIZE; i++) {
if (pref[i].valid && (i < MAX_REF_SIZE)) { if (pref[i].valid) {
RK_U32 slot_idx = 0; RK_U32 slot_idx = 0;
MppFrame mframe = NULL; MppFrame mframe = NULL;
slot_idx = p_Dec->dpb_info[pref->dpb_idx].slot_index; slot_idx = p_Dec->dpb_info[pref->dpb_idx].slot_index;
mpp_buf_slot_get_prop(p_Dec->frame_slots, slot_idx, SLOT_FRAME_PTR, &mframe); mpp_buf_slot_get_prop(p_Dec->frame_slots, slot_idx, SLOT_FRAME_PTR, &mframe);
dpb_error_flag |= mpp_frame_get_errinfo(mframe); dpb_error_flag |= mpp_frame_get_errinfo(mframe);
H264D_DBG(H264D_DBG_DPB_REF_ERR, "[DPB_REF_ERR] frame_no=%d, slot_idx=%d, dpb_err[%d]=%d", H264D_DBG(H264D_DBG_DPB_REF_ERR, "[DPB_REF_ERR] frame_no=%d, slot_idx=%d, dpb_err[%d]=%d",
p_Dec->p_Vid->g_framecnt, p_Dec->dpb_info[i].slot_index, i, mpp_frame_get_errinfo(mframe)); p_Dec->p_Vid->g_framecnt, p_Dec->dpb_info[i].slot_index, i, mpp_frame_get_errinfo(mframe));
} }
} }
return dpb_error_flag; return dpb_error_flag;
} }
static void check_refer_lists(H264_SLICE_t *currSlice) static void check_refer_lists(H264_SLICE_t *currSlice)
{ {
H264_DecCtx_t *p_Dec = currSlice->p_Dec; H264_DecCtx_t *p_Dec = currSlice->p_Dec;
p_Dec->errctx.dpb_err_flag = 0; p_Dec->errctx.dpb_err_flag = 0;
if (I_SLICE == currSlice->slice_type) { if (I_SLICE == currSlice->slice_type) {
p_Dec->errctx.dpb_err_flag = 0; p_Dec->errctx.dpb_err_flag = 0;
goto __RETURN; goto __RETURN;
} }
#if 1 #if 1
if ((currSlice->slice_type % 5) != I_SLICE if ((currSlice->slice_type % 5) != I_SLICE
&& (currSlice->slice_type % 5) != SI_SLICE) { && (currSlice->slice_type % 5) != SI_SLICE) {
if (currSlice->ref_pic_list_reordering_flag[LIST_0]){ if (currSlice->ref_pic_list_reordering_flag[LIST_0]) {
p_Dec->errctx.dpb_err_flag |= check_ref_pic_list(currSlice, 0); p_Dec->errctx.dpb_err_flag |= check_ref_pic_list(currSlice, 0);
} } else {
else { p_Dec->errctx.dpb_err_flag |= check_ref_dbp_err(p_Dec, p_Dec->refpic_info_b[0]);
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->slice_type % 5 == B_SLICE) { if (currSlice->ref_pic_list_reordering_flag[LIST_1]) {
if (currSlice->ref_pic_list_reordering_flag[LIST_1]) { p_Dec->errctx.dpb_err_flag |= check_ref_pic_list(currSlice, 1);
p_Dec->errctx.dpb_err_flag |= check_ref_pic_list(currSlice, 1); } else {
} p_Dec->errctx.dpb_err_flag |= check_ref_dbp_err(p_Dec, p_Dec->refpic_info_b[1]);
else { }
p_Dec->errctx.dpb_err_flag |= check_ref_dbp_err(p_Dec, p_Dec->refpic_info_b[1]); }
}
}
#endif #endif
__RETURN: __RETURN:
free_ref_pic_list_reordering_buffer(currSlice); free_ref_pic_list_reordering_buffer(currSlice);
} }
MPP_RET init_picture(H264_SLICE_t *currSlice) MPP_RET init_picture(H264_SLICE_t *currSlice)
{ {
@@ -1414,14 +1408,14 @@ MPP_RET init_picture(H264_SLICE_t *currSlice)
H264_DecCtx_t *p_Dec = currSlice->p_Vid->p_Dec; H264_DecCtx_t *p_Dec = currSlice->p_Vid->p_Dec;
H264dVideoCtx_t *p_Vid = currSlice->p_Vid; H264dVideoCtx_t *p_Vid = currSlice->p_Vid;
p_Dec->errctx.i_slice_no += ((!currSlice->layer_id) && (I_SLICE == currSlice->slice_type)) ? 1 : 0; p_Dec->errctx.i_slice_no += ((!currSlice->layer_id) && (I_SLICE == currSlice->slice_type)) ? 1 : 0;
if (!p_Dec->errctx.i_slice_no) { if (!p_Dec->errctx.i_slice_no) {
H264D_WARNNING("[Discard] Discard slice before I Slice."); H264D_WARNNING("[Discard] Discard slice before I Slice.");
p_Dec->errctx.parse_err_flag |= VPU_FRAME_ERR_UNKNOW; p_Dec->errctx.parse_err_flag |= VPU_FRAME_ERR_UNKNOW;
ret = MPP_NOK; ret = MPP_NOK;
goto __FAILED; goto __FAILED;
} }
p_Dec->errctx.used_for_ref_flag = currSlice->nal_reference_idc ? 1 : 0; p_Dec->errctx.used_for_ref_flag = currSlice->nal_reference_idc ? 1 : 0;
FUN_CHECK(ret = alloc_decpic(currSlice)); FUN_CHECK(ret = alloc_decpic(currSlice));
//!< idr_memory_management MVC_layer, idr_flag==1 //!< idr_memory_management MVC_layer, idr_flag==1
if (currSlice->layer_id && !currSlice->svc_extension_flag && !currSlice->mvcExt.non_idr_flag) { if (currSlice->layer_id && !currSlice->svc_extension_flag && !currSlice->mvcExt.non_idr_flag) {
@@ -1438,7 +1432,7 @@ MPP_RET init_picture(H264_SLICE_t *currSlice)
} }
prepare_init_dpb_info(currSlice); prepare_init_dpb_info(currSlice);
prepare_init_ref_info(currSlice); prepare_init_ref_info(currSlice);
check_refer_lists(currSlice); check_refer_lists(currSlice);
prepare_init_scanlist(currSlice); prepare_init_scanlist(currSlice);
fill_picparams(currSlice->p_Vid, &p_Dec->dxva_ctx->pp); fill_picparams(currSlice->p_Vid, &p_Dec->dxva_ctx->pp);

View File

@@ -96,7 +96,7 @@ static void reset_slice(H264dVideoCtx_t *p_Vid)
currSlice->listXsizeP[i] = 0; currSlice->listXsizeP[i] = 0;
currSlice->listXsizeB[i] = 0; currSlice->listXsizeB[i] = 0;
} }
free_ref_pic_list_reordering_buffer(currSlice); free_ref_pic_list_reordering_buffer(currSlice);
FunctionOut(p_Vid->p_Dec->logctx.parr[RUN_PARSE]); FunctionOut(p_Vid->p_Dec->logctx.parr[RUN_PARSE]);
} }
@@ -158,13 +158,13 @@ static MPP_RET parser_nalu_header(H264_SLICE_t *currSlice)
LogInfo(p_bitctx->ctx, "================== NAL begin ==================="); LogInfo(p_bitctx->ctx, "================== NAL begin ===================");
READ_BITS(p_bitctx, 1, &cur_nal->forbidden_bit, "forbidden_bit"); READ_BITS(p_bitctx, 1, &cur_nal->forbidden_bit, "forbidden_bit");
ASSERT(cur_nal->forbidden_bit == 0); ASSERT(cur_nal->forbidden_bit == 0);
{ {
RK_S32 *ptmp = NULL; RK_S32 *ptmp = NULL;
ptmp = (RK_S32 *)&cur_nal->nal_reference_idc; ptmp = (RK_S32 *)&cur_nal->nal_reference_idc;
READ_BITS(p_bitctx, 2, ptmp, "nal_ref_idc"); READ_BITS(p_bitctx, 2, ptmp, "nal_ref_idc");
ptmp = (RK_S32 *)&cur_nal->nalu_type; ptmp = (RK_S32 *)&cur_nal->nalu_type;
READ_BITS(p_bitctx, 5, ptmp, "nalu_type"); READ_BITS(p_bitctx, 5, ptmp, "nalu_type");
} }
//if (g_nalu_cnt0 == 2384) { //if (g_nalu_cnt0 == 2384) {
// g_nalu_cnt0 = g_nalu_cnt0; // g_nalu_cnt0 = g_nalu_cnt0;
//} //}
@@ -232,10 +232,10 @@ static MPP_RET parser_one_nalu(H264_SLICE_t *currSlice)
} else { } else {
currSlice->p_Dec->nalu_ret = StartOfSlice; currSlice->p_Dec->nalu_ret = StartOfSlice;
} }
if (currSlice->layer_id && currSlice->p_Inp->mvc_disable) { if (currSlice->layer_id && currSlice->p_Inp->mvc_disable) {
currSlice->p_Dec->nalu_ret = MvcDisAble; currSlice->p_Dec->nalu_ret = MvcDisAble;
} }
H264D_DBG(H264D_DBG_PARSE_NALU, "nalu_type=SLICE."); H264D_DBG(H264D_DBG_PARSE_NALU, "nalu_type=SLICE.");
break; break;
case NALU_TYPE_SPS: case NALU_TYPE_SPS:
FUN_CHECK(ret = process_sps(currSlice)); FUN_CHECK(ret = process_sps(currSlice));
@@ -288,7 +288,7 @@ static MPP_RET parser_one_nalu(H264_SLICE_t *currSlice)
case NALU_TYPE_DPA: case NALU_TYPE_DPA:
case NALU_TYPE_DPB: case NALU_TYPE_DPB:
case NALU_TYPE_DPC: case NALU_TYPE_DPC:
H264D_DBG(H264D_DBG_PARSE_NALU, "Found NALU_TYPE_DPA DPB DPC, and not supported."); H264D_DBG(H264D_DBG_PARSE_NALU, "Found NALU_TYPE_DPA DPB DPC, and not supported.");
currSlice->p_Dec->nalu_ret = NaluNotSupport; currSlice->p_Dec->nalu_ret = NaluNotSupport;
break; break;
default: default:
@@ -348,9 +348,9 @@ static MPP_RET store_cur_nalu(H264dCurStream_t *p_strm, H264dDxvaCtx_t *dxva_ctx
add_size = MPP_MIN(HEAD_MAX_SIZE, p_strm->nalu_len); add_size = MPP_MIN(HEAD_MAX_SIZE, p_strm->nalu_len);
((H264dNaluHead_t *)p_des)->is_frame_end = 0; ((H264dNaluHead_t *)p_des)->is_frame_end = 0;
((H264dNaluHead_t *)p_des)->nalu_type = p_strm->nalu_type; ((H264dNaluHead_t *)p_des)->nalu_type = p_strm->nalu_type;
((H264dNaluHead_t *)p_des)->sodb_len = add_size; ((H264dNaluHead_t *)p_des)->sodb_len = add_size;
memcpy(p_des + sizeof(H264dNaluHead_t), p_strm->nalu_buf, add_size); memcpy(p_des + sizeof(H264dNaluHead_t), p_strm->nalu_buf, add_size);
p_strm->head_offset += add_size + sizeof(H264dNaluHead_t); p_strm->head_offset += add_size + sizeof(H264dNaluHead_t);
} }
//!< fill sodb buffer //!< fill sodb buffer
if ((p_strm->nalu_type == NALU_TYPE_SLICE) if ((p_strm->nalu_type == NALU_TYPE_SLICE)
@@ -359,7 +359,7 @@ static MPP_RET store_cur_nalu(H264dCurStream_t *p_strm, H264dDxvaCtx_t *dxva_ctx
if ((dxva_ctx->strm_offset + add_size) >= dxva_ctx->max_strm_size) { if ((dxva_ctx->strm_offset + add_size) >= dxva_ctx->max_strm_size) {
realloc_buffer(&dxva_ctx->bitstream, &dxva_ctx->max_strm_size, add_size); realloc_buffer(&dxva_ctx->bitstream, &dxva_ctx->max_strm_size, add_size);
} }
p_des = &dxva_ctx->bitstream[dxva_ctx->strm_offset]; p_des = &dxva_ctx->bitstream[dxva_ctx->strm_offset];
memcpy(p_des, g_start_precode, sizeof(g_start_precode)); memcpy(p_des, g_start_precode, sizeof(g_start_precode));
memcpy(p_des + sizeof(g_start_precode), p_strm->nalu_buf, p_strm->nalu_len); 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); dxva_ctx->strm_offset += p_strm->nalu_len + sizeof(g_start_precode);
@@ -413,7 +413,7 @@ static MPP_RET judge_is_new_frame(H264dCurCtx_t *p_Cur, H264dCurStream_t *p_strm
READ_BITS(p_bitctx, 2, &nal_reference_idc); READ_BITS(p_bitctx, 2, &nal_reference_idc);
READ_BITS(p_bitctx, 5, &p_strm->nalu_type); READ_BITS(p_bitctx, 5, &p_strm->nalu_type);
nalu_header_bytes = 1; nalu_header_bytes = 1;
if ((p_strm->nalu_type == NALU_TYPE_PREFIX) || (p_strm->nalu_type == NALU_TYPE_SLC_EXT)) { if ((p_strm->nalu_type == NALU_TYPE_PREFIX) || (p_strm->nalu_type == NALU_TYPE_SLC_EXT)) {
READ_BITS(p_bitctx, 1, &svc_extension_flag); READ_BITS(p_bitctx, 1, &svc_extension_flag);
if (svc_extension_flag) { if (svc_extension_flag) {
@@ -598,7 +598,7 @@ MPP_RET parse_prepare_fast(H264dInputCtx_t *p_Inp, H264dCurCtx_t *p_Cur)
//} //}
if (p_strm->nalu_type == NALU_TYPE_SLICE if (p_strm->nalu_type == NALU_TYPE_SLICE
|| p_strm->nalu_type == NALU_TYPE_IDR || p_strm->nalu_type == NALU_TYPE_SLC_EXT) { || p_strm->nalu_type == NALU_TYPE_IDR || p_strm->nalu_type == NALU_TYPE_SLC_EXT) {
p_strm->nalu_len += (RK_U32)pkt_impl->length; p_strm->nalu_len += (RK_U32)pkt_impl->length;
memcpy(&p_strm->nalu_buf[0], p_strm->curdata, pkt_impl->length + 1); memcpy(&p_strm->nalu_buf[0], p_strm->curdata, pkt_impl->length + 1);
pkt_impl->length = 0; pkt_impl->length = 0;
@@ -800,7 +800,7 @@ MPP_RET parse_prepare_extra_data(H264dInputCtx_t *p_Inp, H264dCurCtx_t *p_Cur)
p_strm->startcode_found = 1; p_strm->startcode_found = 1;
p_strm->endcode_found = 0; p_strm->endcode_found = 0;
p_strm->nalu_buf = NULL; p_strm->nalu_buf = NULL;
break; break;
} }
} }
@@ -843,7 +843,7 @@ MPP_RET parse_loop(H264_DecCtx_t *p_Dec)
RK_U8 while_loop_flag = 1; RK_U8 while_loop_flag = 1;
H264dNaluHead_t *p_head = NULL; H264dNaluHead_t *p_head = NULL;
INP_CHECK(ret, !p_Dec); INP_CHECK(ret, !p_Dec);
FunctionIn(p_Dec->logctx.parr[RUN_PARSE]); FunctionIn(p_Dec->logctx.parr[RUN_PARSE]);
//!< ==== loop ==== //!< ==== loop ====
p_curdata = p_Dec->p_Cur->strm.head_buf; p_curdata = p_Dec->p_Cur->strm.head_buf;
@@ -868,7 +868,7 @@ MPP_RET parse_loop(H264_DecCtx_t *p_Dec)
p_Dec->nalu_ret = EndOfNalu; p_Dec->nalu_ret = EndOfNalu;
p_Dec->next_state = SliceSTATE_ParseNalu; p_Dec->next_state = SliceSTATE_ParseNalu;
} }
H264D_DBG(H264D_DBG_LOOP_STATE, "SliceSTATE_ReadNalu"); H264D_DBG(H264D_DBG_LOOP_STATE, "SliceSTATE_ReadNalu");
break; break;
case SliceSTATE_ParseNalu: case SliceSTATE_ParseNalu:
(ret = parser_one_nalu(&p_Dec->p_Cur->slice)); (ret = parser_one_nalu(&p_Dec->p_Cur->slice));
@@ -877,30 +877,30 @@ MPP_RET parse_loop(H264_DecCtx_t *p_Dec)
} else if (p_Dec->nalu_ret == StartOfPicture) { } else if (p_Dec->nalu_ret == StartOfPicture) {
p_Dec->next_state = SliceSTATE_InitPicture; p_Dec->next_state = SliceSTATE_InitPicture;
} else if (p_Dec->nalu_ret == MvcDisAble) { } else if (p_Dec->nalu_ret == MvcDisAble) {
H264D_LOG("xxxxxxxx MVC disable"); H264D_LOG("xxxxxxxx MVC disable");
goto __FAILED; goto __FAILED;
} else { } else {
p_Dec->next_state = SliceSTATE_ReadNalu; p_Dec->next_state = SliceSTATE_ReadNalu;
} }
H264D_DBG(H264D_DBG_LOOP_STATE, "SliceSTATE_ParseNalu"); H264D_DBG(H264D_DBG_LOOP_STATE, "SliceSTATE_ParseNalu");
break; break;
case SliceSTATE_InitPicture: case SliceSTATE_InitPicture:
FUN_CHECK(ret = init_picture(&p_Dec->p_Cur->slice)); FUN_CHECK(ret = init_picture(&p_Dec->p_Cur->slice));
p_Dec->next_state = SliceSTATE_GetSliceData; p_Dec->next_state = SliceSTATE_GetSliceData;
H264D_DBG(H264D_DBG_LOOP_STATE, "SliceSTATE_InitPicture"); H264D_DBG(H264D_DBG_LOOP_STATE, "SliceSTATE_InitPicture");
break; break;
case SliceSTATE_GetSliceData: case SliceSTATE_GetSliceData:
FUN_CHECK(ret = fill_slice_syntax(&p_Dec->p_Cur->slice, p_Dec->dxva_ctx)); FUN_CHECK(ret = fill_slice_syntax(&p_Dec->p_Cur->slice, p_Dec->dxva_ctx));
p_Dec->p_Vid->iNumOfSlicesDecoded++; p_Dec->p_Vid->iNumOfSlicesDecoded++;
p_Dec->next_state = SliceSTATE_ResetSlice; p_Dec->next_state = SliceSTATE_ResetSlice;
H264D_DBG(H264D_DBG_LOOP_STATE, "SliceSTATE_GetSliceData"); H264D_DBG(H264D_DBG_LOOP_STATE, "SliceSTATE_GetSliceData");
break; break;
case SliceSTATE_RegisterOneFrame: case SliceSTATE_RegisterOneFrame:
commit_buffer(p_Dec->dxva_ctx); commit_buffer(p_Dec->dxva_ctx);
while_loop_flag = 0; while_loop_flag = 0;
p_Dec->is_parser_end = 1; p_Dec->is_parser_end = 1;
p_Dec->next_state = SliceSTATE_ReadNalu; p_Dec->next_state = SliceSTATE_ReadNalu;
H264D_DBG(H264D_DBG_LOOP_STATE, "SliceSTATE_RegisterOneFrame"); H264D_DBG(H264D_DBG_LOOP_STATE, "SliceSTATE_RegisterOneFrame");
break; break;
default: default:
ret = MPP_NOK; ret = MPP_NOK;
@@ -911,16 +911,16 @@ MPP_RET parse_loop(H264_DecCtx_t *p_Dec)
__RETURN: __RETURN:
return ret = MPP_OK; return ret = MPP_OK;
__FAILED: __FAILED:
p_Dec->nalu_ret = NALU_NULL; p_Dec->nalu_ret = NALU_NULL;
//p_Dec->is_first_frame = 1; //p_Dec->is_first_frame = 1;
//p_Dec->is_new_frame = 0; //p_Dec->is_new_frame = 0;
//p_Dec->is_parser_end = 0; //p_Dec->is_parser_end = 0;
p_Dec->next_state = SliceSTATE_ResetSlice; p_Dec->next_state = SliceSTATE_ResetSlice;
p_Dec->dxva_ctx->slice_count = 0; p_Dec->dxva_ctx->slice_count = 0;
p_Dec->dxva_ctx->strm_offset = 0; p_Dec->dxva_ctx->strm_offset = 0;
p_Dec->p_Vid->iNumOfSlicesDecoded = 0; p_Dec->p_Vid->iNumOfSlicesDecoded = 0;
p_Dec->p_Vid->exit_picture_flag = 0; p_Dec->p_Vid->exit_picture_flag = 0;
p_Dec->errctx.parse_err_flag |= VPU_FRAME_ERR_UNKNOW; p_Dec->errctx.parse_err_flag |= VPU_FRAME_ERR_UNKNOW;
return ret; return ret;
} }

View File

@@ -71,12 +71,12 @@ static MPP_RET parser_pps(BitReadCtx_t *p_bitctx, H264_SPS_t *cur_sps, H264_PPS_
READ_UE(p_bitctx, &cur_pps->pic_parameter_set_id, "pic_parameter_set_id"); READ_UE(p_bitctx, &cur_pps->pic_parameter_set_id, "pic_parameter_set_id");
READ_UE(p_bitctx, &cur_pps->seq_parameter_set_id, "seq_parameter_set_id"); READ_UE(p_bitctx, &cur_pps->seq_parameter_set_id, "seq_parameter_set_id");
//VAL_CHECK(ret, cur_pps->seq_parameter_set_id < 32); //VAL_CHECK(ret, cur_pps->seq_parameter_set_id < 32);
if (cur_pps->seq_parameter_set_id <0 || cur_pps->seq_parameter_set_id > 32) { if (cur_pps->seq_parameter_set_id < 0 || cur_pps->seq_parameter_set_id > 32) {
cur_pps->seq_parameter_set_id = 0; cur_pps->seq_parameter_set_id = 0;
} }
if (cur_pps->pic_parameter_set_id <0 || cur_pps->pic_parameter_set_id > 256) { if (cur_pps->pic_parameter_set_id < 0 || cur_pps->pic_parameter_set_id > 256) {
cur_pps->pic_parameter_set_id = 0; cur_pps->pic_parameter_set_id = 0;
} }
READ_ONEBIT(p_bitctx, &cur_pps->entropy_coding_mode_flag, "entropy_coding_mode_flag"); READ_ONEBIT(p_bitctx, &cur_pps->entropy_coding_mode_flag, "entropy_coding_mode_flag");
READ_ONEBIT(p_bitctx, &cur_pps->bottom_field_pic_order_in_frame_present_flag, "bottom_field_pic_order_in_frame_present_flag"); READ_ONEBIT(p_bitctx, &cur_pps->bottom_field_pic_order_in_frame_present_flag, "bottom_field_pic_order_in_frame_present_flag");
@@ -166,7 +166,7 @@ MPP_RET activate_pps(H264dVideoCtx_t *p_Vid, H264_PPS_t *pps)
{ {
MPP_RET ret = MPP_ERR_UNKNOW; MPP_RET ret = MPP_ERR_UNKNOW;
INP_CHECK(ret, !p_Vid && !pps); INP_CHECK(ret, !p_Vid && !pps);
if (p_Vid->active_pps != pps) { if (p_Vid->active_pps != pps) {
if (p_Vid->dec_pic) { if (p_Vid->dec_pic) {
//!< return if the last picture has already been finished //!< return if the last picture has already been finished

View File

@@ -79,7 +79,7 @@ static MPP_RET interpret_user_data_unregistered_info(RK_U8 *payload, RK_S32 size
goto __FAILED; goto __FAILED;
} }
return ret = MPP_OK; return ret = MPP_OK;
__FAILED: __FAILED:
return ret; return ret;
} }

View File

@@ -42,21 +42,21 @@ static MPP_RET ref_pic_list_mvc_modification(H264_SLICE_t *currSlice)
RK_U32 modification_of_pic_nums_idc = 0; RK_U32 modification_of_pic_nums_idc = 0;
BitReadCtx_t *p_bitctx = &currSlice->p_Cur->bitctx; BitReadCtx_t *p_bitctx = &currSlice->p_Cur->bitctx;
alloc_ref_pic_list_reordering_buffer(currSlice); alloc_ref_pic_list_reordering_buffer(currSlice);
if ((currSlice->slice_type % 5) != I_SLICE && (currSlice->slice_type % 5) != SI_SLICE) { if ((currSlice->slice_type % 5) != I_SLICE && (currSlice->slice_type % 5) != SI_SLICE) {
READ_ONEBIT(p_bitctx, &currSlice->ref_pic_list_reordering_flag[LIST_0], "ref_pic_list_reordering_flag"); READ_ONEBIT(p_bitctx, &currSlice->ref_pic_list_reordering_flag[LIST_0], "ref_pic_list_reordering_flag");
if (currSlice->ref_pic_list_reordering_flag[LIST_0]) { if (currSlice->ref_pic_list_reordering_flag[LIST_0]) {
i = 0; i = 0;
do { do {
READ_UE(p_bitctx, &modification_of_pic_nums_idc, "modification_of_pic_nums_idc"); READ_UE(p_bitctx, &modification_of_pic_nums_idc, "modification_of_pic_nums_idc");
currSlice->modification_of_pic_nums_idc[LIST_0][i] = modification_of_pic_nums_idc; currSlice->modification_of_pic_nums_idc[LIST_0][i] = modification_of_pic_nums_idc;
if (modification_of_pic_nums_idc == 0 || modification_of_pic_nums_idc == 1) { if (modification_of_pic_nums_idc == 0 || modification_of_pic_nums_idc == 1) {
READ_UE(p_bitctx, &currSlice->abs_diff_pic_num_minus1[LIST_0][i], "abs_diff_pic_num_minus1_lx"); READ_UE(p_bitctx, &currSlice->abs_diff_pic_num_minus1[LIST_0][i], "abs_diff_pic_num_minus1_lx");
} else { } else {
if (modification_of_pic_nums_idc == 2) { if (modification_of_pic_nums_idc == 2) {
READ_UE(p_bitctx, &currSlice->long_term_pic_idx[LIST_0][i], "long_term_pic_idx"); READ_UE(p_bitctx, &currSlice->long_term_pic_idx[LIST_0][i], "long_term_pic_idx");
} else if (modification_of_pic_nums_idc == 4 || modification_of_pic_nums_idc == 5) { } else if (modification_of_pic_nums_idc == 4 || modification_of_pic_nums_idc == 5) {
READ_UE(p_bitctx, &currSlice->abs_diff_view_idx_minus1[LIST_0][i], "abs_diff_view_idx_minus1"); READ_UE(p_bitctx, &currSlice->abs_diff_view_idx_minus1[LIST_0][i], "abs_diff_view_idx_minus1");
} }
} }
i++; i++;
@@ -69,14 +69,14 @@ static MPP_RET ref_pic_list_mvc_modification(H264_SLICE_t *currSlice)
i = 0; i = 0;
do { do {
READ_UE(p_bitctx, &modification_of_pic_nums_idc, "modification_of_pic_nums_idc"); READ_UE(p_bitctx, &modification_of_pic_nums_idc, "modification_of_pic_nums_idc");
currSlice->modification_of_pic_nums_idc[LIST_1][i] = modification_of_pic_nums_idc; currSlice->modification_of_pic_nums_idc[LIST_1][i] = modification_of_pic_nums_idc;
if (modification_of_pic_nums_idc == 0 || modification_of_pic_nums_idc == 1) { if (modification_of_pic_nums_idc == 0 || modification_of_pic_nums_idc == 1) {
READ_UE(p_bitctx, &currSlice->abs_diff_pic_num_minus1[LIST_1][i], "abs_diff_pic_num_minus1_lx"); READ_UE(p_bitctx, &currSlice->abs_diff_pic_num_minus1[LIST_1][i], "abs_diff_pic_num_minus1_lx");
} else { } else {
if (modification_of_pic_nums_idc == 2) { if (modification_of_pic_nums_idc == 2) {
READ_UE(p_bitctx, &currSlice->long_term_pic_idx[LIST_1][i], "long_term_pic_idx"); READ_UE(p_bitctx, &currSlice->long_term_pic_idx[LIST_1][i], "long_term_pic_idx");
} else if (modification_of_pic_nums_idc == 4 || modification_of_pic_nums_idc == 5) { } else if (modification_of_pic_nums_idc == 4 || modification_of_pic_nums_idc == 5) {
READ_UE(p_bitctx, &currSlice->abs_diff_view_idx_minus1[LIST_1][i], "abs_diff_view_idx_minus1"); READ_UE(p_bitctx, &currSlice->abs_diff_view_idx_minus1[LIST_1][i], "abs_diff_view_idx_minus1");
} }
} }
i++; i++;
@@ -233,68 +233,67 @@ static void init_slice_parmeters(H264_SLICE_t *currSlice)
static MPP_RET check_sps_pps(H264_SPS_t *sps, H264_subSPS_t *subset_sps, H264_PPS_t *pps) static MPP_RET check_sps_pps(H264_SPS_t *sps, H264_subSPS_t *subset_sps, H264_PPS_t *pps)
{ {
RK_U32 ret = 0; RK_U32 ret = 0;
ret |= (sps->seq_parameter_set_id > 63); ret |= (sps->seq_parameter_set_id > 63);
ret |= (sps->separate_colour_plane_flag == 1); ret |= (sps->separate_colour_plane_flag == 1);
ret |= (sps->chroma_format_idc == 3); ret |= (sps->chroma_format_idc == 3);
ret |= (sps->bit_depth_luma_minus8 > 2); ret |= (sps->bit_depth_luma_minus8 > 2);
ret |= (sps->bit_depth_chroma_minus8 > 2); ret |= (sps->bit_depth_chroma_minus8 > 2);
ret |= (sps->log2_max_frame_num_minus4 > 12); ret |= (sps->log2_max_frame_num_minus4 > 12);
ret |= (sps->pic_order_cnt_type > 2); ret |= (sps->pic_order_cnt_type > 2);
ret |= (sps->log2_max_pic_order_cnt_lsb_minus4 > 12); ret |= (sps->log2_max_pic_order_cnt_lsb_minus4 > 12);
ret |= (sps->num_ref_frames_in_pic_order_cnt_cycle > 255); ret |= (sps->num_ref_frames_in_pic_order_cnt_cycle > 255);
ret |= (sps->max_num_ref_frames > 16); ret |= (sps->max_num_ref_frames > 16);
ret |= (sps->pic_width_in_mbs_minus1 > 4095); ret |= (sps->pic_width_in_mbs_minus1 > 4095);
ret |= (sps->pic_height_in_map_units_minus1 > 2303); ret |= (sps->pic_height_in_map_units_minus1 > 2303);
ret |= (sps->pic_height_in_map_units_minus1 > 2303); ret |= (sps->pic_height_in_map_units_minus1 > 2303);
if (ret) { if (ret) {
H264D_ERR("sps has error, sps_id=%d", sps->seq_parameter_set_id); H264D_ERR("sps has error, sps_id=%d", sps->seq_parameter_set_id);
goto __FAILED; goto __FAILED;
} }
if (subset_sps) //!< MVC if (subset_sps) { //!< MVC
{ ret |= (subset_sps->num_views_minus1 != 1);
ret |= (subset_sps->num_views_minus1 != 1); // ret |= (subset_sps->num_anchor_refs_l0[0] != 1);
// ret |= (subset_sps->num_anchor_refs_l0[0] != 1); if (subset_sps->num_anchor_refs_l0[0] > 0)
if (subset_sps->num_anchor_refs_l0[0] > 0) ret |= (subset_sps->anchor_ref_l0[0][0] != subset_sps->view_id[0]);
ret |= (subset_sps->anchor_ref_l0[0][0] != subset_sps->view_id[0]); // ret |= (subset_sps->num_anchor_refs_l1[0] != 1);
// ret |= (subset_sps->num_anchor_refs_l1[0] != 1); if (subset_sps->num_anchor_refs_l1[0] > 0)
if (subset_sps->num_anchor_refs_l1[0] > 0) ret |= (subset_sps->anchor_ref_l1[0][0] != subset_sps->view_id[1]);
ret |= (subset_sps->anchor_ref_l1[0][0] != subset_sps->view_id[1]);
// ret |= (subset_sps->num_non_anchor_refs_l0[0] != 1); // ret |= (subset_sps->num_non_anchor_refs_l0[0] != 1);
if (subset_sps->num_non_anchor_refs_l0[0] > 0) if (subset_sps->num_non_anchor_refs_l0[0] > 0)
ret |= (subset_sps->non_anchor_ref_l0[0][0] != subset_sps->view_id[0]); ret |= (subset_sps->non_anchor_ref_l0[0][0] != subset_sps->view_id[0]);
// ret |= (subset_sps->num_non_anchor_refs_l1[0] != 1); // ret |= (subset_sps->num_non_anchor_refs_l1[0] != 1);
if (subset_sps->num_non_anchor_refs_l1[0] > 0) if (subset_sps->num_non_anchor_refs_l1[0] > 0)
ret |= (subset_sps->non_anchor_ref_l1[0][0] != subset_sps->view_id[1]); ret |= (subset_sps->non_anchor_ref_l1[0][0] != subset_sps->view_id[1]);
ret |= (subset_sps->num_level_values_signalled_minus1 != 0); ret |= (subset_sps->num_level_values_signalled_minus1 != 0);
//ret |= (subset_sps->num_applicable_ops_minus1[0] > 1); //ret |= (subset_sps->num_applicable_ops_minus1[0] > 1);
ret |= (subset_sps->applicable_op_num_target_views_minus1[0][0] > 1); ret |= (subset_sps->applicable_op_num_target_views_minus1[0][0] > 1);
ret |= (subset_sps->applicable_op_num_views_minus1[0][0] > 1); ret |= (subset_sps->applicable_op_num_views_minus1[0][0] > 1);
if (ret) { if (ret) {
H264D_ERR("subsps has error, sps_id=%d", sps->seq_parameter_set_id); H264D_ERR("subsps has error, sps_id=%d", sps->seq_parameter_set_id);
goto __FAILED; goto __FAILED;
} }
} }
//!< check PPS //!< check PPS
ret |= (pps->pic_parameter_set_id > 255); ret |= (pps->pic_parameter_set_id > 255);
ret |= (pps->seq_parameter_set_id > 63); ret |= (pps->seq_parameter_set_id > 63);
ret |= (pps->num_slice_groups_minus1 > 0); ret |= (pps->num_slice_groups_minus1 > 0);
ret |= (pps->num_ref_idx_l0_default_active_minus1 > 31); ret |= (pps->num_ref_idx_l0_default_active_minus1 > 31);
ret |= (pps->num_ref_idx_l1_default_active_minus1 > 31); ret |= (pps->num_ref_idx_l1_default_active_minus1 > 31);
ret |= (pps->pic_init_qp_minus26 > 25 || pps->pic_init_qp_minus26 < -(26 + 6 * (RK_S32)sps->bit_depth_luma_minus8)); ret |= (pps->pic_init_qp_minus26 > 25 || pps->pic_init_qp_minus26 < -(26 + 6 * (RK_S32)sps->bit_depth_luma_minus8));
ret |= (pps->pic_init_qs_minus26 > 25 || pps->pic_init_qs_minus26 < -26); ret |= (pps->pic_init_qs_minus26 > 25 || pps->pic_init_qs_minus26 < -26);
ret |= (pps->chroma_qp_index_offset > 12 || pps->chroma_qp_index_offset < -12); ret |= (pps->chroma_qp_index_offset > 12 || pps->chroma_qp_index_offset < -12);
ret |= (pps->redundant_pic_cnt_present_flag == 1); ret |= (pps->redundant_pic_cnt_present_flag == 1);
if (ret) { if (ret) {
H264D_ERR("pps has error, sps_id=%d, pps_id", sps->seq_parameter_set_id, pps->pic_parameter_set_id); H264D_ERR("pps has error, sps_id=%d, pps_id", sps->seq_parameter_set_id, pps->pic_parameter_set_id);
goto __FAILED; goto __FAILED;
} }
return MPP_OK; return MPP_OK;
__FAILED: __FAILED:
return MPP_NOK; return MPP_NOK;
} }
@@ -306,9 +305,9 @@ static MPP_RET set_slice_user_parmeters(H264_SLICE_t *currSlice)
H264_subSPS_t *cur_subsps = NULL; H264_subSPS_t *cur_subsps = NULL;
H264dVideoCtx_t *p_Vid = currSlice->p_Vid; H264dVideoCtx_t *p_Vid = currSlice->p_Vid;
//!< use parameter set //!< use parameter set
cur_pps = &p_Vid->ppsSet[currSlice->pic_parameter_set_id]; cur_pps = &p_Vid->ppsSet[currSlice->pic_parameter_set_id];
cur_pps = (cur_pps && cur_pps->Valid) ? cur_pps : NULL; cur_pps = (cur_pps && cur_pps->Valid) ? cur_pps : NULL;
VAL_CHECK(ret, cur_pps != NULL); VAL_CHECK(ret, cur_pps != NULL);
if (currSlice->mvcExt.valid) { if (currSlice->mvcExt.valid) {
cur_sps = &p_Vid->subspsSet[cur_pps->seq_parameter_set_id].sps; cur_sps = &p_Vid->subspsSet[cur_pps->seq_parameter_set_id].sps;
@@ -332,23 +331,23 @@ static MPP_RET set_slice_user_parmeters(H264_SLICE_t *currSlice)
cur_subsps = NULL; cur_subsps = NULL;
} }
if (p_Vid->active_mvc_sps_flag) { // layer_id == 1 if (p_Vid->active_mvc_sps_flag) { // layer_id == 1
cur_subsps = (cur_subsps && cur_subsps->Valid) ? cur_subsps : NULL; cur_subsps = (cur_subsps && cur_subsps->Valid) ? cur_subsps : NULL;
VAL_CHECK(ret, cur_subsps != NULL); VAL_CHECK(ret, cur_subsps != NULL);
cur_sps = &cur_subsps->sps; cur_sps = &cur_subsps->sps;
} else { //!< layer_id == 0 } else { //!< layer_id == 0
cur_subsps = NULL; cur_subsps = NULL;
cur_sps = (cur_sps && cur_sps->Valid) ? cur_sps : NULL; cur_sps = (cur_sps && cur_sps->Valid) ? cur_sps : NULL;
VAL_CHECK(ret, cur_sps != NULL); VAL_CHECK(ret, cur_sps != NULL);
} }
VAL_CHECK(ret, check_sps_pps(cur_sps, cur_subsps, cur_pps) != MPP_NOK); VAL_CHECK(ret, check_sps_pps(cur_sps, cur_subsps, cur_pps) != MPP_NOK);
H264D_DBG(H264D_DBG_PPS_SPS, "[SLICE_HEAD] layer_id=%d,sps_id=%d, pps_id=%d", currSlice->layer_id, H264D_DBG(H264D_DBG_PPS_SPS, "[SLICE_HEAD] layer_id=%d,sps_id=%d, pps_id=%d", currSlice->layer_id,
cur_sps->seq_parameter_set_id, cur_pps->pic_parameter_set_id); cur_sps->seq_parameter_set_id, cur_pps->pic_parameter_set_id);
FUN_CHECK(ret = activate_sps(p_Vid, cur_sps, cur_subsps)); FUN_CHECK(ret = activate_sps(p_Vid, cur_sps, cur_subsps));
FUN_CHECK(ret = activate_pps(p_Vid, cur_pps)); FUN_CHECK(ret = activate_pps(p_Vid, cur_pps));
//!< Set SPS to the subset SPS parameters //!< Set SPS to the subset SPS parameters
if (currSlice->svc_extension_flag == 0) { if (currSlice->svc_extension_flag == 0) {
p_Vid->active_subsps = &p_Vid->subspsSet[cur_pps->seq_parameter_set_id]; p_Vid->active_subsps = &p_Vid->subspsSet[cur_pps->seq_parameter_set_id];
@@ -377,46 +376,46 @@ void recycle_slice(H264_SLICE_t *currSlice)
} }
void free_ref_pic_list_reordering_buffer(H264_SLICE_t *currSlice) void free_ref_pic_list_reordering_buffer(H264_SLICE_t *currSlice)
{ {
if (currSlice) { if (currSlice) {
MPP_FREE(currSlice->modification_of_pic_nums_idc[LIST_0]); MPP_FREE(currSlice->modification_of_pic_nums_idc[LIST_0]);
MPP_FREE(currSlice->abs_diff_pic_num_minus1[LIST_0]); MPP_FREE(currSlice->abs_diff_pic_num_minus1[LIST_0]);
MPP_FREE(currSlice->long_term_pic_idx[LIST_0]); MPP_FREE(currSlice->long_term_pic_idx[LIST_0]);
MPP_FREE(currSlice->modification_of_pic_nums_idc[LIST_1]); MPP_FREE(currSlice->modification_of_pic_nums_idc[LIST_1]);
MPP_FREE(currSlice->abs_diff_pic_num_minus1[LIST_1]); MPP_FREE(currSlice->abs_diff_pic_num_minus1[LIST_1]);
MPP_FREE(currSlice->long_term_pic_idx[LIST_1]); MPP_FREE(currSlice->long_term_pic_idx[LIST_1]);
MPP_FREE(currSlice->abs_diff_view_idx_minus1[LIST_0]); MPP_FREE(currSlice->abs_diff_view_idx_minus1[LIST_0]);
MPP_FREE(currSlice->abs_diff_view_idx_minus1[LIST_1]); MPP_FREE(currSlice->abs_diff_view_idx_minus1[LIST_1]);
} }
} }
MPP_RET alloc_ref_pic_list_reordering_buffer(H264_SLICE_t *currSlice) MPP_RET alloc_ref_pic_list_reordering_buffer(H264_SLICE_t *currSlice)
{ {
MPP_RET ret = MPP_ERR_UNKNOW; MPP_RET ret = MPP_ERR_UNKNOW;
currSlice->modification_of_pic_nums_idc[LIST_0] = NULL; currSlice->modification_of_pic_nums_idc[LIST_0] = NULL;
currSlice->abs_diff_pic_num_minus1[LIST_0] = NULL; currSlice->abs_diff_pic_num_minus1[LIST_0] = NULL;
currSlice->long_term_pic_idx[LIST_0] = NULL; currSlice->long_term_pic_idx[LIST_0] = NULL;
currSlice->abs_diff_view_idx_minus1[LIST_0] = NULL; currSlice->abs_diff_view_idx_minus1[LIST_0] = NULL;
if (currSlice->slice_type != I_SLICE && currSlice->slice_type != SI_SLICE) { if (currSlice->slice_type != I_SLICE && currSlice->slice_type != SI_SLICE) {
RK_U32 size = currSlice->num_ref_idx_active[LIST_0] + 1; RK_U32 size = currSlice->num_ref_idx_active[LIST_0] + 1;
MEM_CHECK(ret, currSlice->modification_of_pic_nums_idc[LIST_0] = mpp_calloc(RK_U32, size)); MEM_CHECK(ret, currSlice->modification_of_pic_nums_idc[LIST_0] = mpp_calloc(RK_U32, size));
MEM_CHECK(ret, currSlice->abs_diff_pic_num_minus1[LIST_0] = mpp_calloc(RK_U32, size)); MEM_CHECK(ret, currSlice->abs_diff_pic_num_minus1[LIST_0] = mpp_calloc(RK_U32, size));
MEM_CHECK(ret, currSlice->long_term_pic_idx[LIST_0] = mpp_calloc(RK_U32, size)); MEM_CHECK(ret, currSlice->long_term_pic_idx[LIST_0] = mpp_calloc(RK_U32, size));
MEM_CHECK(ret, currSlice->abs_diff_view_idx_minus1[LIST_0] = mpp_calloc(RK_U32, size)); MEM_CHECK(ret, currSlice->abs_diff_view_idx_minus1[LIST_0] = mpp_calloc(RK_U32, size));
} }
currSlice->modification_of_pic_nums_idc[LIST_1] = NULL; currSlice->modification_of_pic_nums_idc[LIST_1] = NULL;
currSlice->abs_diff_pic_num_minus1[LIST_1] = NULL; currSlice->abs_diff_pic_num_minus1[LIST_1] = NULL;
currSlice->long_term_pic_idx[LIST_1] = NULL; currSlice->long_term_pic_idx[LIST_1] = NULL;
currSlice->abs_diff_view_idx_minus1[LIST_1] = NULL; currSlice->abs_diff_view_idx_minus1[LIST_1] = NULL;
if (currSlice->slice_type == B_SLICE) { if (currSlice->slice_type == B_SLICE) {
RK_U32 size = currSlice->num_ref_idx_active[LIST_1] + 1; RK_U32 size = currSlice->num_ref_idx_active[LIST_1] + 1;
MEM_CHECK(ret, currSlice->modification_of_pic_nums_idc[LIST_1] = mpp_calloc(RK_U32, size)); MEM_CHECK(ret, currSlice->modification_of_pic_nums_idc[LIST_1] = mpp_calloc(RK_U32, size));
MEM_CHECK(ret, currSlice->abs_diff_pic_num_minus1[LIST_1] = mpp_calloc(RK_U32, size)); MEM_CHECK(ret, currSlice->abs_diff_pic_num_minus1[LIST_1] = mpp_calloc(RK_U32, size));
MEM_CHECK(ret, currSlice->long_term_pic_idx[LIST_1] = mpp_calloc(RK_U32, size)); MEM_CHECK(ret, currSlice->long_term_pic_idx[LIST_1] = mpp_calloc(RK_U32, size));
MEM_CHECK(ret, currSlice->abs_diff_view_idx_minus1[LIST_1] = mpp_calloc(RK_U32, size)); MEM_CHECK(ret, currSlice->abs_diff_view_idx_minus1[LIST_1] = mpp_calloc(RK_U32, size));
} }
return ret = MPP_OK; return ret = MPP_OK;
__FAILED: __FAILED:
free_ref_pic_list_reordering_buffer(currSlice); free_ref_pic_list_reordering_buffer(currSlice);
return ret; return ret;
} }
/*! /*!
*********************************************************************** ***********************************************************************

View File

@@ -170,9 +170,9 @@ static MPP_RET parser_sps(BitReadCtx_t *p_bitctx, H264_SPS_t *cur_sps, H264_DecC
ASSERT(temp == 0); ASSERT(temp == 0);
READ_BITS(p_bitctx, 8, &cur_sps->level_idc, "level_idc"); READ_BITS(p_bitctx, 8, &cur_sps->level_idc, "level_idc");
READ_UE(p_bitctx, &cur_sps->seq_parameter_set_id, "seq_parameter_set_id"); READ_UE(p_bitctx, &cur_sps->seq_parameter_set_id, "seq_parameter_set_id");
if (cur_sps->seq_parameter_set_id <0 || cur_sps->seq_parameter_set_id > 32) { if (cur_sps->seq_parameter_set_id < 0 || cur_sps->seq_parameter_set_id > 32) {
cur_sps->seq_parameter_set_id = 0; cur_sps->seq_parameter_set_id = 0;
} }
if (cur_sps->profile_idc == 100 || cur_sps->profile_idc == 110 if (cur_sps->profile_idc == 100 || cur_sps->profile_idc == 110
|| cur_sps->profile_idc == 122 || cur_sps->profile_idc == 244 || cur_sps->profile_idc == 122 || cur_sps->profile_idc == 244
|| cur_sps->profile_idc == 44 || cur_sps->profile_idc == 83 || cur_sps->profile_idc == 44 || cur_sps->profile_idc == 83
@@ -247,7 +247,7 @@ static MPP_RET parser_sps(BitReadCtx_t *p_bitctx, H264_SPS_t *cur_sps, H264_DecC
FUN_CHECK(ret = read_VUI(p_bitctx, &cur_sps->vui_seq_parameters)); FUN_CHECK(ret = read_VUI(p_bitctx, &cur_sps->vui_seq_parameters));
} }
cur_sps->Valid = 1; cur_sps->Valid = 1;
(void)p_Dec; (void)p_Dec;
return ret = MPP_OK; return ret = MPP_OK;
__BITREAD_ERR: __BITREAD_ERR:
@@ -533,7 +533,7 @@ __FAILED:
MPP_RET activate_sps(H264dVideoCtx_t *p_Vid, H264_SPS_t *sps, H264_subSPS_t *subset_sps) MPP_RET activate_sps(H264dVideoCtx_t *p_Vid, H264_SPS_t *sps, H264_subSPS_t *subset_sps)
{ {
MPP_RET ret = MPP_ERR_UNKNOW; MPP_RET ret = MPP_ERR_UNKNOW;
INP_CHECK(ret, !p_Vid && !sps && !subset_sps); INP_CHECK(ret, !p_Vid && !sps && !subset_sps);
if (p_Vid->dec_pic) { if (p_Vid->dec_pic) {
FUN_CHECK(ret = exit_picture(p_Vid, &p_Vid->dec_pic)); FUN_CHECK(ret = exit_picture(p_Vid, &p_Vid->dec_pic));
} }
@@ -542,7 +542,7 @@ MPP_RET activate_sps(H264dVideoCtx_t *p_Vid, H264_SPS_t *sps, H264_subSPS_t *sub
p_Vid->active_subsps = subset_sps; p_Vid->active_subsps = subset_sps;
p_Vid->active_sps_id[0] = 0; p_Vid->active_sps_id[0] = 0;
p_Vid->active_sps_id[1] = subset_sps->sps.seq_parameter_set_id; p_Vid->active_sps_id[1] = subset_sps->sps.seq_parameter_set_id;
VAL_CHECK(ret, subset_sps->sps.seq_parameter_set_id >= 0); VAL_CHECK(ret, subset_sps->sps.seq_parameter_set_id >= 0);
if (video_pars_changed(p_Vid, p_Vid->active_sps, 1)) { if (video_pars_changed(p_Vid, p_Vid->active_sps, 1)) {
FUN_CHECK(ret = flush_dpb(p_Vid->p_Dpb_layer[1], 2)); FUN_CHECK(ret = flush_dpb(p_Vid->p_Dpb_layer[1], 2));
FUN_CHECK(ret = init_dpb(p_Vid, p_Vid->p_Dpb_layer[1], 2)); FUN_CHECK(ret = init_dpb(p_Vid, p_Vid->p_Dpb_layer[1], 2));
@@ -550,11 +550,11 @@ MPP_RET activate_sps(H264dVideoCtx_t *p_Vid, H264_SPS_t *sps, H264_subSPS_t *sub
//!< init frame slots, store frame buffer size //!< init frame slots, store frame buffer size
p_Vid->dpb_size[1] = p_Vid->p_Dpb_layer[1]->size; p_Vid->dpb_size[1] = p_Vid->p_Dpb_layer[1]->size;
} }
VAL_CHECK(ret, p_Vid->dpb_size[1] > 0); VAL_CHECK(ret, p_Vid->dpb_size[1] > 0);
} else { //!< layer_id == 0 } else { //!< layer_id == 0
p_Vid->active_sps = sps; p_Vid->active_sps = sps;
p_Vid->active_subsps = NULL; p_Vid->active_subsps = NULL;
VAL_CHECK(ret, sps->seq_parameter_set_id >= 0); VAL_CHECK(ret, sps->seq_parameter_set_id >= 0);
p_Vid->active_sps_id[0] = sps->seq_parameter_set_id; p_Vid->active_sps_id[0] = sps->seq_parameter_set_id;
p_Vid->active_sps_id[1] = 0; p_Vid->active_sps_id[1] = 0;
if (video_pars_changed(p_Vid, p_Vid->active_sps, 0)) { if (video_pars_changed(p_Vid, p_Vid->active_sps, 0)) {
@@ -566,10 +566,10 @@ MPP_RET activate_sps(H264dVideoCtx_t *p_Vid, H264_SPS_t *sps, H264_subSPS_t *sub
//!< init frame slots, store frame buffer size //!< init frame slots, store frame buffer size
p_Vid->dpb_size[0] = p_Vid->p_Dpb_layer[0]->size; p_Vid->dpb_size[0] = p_Vid->p_Dpb_layer[0]->size;
} }
VAL_CHECK(ret, p_Vid->dpb_size[0] > 0); VAL_CHECK(ret, p_Vid->dpb_size[0] > 0);
} }
H264D_DBG(H264D_DBG_DPB_INFO, "[DPB size] dpb_size[0]=%d, mvc_flag=%d, dpb_size[1]=%d", H264D_DBG(H264D_DBG_DPB_INFO, "[DPB size] dpb_size[0]=%d, mvc_flag=%d, dpb_size[1]=%d",
p_Vid->dpb_size[0], p_Vid->active_mvc_sps_flag, p_Vid->dpb_size[1]); p_Vid->dpb_size[0], p_Vid->active_mvc_sps_flag, p_Vid->dpb_size[1]);
update_video_pars(p_Vid, p_Vid->active_sps); update_video_pars(p_Vid, p_Vid->active_sps);
__RETURN: __RETURN:
return ret = MPP_OK; return ret = MPP_OK;

View File

@@ -2036,9 +2036,9 @@ MPP_RET h265d_callback(void *ctx, void *err_info)
H265dContext_t *h265dctx = (H265dContext_t *)ctx; H265dContext_t *h265dctx = (H265dContext_t *)ctx;
HEVCContext *s = (HEVCContext *)h265dctx->priv_data; HEVCContext *s = (HEVCContext *)h265dctx->priv_data;
RK_U32 i = 0; RK_U32 i = 0;
if(s->first_nal_type >= 16 && s->first_nal_type <= 23){ if (s->first_nal_type >= 16 && s->first_nal_type <= 23) {
mpp_log("IS_IRAP frame found error"); mpp_log("IS_IRAP frame found error");
s->max_ra = INT_MAX; s->max_ra = INT_MAX;
} }
// s->miss_ref_flag = 1; // s->miss_ref_flag = 1;
mpp_buf_slot_get_prop(s->slots, s->ref->slot_index, SLOT_FRAME, &s->ref->frame); mpp_buf_slot_get_prop(s->slots, s->ref->slot_index, SLOT_FRAME, &s->ref->frame);

View File

@@ -535,7 +535,7 @@ RK_S32 hevc_parser_test(ParserDemoCmdContext_t *cmd)
mpp_buf_slot_get_prop(slots, index, SLOT_FRAME, &frame); mpp_buf_slot_get_prop(slots, index, SLOT_FRAME, &frame);
if (frame) { if (frame) {
mpp_frame_deinit(&frame); mpp_frame_deinit(&frame);
frame = NULL; frame = NULL;
} }
mpp_buf_slot_clr_flag(slots, index, SLOT_QUEUE_USE); mpp_buf_slot_clr_flag(slots, index, SLOT_QUEUE_USE);
} }

View File

@@ -584,8 +584,8 @@ static RK_S32 read_colorspace_details(Vp9CodecContext *ctx)
if (ctx->colorspace == MPP_FRAME_SPC_RGB) { // RGB = profile 1 if (ctx->colorspace == MPP_FRAME_SPC_RGB) { // RGB = profile 1
#if 0 #if 0
static const enum AVPixelFormat pix_fmt_rgb[3] = { static const enum AVPixelFormat pix_fmt_rgb[3] = {
AV_PIX_FMT_GBRP, AV_PIX_FMT_GBRP10, AV_PIX_FMT_GBRP12 AV_PIX_FMT_GBRP, AV_PIX_FMT_GBRP10, AV_PIX_FMT_GBRP12
}; };
if (ctx->profile & 1) { if (ctx->profile & 1) {
s->ss_h = s->ss_v = 1; s->ss_h = s->ss_v = 1;
res = pix_fmt_rgb[bits]; res = pix_fmt_rgb[bits];
@@ -827,12 +827,12 @@ static RK_S32 decode_parser_header(Vp9CodecContext *ctx,
} }
} }
for (i = 0; i < 3; i++) { for (i = 0; i < 3; i++) {
RK_U32 refw = mpp_frame_get_width(s->refs[s->refidx[i]].f); RK_U32 refw = mpp_frame_get_width(s->refs[s->refidx[i]].f);
RK_U32 refh = mpp_frame_get_height(s->refs[s->refidx[i]].f); RK_U32 refh = mpp_frame_get_height(s->refs[s->refidx[i]].f);
RK_S32 reffmt = mpp_frame_get_fmt(s->refs[s->refidx[i]].f); RK_S32 reffmt = mpp_frame_get_fmt(s->refs[s->refidx[i]].f);
vp9d_dbg(VP9D_DBG_REF, "ref get width frame slot %p", s->refs[s->refidx[i]].f); vp9d_dbg(VP9D_DBG_REF, "ref get width frame slot %p", s->refs[s->refidx[i]].f);
if (reffmt != fmt) { if (reffmt != fmt) {
/* mpp_err("Ref pixfmt (%s) did not match current frame (%s)", /* mpp_err("Ref pixfmt (%s) did not match current frame (%s)",
av_get_pix_fmt_name(ref->format), av_get_pix_fmt_name(ref->format),

View File

@@ -23,7 +23,7 @@
(*b) += bytes;\ (*b) += bytes;\
return read(*b - bytes);\ return read(*b - bytes);\
}\ }\
DEF(be24, 3, MPP_RB24, MPP_WB24) DEF(be24, 3, MPP_RB24, MPP_WB24)
DEF(be16, 2, MPP_RB16, MPP_WB16) DEF(be16, 2, MPP_RB16, MPP_WB16)

View File

@@ -839,7 +839,7 @@ MPP_RET mpp_buf_slot_get_prop(MppBufSlots slots, RK_S32 index, SlotPropType type
mpp_assert(slot->status.has_frame); mpp_assert(slot->status.has_frame);
if (slot->status.has_frame) { if (slot->status.has_frame) {
if (NULL == *frame ) if (NULL == *frame )
mpp_frame_init(frame); mpp_frame_init(frame);
if (*frame) if (*frame)
mpp_frame_copy(*frame, slot->frame); mpp_frame_copy(*frame, slot->frame);
} else } else
@@ -892,10 +892,10 @@ MPP_RET mpp_slots_set_prop(MppBufSlots slots, SlotsPropType type, void *val)
// do info change detection here // do info change detection here
generate_info_set(impl, (MppFrame)val, 1); generate_info_set(impl, (MppFrame)val, 1);
mpp_frame_copy(impl->info, impl->info_set); mpp_frame_copy(impl->info, impl->info_set);
{ {
MppFrameImpl *p = (MppFrameImpl *)impl->info; MppFrameImpl *p = (MppFrameImpl *)impl->info;
mpp_log_f("had set frame info: w %4d h %4d hor %4d ver %4d\n", p->width, p->height, p->hor_stride, p->ver_stride); mpp_log_f("had set frame info: w %4d h %4d hor %4d ver %4d\n", p->width, p->height, p->hor_stride, p->ver_stride);
} }
impl->buf_size = mpp_frame_get_buf_size(impl->info); impl->buf_size = mpp_frame_get_buf_size(impl->info);
} break; } break;
default : { default : {

View File

@@ -59,33 +59,33 @@ extern RK_U32 rkv_h264d_hal_debug;
#define H264D_DBG(level, fmt, ...)\ #define H264D_DBG(level, fmt, ...)\
do {\ do {\
if (level & rkv_h264d_parse_debug)\ if (level & rkv_h264d_parse_debug)\
{ mpp_log(fmt, ## __VA_ARGS__);}\ { mpp_log(fmt, ## __VA_ARGS__);}\
} while (0) } while (0)
#define H264D_ERR(fmt, ...)\ #define H264D_ERR(fmt, ...)\
do {\ do {\
if (H264D_DBG_ERROR & rkv_h264d_parse_debug)\ if (H264D_DBG_ERROR & rkv_h264d_parse_debug)\
{ mpp_err(fmt, ## __VA_ARGS__); }\ { mpp_err(fmt, ## __VA_ARGS__); }\
} while (0) } while (0)
#define ASSERT(val)\ #define ASSERT(val)\
do {\ do {\
if (H264D_DBG_ASSERT & rkv_h264d_parse_debug)\ if (H264D_DBG_ASSERT & rkv_h264d_parse_debug)\
{ mpp_assert(val); }\ { mpp_assert(val); }\
} while (0) } while (0)
#define H264D_WARNNING(fmt, ...)\ #define H264D_WARNNING(fmt, ...)\
do {\ do {\
if (H264D_DBG_WARNNING & rkv_h264d_parse_debug)\ if (H264D_DBG_WARNNING & rkv_h264d_parse_debug)\
{ mpp_log(fmt, ## __VA_ARGS__); }\ { mpp_log(fmt, ## __VA_ARGS__); }\
} while (0) } while (0)
#define H264D_LOG(fmt, ...)\ #define H264D_LOG(fmt, ...)\
do {\ do {\
if (H264D_DBG_LOG & rkv_h264d_parse_debug)\ if (H264D_DBG_LOG & rkv_h264d_parse_debug)\
{ mpp_log(fmt, ## __VA_ARGS__); }\ { mpp_log(fmt, ## __VA_ARGS__); }\
} while (0) } while (0)

View File

@@ -96,8 +96,8 @@ typedef struct HalDecTask_t {
// previous task hardware working status // previous task hardware working status
// when hardware error happen status is not zero // when hardware error happen status is not zero
RK_U32 prev_status; RK_U32 prev_status;
RK_U32 dpb_err_flag; RK_U32 dpb_err_flag;
RK_U32 used_for_ref_flag; RK_U32 used_for_ref_flag;
// current tesk protocol syntax information // current tesk protocol syntax information
MppSyntax syntax; MppSyntax syntax;

View File

@@ -230,9 +230,9 @@ MPP_RET hal_h264d_init(void *hal, MppHalCfg *cfg)
default: default:
break; break;
} }
//!< callback function to parser module //!< callback function to parser module
p_hal->init_cb = cfg->hal_int_cb; p_hal->init_cb = cfg->hal_int_cb;
mpp_env_get_u32("rkv_h264d_debug", &rkv_h264d_hal_debug, 0); mpp_env_get_u32("rkv_h264d_debug", &rkv_h264d_hal_debug, 0);
//!< init logctx //!< init logctx
FUN_CHECK(ret = logctx_init(&p_hal->logctx, p_hal->logctxbuf)); FUN_CHECK(ret = logctx_init(&p_hal->logctx, p_hal->logctxbuf));
//!< VPUClientInit //!< VPUClientInit

View File

@@ -32,7 +32,7 @@ typedef struct h264d_hal_ctx_t {
MppHalApi hal_api; MppHalApi hal_api;
void *regs; void *regs;
void *pkts; void *pkts;
void *dump; void *dump;
RK_U8 spt_BitstrmRaw; RK_U8 spt_BitstrmRaw;
RK_U8 set_BitstrmRaw; RK_U8 set_BitstrmRaw;
@@ -55,7 +55,7 @@ typedef struct h264d_hal_ctx_t {
RK_S32 vpu_socket; RK_S32 vpu_socket;
RK_U64 total_time; RK_U64 total_time;
RK_U64 iDecodedNum; RK_U64 iDecodedNum;
IOInterruptCB init_cb; IOInterruptCB init_cb;
} H264dHalCtx_t; } H264dHalCtx_t;

View File

@@ -137,7 +137,6 @@ static void rkv_write_pps_to_fifo(H264dHalCtx_t *p_hal, FifoCtx_t *pkt)
} else { } else {
Scaleing_list_address += offset; Scaleing_list_address += offset;
} }
//mpp_log("Scaleing_list_address=%08x \n", Scaleing_list_address);
#if FPGA_TEST #if FPGA_TEST
fifo_write_bits(pkt, 0, 32, "Scaleing_list_address"); fifo_write_bits(pkt, 0, 32, "Scaleing_list_address");
#else #else
@@ -361,22 +360,26 @@ void rkv_prepare_scanlist_packet(void *hal, FifoCtx_t *pkt)
//extern "C" //extern "C"
void rkv_generate_regs(void *hal, HalTaskInfo *task, FifoCtx_t *pkt) void rkv_generate_regs(void *hal, HalTaskInfo *task, FifoCtx_t *pkt)
{ {
RK_S32 i = 0; H264dHalCtx_t *p_hal = (H264dHalCtx_t *)hal;
MppBuffer frame_buf = NULL;
MppBuffer bitstream_buf = NULL;
H264dHalCtx_t *p_hal = (H264dHalCtx_t *)hal;
DXVA_PicParams_H264_MVC *pp = p_hal->pp; DXVA_PicParams_H264_MVC *pp = p_hal->pp;
H264dRkvRegs_t *p_regs = (H264dRkvRegs_t *)p_hal->regs; H264dRkvRegs_t *p_regs = (H264dRkvRegs_t *)p_hal->regs;
FunctionIn(p_hal->logctx.parr[RUN_HAL]); FunctionIn(p_hal->logctx.parr[RUN_HAL]);
memset(p_regs, 0, sizeof(H264dRkvRegs_t)); memset(p_regs, 0, sizeof(H264dRkvRegs_t));
p_regs->swreg2_sysctrl.sw_dec_mode = 1; //!< h264 //!< set dec_mode && rlc_mode && rps_mode && slice_num
{
if (p_regs->swreg2_sysctrl.sw_rlc_mode == 1) { p_regs->swreg2_sysctrl.sw_dec_mode = 1; //!< h264
p_regs->swreg5_stream_rlc_len.sw_stream_len = 0; if (p_regs->swreg2_sysctrl.sw_rlc_mode == 1) {
} else { p_regs->swreg5_stream_rlc_len.sw_stream_len = 0;
p_regs->swreg5_stream_rlc_len.sw_stream_len = (RK_U32)mpp_packet_get_length(task->dec.input_packet); } else {
p_regs->swreg5_stream_rlc_len.sw_stream_len = (RK_U32)mpp_packet_get_length(task->dec.input_packet);
}
if (p_regs->swreg2_sysctrl.sw_h264_rps_mode) { // rps_mode == 1
p_regs->swreg43_rps_base.sw_rps_base += 0x8;
}
p_regs->swreg3_picpar.sw_slice_num_lowbits = 0x7ff; // p_Vid->iNumOfSlicesDecoded & 0x7ff
p_regs->swreg3_picpar.sw_slice_num_highbit = 1; // (p_Vid->iNumOfSlicesDecoded >> 11) & 1
} }
//!< caculate the yuv_frame_size //!< caculate the yuv_frame_size
{ {
@@ -398,97 +401,103 @@ void rkv_generate_regs(void *hal, HalTaskInfo *task, FifoCtx_t *pkt)
} else if (pp->chroma_format_idc == 2) { //!< Y422 } else if (pp->chroma_format_idc == 2) { //!< Y422
yuv_virstride += 2 * y_virstride; yuv_virstride += 2 * y_virstride;
} }
p_regs->swreg3_picpar.sw_y_hor_virstride = hor_virstride / 16; p_regs->swreg3_picpar.sw_y_hor_virstride = hor_virstride / 16;
p_regs->swreg3_picpar.sw_uv_hor_virstride = hor_virstride / 16; p_regs->swreg3_picpar.sw_uv_hor_virstride = hor_virstride / 16;
p_regs->swreg8_y_virstride.sw_y_virstride = y_virstride / 16; p_regs->swreg8_y_virstride.sw_y_virstride = y_virstride / 16;
p_regs->swreg9_yuv_virstride.sw_yuv_virstride = yuv_virstride / 16; p_regs->swreg9_yuv_virstride.sw_yuv_virstride = yuv_virstride / 16;
//mpp_log("$$$$$$$$ hor_stride=%d, y_stride=%d, yuv_stride=%d \n", p_regs->swreg3_picpar.sw_y_hor_virstride,
// p_regs->swreg8_y_virstride.sw_y_virstride, p_regs->swreg9_yuv_virstride.sw_yuv_virstride);
} }
//!< caculate mv_size //!< caculate mv_size
{ {
RK_U32 mb_width = 0, mb_height = 0, mv_size = 0; RK_U32 mb_width = 0, mb_height = 0, mv_size = 0;
mb_width = pp->wFrameWidthInMbsMinus1 + 1; mb_width = pp->wFrameWidthInMbsMinus1 + 1;
mb_height = (2 - pp->frame_mbs_only_flag) * (pp->wFrameHeightInMbsMinus1 + 1); mb_height = (2 - pp->frame_mbs_only_flag) * (pp->wFrameHeightInMbsMinus1 + 1);
mv_size = mb_width * mb_height * 8; // 64bit per 4x4 mv_size = mb_width * mb_height * 8; // 64bit per 4x4
p_regs->compare_len = (p_regs->swreg9_yuv_virstride.sw_yuv_virstride + mv_size) * 2; p_regs->compare_len = (p_regs->swreg9_yuv_virstride.sw_yuv_virstride + mv_size) * 2;
} }
if (p_regs->swreg2_sysctrl.sw_h264_rps_mode) { // rps_mode == 1
p_regs->swreg43_rps_base.sw_rps_base += 0x8;
}
p_regs->swreg3_picpar.sw_slice_num_lowbits = 0x7ff; // p_Vid->iNumOfSlicesDecoded & 0x7ff
p_regs->swreg3_picpar.sw_slice_num_highbit = 1; // (p_Vid->iNumOfSlicesDecoded >> 11) & 1
//!< set current //!< set current
p_regs->swreg40_cur_poc.sw_cur_poc = pp->CurrFieldOrderCnt[0]; {
p_regs->swreg74_h264_cur_poc1.sw_h264_cur_poc1 = pp->CurrFieldOrderCnt[1]; MppBuffer frame_buf = NULL;
mpp_buf_slot_get_prop(p_hal->frame_slots, pp->CurrPic.Index7Bits, SLOT_BUFFER, &frame_buf); //!< current out phy addr p_regs->swreg40_cur_poc.sw_cur_poc = pp->CurrFieldOrderCnt[0];
p_regs->swreg74_h264_cur_poc1.sw_h264_cur_poc1 = pp->CurrFieldOrderCnt[1];
#if FPGA_TEST
p_regs->swreg7_decout_base.sw_decout_base = pp->CurrPic.Index7Bits + 1;
#else
p_regs->swreg7_decout_base.sw_decout_base = mpp_buffer_get_fd(frame_buf);
//mpp_log_f("line=%d, decout_fd=%d over \n", __LINE__, mpp_buffer_get_fd(frame_buf));
#endif
//!< set reference
for (i = 0; i < 15; i++) {
p_regs->swreg25_39_refer0_14_poc[i] = (i & 1) ? pp->FieldOrderCntList[i / 2][1] : pp->FieldOrderCntList[i / 2][0];
p_regs->swreg49_63_refer15_29_poc[i] = (i & 1) ? pp->FieldOrderCntList[(i + 15) / 2][0] : pp->FieldOrderCntList[(i + 15) / 2][1];
p_regs->swreg10_24_refer0_14_base[i].sw_ref_field = (pp->RefPicFiledFlags >> i) & 0x01;
p_regs->swreg10_24_refer0_14_base[i].sw_ref_topfield_used = (pp->UsedForReferenceFlags >> (2 * i + 0)) & 0x01;
p_regs->swreg10_24_refer0_14_base[i].sw_ref_botfield_used = (pp->UsedForReferenceFlags >> (2 * i + 1)) & 0x01;
p_regs->swreg10_24_refer0_14_base[i].sw_ref_colmv_use_flag = (pp->RefPicColmvUsedFlags >> i) & 0x01;
if (pp->RefFrameList[i].bPicEntry == 0xff) {
mpp_buf_slot_get_prop(p_hal->frame_slots, pp->CurrPic.Index7Bits, SLOT_BUFFER, &frame_buf); //!< current out phy addr
} else {
mpp_buf_slot_get_prop(p_hal->frame_slots, pp->RefFrameList[i].Index7Bits, SLOT_BUFFER, &frame_buf); //!< reference phy addr
}
//mpp_log_f("line=%d, ref[%d]=%d over \n", __LINE__, i, mpp_buffer_get_fd(frame_buf));
#if FPGA_TEST
p_regs->swreg10_24_refer0_14_base[i].sw_refer_base = pp->RefFrameList[i].Index7Bits + 1;
#else
p_regs->swreg10_24_refer0_14_base[i].sw_refer_base = mpp_buffer_get_fd(frame_buf);
#endif
}
p_regs->swreg72_refer30_poc = pp->FieldOrderCntList[i][0];
p_regs->swreg73_refer31_poc = pp->FieldOrderCntList[i][1];
p_regs->swreg48_refer15_base.sw_ref_field = (pp->RefPicFiledFlags >> 15) & 0x01;
p_regs->swreg48_refer15_base.sw_ref_topfield_used = (pp->UsedForReferenceFlags >> 30) & 0x01;
p_regs->swreg48_refer15_base.sw_ref_botfield_used = (pp->UsedForReferenceFlags >> 31) & 0x01;
p_regs->swreg48_refer15_base.sw_ref_colmv_use_flag = (pp->RefPicColmvUsedFlags >> 15) & 0x01;
if (pp->RefFrameList[15].bPicEntry == 0xff) {
mpp_buf_slot_get_prop(p_hal->frame_slots, pp->CurrPic.Index7Bits, SLOT_BUFFER, &frame_buf); //!< current out phy addr mpp_buf_slot_get_prop(p_hal->frame_slots, pp->CurrPic.Index7Bits, SLOT_BUFFER, &frame_buf); //!< current out phy addr
} else { #if FPGA_TEST
mpp_buf_slot_get_prop(p_hal->frame_slots, pp->RefFrameList[15].Index7Bits, SLOT_BUFFER, &frame_buf); //!< reference phy addr p_regs->swreg7_decout_base.sw_decout_base = pp->CurrPic.Index7Bits + 1;
#else
p_regs->swreg7_decout_base.sw_decout_base = mpp_buffer_get_fd(frame_buf);
#endif
}
//!< set reference
{
RK_S32 i = 0;
RK_S32 ref_index = -1;
RK_S32 near_index = -1;
MppBuffer frame_buf = NULL;
for (i = 0; i < 15; i++) {
p_regs->swreg25_39_refer0_14_poc[i] = (i & 1) ? pp->FieldOrderCntList[i / 2][1] : pp->FieldOrderCntList[i / 2][0];
p_regs->swreg49_63_refer15_29_poc[i] = (i & 1) ? pp->FieldOrderCntList[(i + 15) / 2][0] : pp->FieldOrderCntList[(i + 15) / 2][1];
p_regs->swreg10_24_refer0_14_base[i].sw_ref_field = (pp->RefPicFiledFlags >> i) & 0x01;
p_regs->swreg10_24_refer0_14_base[i].sw_ref_topfield_used = (pp->UsedForReferenceFlags >> (2 * i + 0)) & 0x01;
p_regs->swreg10_24_refer0_14_base[i].sw_ref_botfield_used = (pp->UsedForReferenceFlags >> (2 * i + 1)) & 0x01;
p_regs->swreg10_24_refer0_14_base[i].sw_ref_colmv_use_flag = (pp->RefPicColmvUsedFlags >> i) & 0x01;
#if FPGA_TEST
p_regs->swreg10_24_refer0_14_base[i].sw_refer_base = pp->RefFrameList[i].Index7Bits + 1;
#else
if (pp->RefFrameList[i].bPicEntry != 0xff) {
ref_index = pp->RefFrameList[i].Index7Bits;
near_index = pp->RefFrameList[i].Index7Bits;
}
if (near_index < 0) {
ref_index = pp->CurrPic.Index7Bits;
} else {
ref_index = pp->RefFrameList[i].Index7Bits;
}
mpp_buf_slot_get_prop(p_hal->frame_slots, ref_index, SLOT_BUFFER, &frame_buf); //!< reference phy addr
p_regs->swreg10_24_refer0_14_base[i].sw_refer_base = mpp_buffer_get_fd(frame_buf);
#endif
}
p_regs->swreg72_refer30_poc = pp->FieldOrderCntList[15][0];
p_regs->swreg73_refer31_poc = pp->FieldOrderCntList[15][1];
p_regs->swreg48_refer15_base.sw_ref_field = (pp->RefPicFiledFlags >> 15) & 0x01;
p_regs->swreg48_refer15_base.sw_ref_topfield_used = (pp->UsedForReferenceFlags >> 30) & 0x01;
p_regs->swreg48_refer15_base.sw_ref_botfield_used = (pp->UsedForReferenceFlags >> 31) & 0x01;
p_regs->swreg48_refer15_base.sw_ref_colmv_use_flag = (pp->RefPicColmvUsedFlags >> 15) & 0x01;
#if FPGA_TEST
p_regs->swreg48_refer15_base.sw_refer_base = pp->RefFrameList[15].Index7Bits + 1;
#else
if (pp->RefFrameList[15].bPicEntry == 0xff) {
ref_index = pp->CurrPic.Index7Bits;
} else {
ref_index = pp->RefFrameList[15].Index7Bits;
}
mpp_buf_slot_get_prop(p_hal->frame_slots, ref_index, SLOT_BUFFER, &frame_buf); //!< reference phy addr
p_regs->swreg48_refer15_base.sw_refer_base = mpp_buffer_get_fd(frame_buf);
#endif
} }
#if FPGA_TEST #if FPGA_TEST
p_regs->swreg48_refer15_base.sw_refer_base = pp->RefFrameList[15].Index7Bits + 1;
p_regs->swreg4_strm_rlc_base.sw_strm_rlc_base = 0; p_regs->swreg4_strm_rlc_base.sw_strm_rlc_base = 0;
p_regs->swreg6_cabactbl_prob_base.sw_cabactbl_base = 0; p_regs->swreg6_cabactbl_prob_base.sw_cabactbl_base = 0;
p_regs->swreg41_rlcwrite_base.sw_rlcwrite_base = 0;
#else #else
p_regs->swreg48_refer15_base.sw_refer_base = mpp_buffer_get_fd(frame_buf); {
//mpp_log_f("line=%d, ref[%d]=%d over \n", __LINE__, 15, mpp_buffer_get_fd(frame_buf)); MppBuffer bitstream_buf = NULL;
p_regs->swreg6_cabactbl_prob_base.sw_cabactbl_base = mpp_buffer_get_fd(p_hal->cabac_buf); mpp_buf_slot_get_prop(p_hal->packet_slots, task->dec.input, SLOT_BUFFER, &bitstream_buf);
//mpp_log_f("line=%d, cabac_table_fd=%d over \n", __LINE__, mpp_buffer_get_fd(p_hal->cabac_buf)); p_regs->swreg4_strm_rlc_base.sw_strm_rlc_base = mpp_buffer_get_fd(bitstream_buf);
mpp_buf_slot_get_prop(p_hal->packet_slots, task->dec.input, SLOT_BUFFER, &bitstream_buf); p_regs->swreg6_cabactbl_prob_base.sw_cabactbl_base = mpp_buffer_get_fd(p_hal->cabac_buf);
p_regs->swreg4_strm_rlc_base.sw_strm_rlc_base = mpp_buffer_get_fd(bitstream_buf); p_regs->swreg41_rlcwrite_base.sw_rlcwrite_base = p_regs->swreg4_strm_rlc_base.sw_strm_rlc_base;
//mpp_log_f("line=%d, rlc_base_fd=%d over \n", __LINE__,mpp_buffer_get_fd(bitstream_buf)); }
p_regs->swreg41_rlcwrite_base.sw_rlcwrite_base = p_regs->swreg4_strm_rlc_base.sw_strm_rlc_base;
#endif #endif
fifo_packet_reset(pkt); fifo_packet_reset(pkt);
fifo_write_bytes(pkt, (void *)p_hal->regs, 80 * sizeof(RK_U32)); fifo_write_bytes(pkt, (void *)p_hal->regs, 80 * sizeof(RK_U32));
{ {
RK_U32 *ptr = (RK_U32*)p_hal->regs; RK_U32 i = 0;
LogInfo(pkt->logctx, "------------------ Frame REG begin ------------------------"); RK_U32 *ptr = (RK_U32*)p_hal->regs;
for (i = 0; i < 80; i++) { LogInfo(pkt->logctx, "------------------ Frame REG begin ------------------------");
//fifo_write_bits(pkt, ptr[i], 32, "reg"); //!< not used in hard for (i = 0; i < 80; i++) {
LogInfo(pkt->logctx, " reg[%3d] = %08x \n", i, ptr[i]); LogInfo(pkt->logctx, " reg[%3d] = %08x \n", i, ptr[i]);
} }
} }
fifo_align_bits(pkt, 64); fifo_align_bits(pkt, 64);
fifo_flush_bits(pkt); fifo_flush_bits(pkt);
fifo_fwrite_data(pkt); //!< "REGH" header 32 bit fifo_fwrite_data(pkt); //!< "REGH" header 32 bit

View File

@@ -208,32 +208,31 @@ static RK_U32 rkv_len_align(RK_U32 val)
} }
static void rkv_h264d_hal_dump(H264dHalCtx_t *p_hal, RK_U32 dump_type) static void rkv_h264d_hal_dump(H264dHalCtx_t *p_hal, RK_U32 dump_type)
{ {
if (rkv_h264d_hal_debug & H264D_DBG_ERR_DUMP) { if (rkv_h264d_hal_debug & H264D_DBG_ERR_DUMP) {
RK_U32 i = 0; RK_U32 i = 0;
RK_U32 *p_hal_regs = NULL; RK_U32 *p_hal_regs = NULL;
H264dRkvErrDump_t *p_dump = (H264dRkvErrDump_t *)p_hal->dump; H264dRkvErrDump_t *p_dump = (H264dRkvErrDump_t *)p_hal->dump;
switch (dump_type) switch (dump_type) {
{ case H264D_DBG_GEN_REGS:
case H264D_DBG_GEN_REGS: p_hal_regs = (RK_U32 *)p_dump->in_regs;
p_hal_regs = (RK_U32 *)p_dump->in_regs; mpp_log("------- register input ------ \n");
mpp_log("------- register input ------ \n"); for (i = 0; i < DEC_RKV_REGISTERS; i++) {
for (i = 0; i < DEC_RKV_REGISTERS; i++) { mpp_log("reg[%d]=%08x", i, p_hal_regs[i]);
mpp_log("reg[%d]=%08x", i, p_hal_regs[i]); }
} break;
break; case H264D_DBG_RET_REGS:
case H264D_DBG_RET_REGS: p_hal_regs = (RK_U32 *)p_dump->out_regs;
p_hal_regs = (RK_U32 *)p_dump->out_regs; mpp_log("------- register output ------ \n");
mpp_log("------- register output ------ \n"); for (i = 0; i < DEC_RKV_REGISTERS; i++) {
for (i = 0; i < DEC_RKV_REGISTERS; i++) { mpp_log("reg[%d]=%08x", i, p_hal_regs[i]);
mpp_log("reg[%d]=%08x", i, p_hal_regs[i]); }
} break;
break;
default: default:
break; break;
} }
} }
} }
/*! /*!
@@ -253,7 +252,7 @@ MPP_RET rkv_h264d_init(void *hal, MppHalCfg *cfg)
FunctionIn(p_hal->logctx.parr[RUN_HAL]); FunctionIn(p_hal->logctx.parr[RUN_HAL]);
p_hal->iDecodedNum = 0; p_hal->iDecodedNum = 0;
MEM_CHECK(ret, p_hal->pkts = mpp_calloc_size(void, sizeof(H264dRkvPkt_t))); MEM_CHECK(ret, p_hal->pkts = mpp_calloc_size(void, sizeof(H264dRkvPkt_t)));
MEM_CHECK(ret, p_hal->dump = mpp_malloc_size(void, sizeof(H264dRkvErrDump_t))); MEM_CHECK(ret, p_hal->dump = mpp_malloc_size(void, sizeof(H264dRkvErrDump_t)));
//!< malloc cabac+scanlis + packets + poc_buf //!< malloc cabac+scanlis + packets + poc_buf
cabac_size = RKV_CABAC_TAB_SIZE + RKV_SPSPPS_SIZE + RKV_RPS_SIZE + RKV_SCALING_LIST_SIZE + RKV_ERROR_INFO_SIZE; cabac_size = RKV_CABAC_TAB_SIZE + RKV_SPSPPS_SIZE + RKV_RPS_SIZE + RKV_SCALING_LIST_SIZE + RKV_ERROR_INFO_SIZE;
FUN_CHECK(ret = mpp_buffer_get(p_hal->buf_group, &p_hal->cabac_buf, cabac_size)); FUN_CHECK(ret = mpp_buffer_get(p_hal->buf_group, &p_hal->cabac_buf, cabac_size));
@@ -291,7 +290,7 @@ MPP_RET rkv_h264d_deinit(void *hal)
FunctionIn(p_hal->logctx.parr[RUN_HAL]); FunctionIn(p_hal->logctx.parr[RUN_HAL]);
rkv_free_fifo_packet((H264dRkvPkt_t *)p_hal->pkts); rkv_free_fifo_packet((H264dRkvPkt_t *)p_hal->pkts);
MPP_FREE(p_hal->dump); MPP_FREE(p_hal->dump);
MPP_FREE(p_hal->pkts); MPP_FREE(p_hal->pkts);
if (p_hal->cabac_buf) { if (p_hal->cabac_buf) {
FUN_CHECK(ret = mpp_buffer_put(p_hal->cabac_buf)); FUN_CHECK(ret = mpp_buffer_put(p_hal->cabac_buf));
@@ -376,15 +375,15 @@ MPP_RET rkv_h264d_start(void *hal, HalTaskInfo *task)
p_regs[67] = 0x000000ff; // disable fpga reset p_regs[67] = 0x000000ff; // disable fpga reset
p_regs[44] = 0xffffffff; // 0xffff_ffff, debug enable p_regs[44] = 0xffffffff; // 0xffff_ffff, debug enable
p_regs[77] = 0xffffffff; // 0xffff_dfff, debug enable p_regs[77] = 0xffffffff; // 0xffff_dfff, debug enable
p_regs[1] = 0x00000021; // run hardware p_regs[1] = 0x00000021; // run hardware
//!< dump input register //!< dump input register
{ {
H264dRkvErrDump_t *p_dump = (H264dRkvErrDump_t *)p_hal->dump; H264dRkvErrDump_t *p_dump = (H264dRkvErrDump_t *)p_hal->dump;
memcpy(p_dump->in_regs, p_regs, DEC_RKV_REGISTERS); memcpy(p_dump->in_regs, p_regs, DEC_RKV_REGISTERS);
if (rkv_h264d_hal_debug & H264D_DBG_GEN_REGS) { if (rkv_h264d_hal_debug & H264D_DBG_GEN_REGS) {
rkv_h264d_hal_dump(p_hal, H264D_DBG_GEN_REGS); rkv_h264d_hal_dump(p_hal, H264D_DBG_GEN_REGS);
} }
} }
#ifdef ANDROID #ifdef ANDROID
if (VPUClientSendReg(p_hal->vpu_socket, (RK_U32 *)p_regs, DEC_RKV_REGISTERS)) { if (VPUClientSendReg(p_hal->vpu_socket, (RK_U32 *)p_regs, DEC_RKV_REGISTERS)) {
ret = MPP_ERR_VPUHW; ret = MPP_ERR_VPUHW;
@@ -406,46 +405,46 @@ __RETURN:
//extern "C" //extern "C"
MPP_RET rkv_h264d_wait(void *hal, HalTaskInfo *task) MPP_RET rkv_h264d_wait(void *hal, HalTaskInfo *task)
{ {
MPP_RET ret = MPP_ERR_UNKNOW; MPP_RET ret = MPP_ERR_UNKNOW;
H264dRkvRegs_t *p_regs = NULL; H264dRkvRegs_t *p_regs = NULL;
H264dHalCtx_t *p_hal = (H264dHalCtx_t *)hal; H264dHalCtx_t *p_hal = (H264dHalCtx_t *)hal;
INP_CHECK(ret, NULL == p_hal); INP_CHECK(ret, NULL == p_hal);
FunctionIn(p_hal->logctx.parr[RUN_HAL]); FunctionIn(p_hal->logctx.parr[RUN_HAL]);
p_regs = (H264dRkvRegs_t *)p_hal->regs; p_regs = (H264dRkvRegs_t *)p_hal->regs;
#ifdef ANDROID #ifdef ANDROID
RK_S32 wait_ret = -1; RK_S32 wait_ret = -1;
RK_S32 ret_len = 0, cur_deat = 0; RK_S32 ret_len = 0, cur_deat = 0;
VPU_CMD_TYPE ret_cmd = VPU_CMD_BUTT; VPU_CMD_TYPE ret_cmd = VPU_CMD_BUTT;
static struct timeval tv1, tv2; static struct timeval tv1, tv2;
gettimeofday(&tv1, NULL); gettimeofday(&tv1, NULL);
wait_ret = VPUClientWaitResult(p_hal->vpu_socket, (RK_U32 *)p_hal->regs, DEC_RKV_REGISTERS, &ret_cmd, &ret_len); wait_ret = VPUClientWaitResult(p_hal->vpu_socket, (RK_U32 *)p_hal->regs, DEC_RKV_REGISTERS, &ret_cmd, &ret_len);
gettimeofday(&tv2, NULL); gettimeofday(&tv2, NULL);
cur_deat = (tv2.tv_sec - tv1.tv_sec) * 1000 + (tv2.tv_usec - tv1.tv_usec) / 1000; cur_deat = (tv2.tv_sec - tv1.tv_sec) * 1000 + (tv2.tv_usec - tv1.tv_usec) / 1000;
p_hal->total_time += cur_deat; p_hal->total_time += cur_deat;
p_hal->iDecodedNum++; p_hal->iDecodedNum++;
(void)wait_ret; (void)wait_ret;
#endif #endif
//!< dump registers //!< dump registers
{ {
H264dRkvErrDump_t *p_dump = (H264dRkvErrDump_t *)p_hal->dump; H264dRkvErrDump_t *p_dump = (H264dRkvErrDump_t *)p_hal->dump;
p_dump->out_regs = (RK_U32 *)p_regs; p_dump->out_regs = (RK_U32 *)p_regs;
if (rkv_h264d_hal_debug & H264D_DBG_RET_REGS) { if (rkv_h264d_hal_debug & H264D_DBG_RET_REGS) {
rkv_h264d_hal_dump(p_hal, H264D_DBG_RET_REGS); rkv_h264d_hal_dump(p_hal, H264D_DBG_RET_REGS);
} }
if (p_regs->swreg1_int.sw_dec_error_sta) { if (p_regs->swreg1_int.sw_dec_error_sta) {
rkv_h264d_hal_dump(p_hal, H264D_DBG_GEN_REGS); rkv_h264d_hal_dump(p_hal, H264D_DBG_GEN_REGS);
rkv_h264d_hal_dump(p_hal, H264D_DBG_RET_REGS); rkv_h264d_hal_dump(p_hal, H264D_DBG_RET_REGS);
} }
} }
p_regs->slot_idx = task->dec.output; p_regs->slot_idx = task->dec.output;
p_regs->dpb_err_flag = task->dec.dpb_err_flag; p_regs->dpb_err_flag = task->dec.dpb_err_flag;
p_regs->used_for_ref_flag = task->dec.used_for_ref_flag; p_regs->used_for_ref_flag = task->dec.used_for_ref_flag;
if (p_hal->init_cb.callBack if (p_hal->init_cb.callBack
&& (p_regs->swreg1_int.sw_dec_error_sta || p_regs->dpb_err_flag)) { && (p_regs->swreg1_int.sw_dec_error_sta || p_regs->dpb_err_flag)) {
p_hal->init_cb.callBack(p_hal->init_cb.opaque, p_hal->regs); p_hal->init_cb.callBack(p_hal->init_cb.opaque, p_hal->regs);
} }
memset(&p_regs->swreg1_int, 0, sizeof(RK_U32)); memset(&p_regs->swreg1_int, 0, sizeof(RK_U32));
FunctionOut(p_hal->logctx.parr[RUN_HAL]); FunctionOut(p_hal->logctx.parr[RUN_HAL]);
@@ -468,8 +467,8 @@ MPP_RET rkv_h264d_reset(void *hal)
INP_CHECK(ret, NULL == p_hal); INP_CHECK(ret, NULL == p_hal);
FunctionIn(p_hal->logctx.parr[RUN_HAL]); FunctionIn(p_hal->logctx.parr[RUN_HAL]);
memset(p_hal->regs, 0, sizeof(H264dRkvRegs_t)); memset(p_hal->regs, 0, sizeof(H264dRkvRegs_t));
rkv_reset_fifo_packet((H264dRkvPkt_t *)p_hal->pkts); rkv_reset_fifo_packet((H264dRkvPkt_t *)p_hal->pkts);
FunctionOut(p_hal->logctx.parr[RUN_HAL]); FunctionOut(p_hal->logctx.parr[RUN_HAL]);
__RETURN: __RETURN:

View File

@@ -210,9 +210,9 @@ typedef struct h264d_rkv_regs_t {
RK_U32 sw_h264_error_en_highbits : 30; RK_U32 sw_h264_error_en_highbits : 30;
RK_U32 reserve : 2; RK_U32 reserve : 2;
} swreg77_h264_error_e; } swreg77_h264_error_e;
RK_U32 slot_idx; RK_U32 slot_idx;
RK_U32 dpb_err_flag; RK_U32 dpb_err_flag;
RK_U32 used_for_ref_flag; RK_U32 used_for_ref_flag;
RK_U32 compare_len; RK_U32 compare_len;
RK_U32 reverse[100]; RK_U32 reverse[100];
} H264dRkvRegs_t; } H264dRkvRegs_t;
@@ -221,12 +221,11 @@ typedef struct h264d_rkv_regs_t {
/* Number registers for the decoder */ /* Number registers for the decoder */
#define DEC_RKV_REGISTERS 78 #define DEC_RKV_REGISTERS 78
typedef struct h264d_rkv_err_dump_t typedef struct h264d_rkv_err_dump_t {
{ RK_U32 in_regs[DEC_RKV_REGISTERS];
RK_U32 in_regs[DEC_RKV_REGISTERS]; RK_U32 *out_regs;
RK_U32 *out_regs;
}H264dRkvErrDump_t; } H264dRkvErrDump_t;

View File

@@ -715,10 +715,10 @@ MPP_RET hal_vp9d_gen_regs(void *hal, HalTaskInfo *task)
/*0 map to 11*/ /*0 map to 11*/
/*1 map to 12*/ /*1 map to 12*/
/*2 map to 13*/ /*2 map to 13*/
if(framebuf != NULL){ if (framebuf != NULL) {
reg_ref_base[i] = mpp_buffer_get_fd(framebuf); reg_ref_base[i] = mpp_buffer_get_fd(framebuf);
}else{ } else {
mpp_log("ref buff address is no valid used out as base slot index 0x%x",pic_param->ref_frame_map[ref_idx].Index7Bits); mpp_log("ref buff address is no valid used out as base slot index 0x%x", pic_param->ref_frame_map[ref_idx].Index7Bits);
reg_ref_base[i] = vp9_hw_regs->swreg7_decout_base; //set reg_ref_base[i] = vp9_hw_regs->swreg7_decout_base; //set
} }
#endif #endif
@@ -799,11 +799,11 @@ MPP_RET hal_vp9d_gen_regs(void *hal, HalTaskInfo *task)
//extern "C" //extern "C"
MPP_RET hal_vp9d_start(void *hal, HalTaskInfo *task) MPP_RET hal_vp9d_start(void *hal, HalTaskInfo *task)
{ {
RK_U32 i = 0; RK_U32 i = 0;
MPP_RET ret = MPP_OK; MPP_RET ret = MPP_OK;
hal_vp9_context_t *reg_cxt = (hal_vp9_context_t *)hal; hal_vp9_context_t *reg_cxt = (hal_vp9_context_t *)hal;
VP9_REGS *hw_regs = ( VP9_REGS *)reg_cxt->hw_regs; VP9_REGS *hw_regs = ( VP9_REGS *)reg_cxt->hw_regs;
RK_U8 *p = (RK_U8*)reg_cxt->hw_regs; RK_U8 *p = (RK_U8*)reg_cxt->hw_regs;
if (hw_regs == NULL) { if (hw_regs == NULL) {
mpp_err("hal_vp9d_start hw_regs is NULL"); mpp_err("hal_vp9d_start hw_regs is NULL");

View File

@@ -186,16 +186,16 @@ static RK_S32 find_dir_in_path(char *path, const char *dir_name, size_t max_leng
if (n < 0) { if (n < 0) {
mpp_err("scan %s for %s failed\n", path, dir_name); mpp_err("scan %s for %s failed\n", path, dir_name);
} else { } else {
while (n > 1) { while (n > 1) {
free(dir[--n]); free(dir[--n]);
} }
new_path_len = path_len; new_path_len = path_len;
new_path_len += snprintf(path + path_len, max_length - path_len - 1, new_path_len += snprintf(path + path_len, max_length - path_len - 1,
"/%s", dir[0]->d_name); "/%s", dir[0]->d_name);
free(dir[0]); free(dir[0]);
free(dir); free(dir);
} }
search_name = NULL; search_name = NULL;
return new_path_len; return new_path_len;

View File

@@ -247,9 +247,9 @@ RK_S32 vpu_open_context(VpuCodecContext **ctx)
{ {
VpuCodecContext *s = *ctx; VpuCodecContext *s = *ctx;
RK_U32 value = 0; RK_U32 value = 0;
RK_U32 use_mpp_mode = 0; RK_U32 use_mpp_mode = 0;
mpp_env_get_u32("chg_orig", &value, 0); mpp_env_get_u32("chg_orig", &value, 0);
mpp_env_get_u32("use_mpp_mode", &use_mpp_mode, 0); mpp_env_get_u32("use_mpp_mode", &use_mpp_mode, 0);
#ifdef ANDROID #ifdef ANDROID
value = value || (!!access("/dev/rkvdec", F_OK)); value = value || (!!access("/dev/rkvdec", F_OK));

View File

@@ -36,21 +36,21 @@ VpuApi::VpuApi()
mpp_create(&mpp_ctx, &mpi); mpp_create(&mpp_ctx, &mpi);
frame_count = 0; frame_count = 0;
set_eos = 0; set_eos = 0;
vpu_api_debug = 0; vpu_api_debug = 0;
fp = NULL; fp = NULL;
mpp_env_get_u32("vpu_api_debug", &vpu_api_debug, 0); mpp_env_get_u32("vpu_api_debug", &vpu_api_debug, 0);
if (vpu_api_debug & VPU_API_DBG_DUMP_YUV) { if (vpu_api_debug & VPU_API_DBG_DUMP_YUV) {
fp = fopen("data/hevcdump.yuv", "wb"); fp = fopen("data/hevcdump.yuv", "wb");
} }
mpp_log_f("ok\n"); mpp_log_f("ok\n");
} }
VpuApi::~VpuApi() VpuApi::~VpuApi()
{ {
mpp_log_f("in\n"); mpp_log_f("in\n");
if (fp) { if (fp) {
fclose(fp); fclose(fp);
} }
mpp_destroy(mpp_ctx); mpp_destroy(mpp_ctx);
mpp_log_f("ok\n"); mpp_log_f("ok\n");
} }
@@ -158,10 +158,10 @@ RK_S32 VpuApi:: decode_getoutframe(DecoderOut_t *aDecOut)
vframe->ErrorInfo = mpp_frame_get_errinfo(mframe) | mpp_frame_get_discard(mframe); vframe->ErrorInfo = mpp_frame_get_errinfo(mframe) | mpp_frame_get_discard(mframe);
pts = mpp_frame_get_pts(mframe); pts = mpp_frame_get_pts(mframe);
aDecOut->timeUs = pts; aDecOut->timeUs = pts;
if (vpu_api_debug & VPU_API_DBG_OUTPUT) { if (vpu_api_debug & VPU_API_DBG_OUTPUT) {
mpp_log("get one frame timeUs %lld, poc=%d, errinfo=%d, discard=%d", aDecOut->timeUs, 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_frame_get_poc(mframe), mpp_frame_get_errinfo(mframe), mpp_frame_get_discard(mframe));
} }
vframe->ShowTime.TimeHigh = (RK_U32)(pts >> 32); vframe->ShowTime.TimeHigh = (RK_U32)(pts >> 32);
vframe->ShowTime.TimeLow = (RK_U32)pts; vframe->ShowTime.TimeLow = (RK_U32)pts;
buf = mpp_frame_get_buffer(mframe); buf = mpp_frame_get_buffer(mframe);
@@ -196,7 +196,7 @@ RK_S32 VpuApi:: decode_getoutframe(DecoderOut_t *aDecOut)
vframe->FrameBusAddr[1] = fd; vframe->FrameBusAddr[1] = fd;
vframe->vpumem.vir_addr = (RK_U32*)ptr; vframe->vpumem.vir_addr = (RK_U32*)ptr;
frame_count++; frame_count++;
//!< Dump yuv //!< Dump yuv
if (fp && (frame_count > 350)) { if (fp && (frame_count > 350)) {
fwrite(ptr, 1, vframe->FrameWidth * vframe->FrameHeight * 3 / 2, fp); fwrite(ptr, 1, vframe->FrameWidth * vframe->FrameHeight * 3 / 2, fp);
fflush(fp); fflush(fp);
@@ -306,10 +306,10 @@ RK_S32 VpuApi::control(VpuCodecContext *ctx, VPU_API_CMD cmd, void *param)
mpicmd = MPP_DEC_USE_FAST_MODE; mpicmd = MPP_DEC_USE_FAST_MODE;
break; break;
} }
case VPU_API_DEC_GET_STREAM_COUNT: { case VPU_API_DEC_GET_STREAM_COUNT: {
mpicmd = MPP_DEC_GET_STREAM_COUNT; mpicmd = MPP_DEC_GET_STREAM_COUNT;
break; break;
} }
default: { default: {
break; break;
} }

View File

@@ -48,7 +48,7 @@ private:
MppApi *mpi; MppApi *mpi;
RK_U32 frame_count; RK_U32 frame_count;
RK_U32 set_eos; RK_U32 set_eos;
RK_U32 vpu_api_debug; RK_U32 vpu_api_debug;
FILE *fp; FILE *fp;
}; };

View File

@@ -85,9 +85,9 @@ MPP_RET Mpp::init(MppCtxType type, MppCodingType coding)
mpp_dec_init(mDec, coding); mpp_dec_init(mDec, coding);
mThreadCodec = new MppThread(mpp_dec_parser_thread, this); mThreadCodec = new MppThread(mpp_dec_parser_thread, this);
mpp_log("mThreadCodec = %p",mThreadCodec); mpp_log("mThreadCodec = %p", mThreadCodec);
mThreadHal = new MppThread(mpp_dec_hal_thread, this); mThreadHal = new MppThread(mpp_dec_hal_thread, this);
mpp_log("mThreadHal = %p",mThreadHal); mpp_log("mThreadHal = %p", mThreadHal);
mpp_buffer_group_get_internal(&mInternalGroup, MPP_BUFFER_TYPE_ION); mpp_buffer_group_get_internal(&mInternalGroup, MPP_BUFFER_TYPE_ION);
mpp_buffer_group_get_internal(&mPacketGroup, MPP_BUFFER_TYPE_ION); mpp_buffer_group_get_internal(&mPacketGroup, MPP_BUFFER_TYPE_ION);
@@ -299,12 +299,12 @@ MPP_RET Mpp::control(MpiCmd cmd, MppParam param)
mFastMode = mode; mFastMode = mode;
break; break;
} }
case MPP_DEC_GET_STREAM_COUNT:{ case MPP_DEC_GET_STREAM_COUNT: {
AutoMutex autoLock(mPackets->mutex()); AutoMutex autoLock(mPackets->mutex());
mpp_assert(mType == MPP_CTX_DEC); mpp_assert(mType == MPP_CTX_DEC);
*((RK_S32 *)param) = mPackets->list_size(); *((RK_S32 *)param) = mPackets->list_size();
break; break;
} }
default : { default : {
} break; } break;
} }

View File

@@ -182,7 +182,7 @@ int _compare_name(const struct dirent *dir)
{ {
if (search_name && strstr(dir->d_name, search_name)) if (search_name && strstr(dir->d_name, search_name))
return 1; return 1;
return 0; return 0;
} }
@@ -206,16 +206,16 @@ RK_S32 find_dir_in_path(char *path, const char *dir_name, size_t max_length)
if (n < 0) { if (n < 0) {
mpp_err("scan %s for %s failed\n", path, dir_name); mpp_err("scan %s for %s failed\n", path, dir_name);
} else { } else {
while (n > 1) { while (n > 1) {
free(dir[--n]); free(dir[--n]);
} }
new_path_len = path_len; new_path_len = path_len;
new_path_len += snprintf(path + path_len, max_length - path_len - 1, new_path_len += snprintf(path + path_len, max_length - path_len - 1,
"/%s", dir[0]->d_name); "/%s", dir[0]->d_name);
free(dir[0]); free(dir[0]);
free(dir); free(dir);
} }
search_name = NULL; search_name = NULL;
return new_path_len; return new_path_len;

View File

@@ -64,7 +64,7 @@ void MppThread::stop()
if (MPP_THREAD_UNINITED != mStatus) { if (MPP_THREAD_UNINITED != mStatus) {
lock(); lock();
mStatus = MPP_THREAD_STOPPING; mStatus = MPP_THREAD_STOPPING;
mpp_log("MPP_THREAD_STOPPING status set mThread %p",this); mpp_log("MPP_THREAD_STOPPING status set mThread %p", this);
signal(); signal();
unlock(); unlock();
void *dummy; void *dummy;