mirror of
https://github.com/nyanmisaka/mpp.git
synced 2025-10-07 18:11:02 +08:00
[h264d] a) deal with bug which time stamp error when use function prepare_fast;
b) change fifo size in rkv_pkt git-svn-id: https://10.10.10.66:8443/svn/MediaProcessPlatform/trunk/mpp@510 6e48237b-75ef-9749-8fc9-41990f28c85a
This commit is contained in:
@@ -252,6 +252,7 @@ static MPP_RET init_vid_ctx(H264dVideoCtx_t *p_Vid)
|
||||
p_Vid->p_Dpb_layer[i]->init_done = 0;
|
||||
memset(&p_Vid->outlist[i], 0, sizeof(p_Vid->outlist[i]));
|
||||
p_Vid->outlist[i].max_size = MAX_MARK_SIZE;
|
||||
p_Vid->last_outputpoc[i] = -1;
|
||||
}
|
||||
//!< init video pars
|
||||
for (i = 0; i < MAXSPS; i++) {
|
||||
@@ -514,6 +515,8 @@ MPP_RET h264d_reset(void *decoder)
|
||||
p_Dec->p_Inp->has_get_eos = 0;
|
||||
//!< reset video parameter
|
||||
p_Dec->p_Vid->g_framecnt = 0;
|
||||
p_Dec->p_Vid->last_outputpoc[0] = -1;
|
||||
p_Dec->p_Vid->last_outputpoc[1] = -1;
|
||||
//!< reset current time stamp
|
||||
p_Dec->p_Cur->last_dts = 0;
|
||||
p_Dec->p_Cur->last_pts = 0;
|
||||
|
@@ -122,14 +122,14 @@ 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) {
|
||||
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_LOG("max_dec_frame_buffering larger than MaxDpbSize");
|
||||
}
|
||||
//}
|
||||
size_vui = MPP_MAX (1, active_sps->vui_seq_parameters.max_dec_frame_buffering);
|
||||
|
||||
if(size_vui < size) {
|
||||
//if(size_vui < size) {
|
||||
//H264D_LOG("Warning: max_dec_frame_buffering(%d) is less than DPB size(%d) calculated from Profile/Level.\n", size_vui, size);
|
||||
}
|
||||
//}
|
||||
size = size_vui;
|
||||
}
|
||||
|
||||
|
@@ -944,6 +944,7 @@ typedef struct h264d_video_ctx_t {
|
||||
RK_S32 last_bottompoc[MAX_NUM_DPB_LAYERS];
|
||||
RK_S32 last_framepoc[MAX_NUM_DPB_LAYERS];
|
||||
RK_S32 last_thispoc[MAX_NUM_DPB_LAYERS];
|
||||
RK_S32 last_outputpoc[MAX_NUM_DPB_LAYERS];
|
||||
//!<
|
||||
RK_S32 profile_idc; // u(8)
|
||||
RK_S32 slice_type;
|
||||
|
@@ -420,16 +420,17 @@ static void dpb_mark_malloc(H264dVideoCtx_t *p_Vid, RK_S32 structure, RK_U8 comb
|
||||
}
|
||||
|
||||
hor_stride = ((p_Vid->width * p_Vid->bit_depth_luma + 127) & (~127))/8;
|
||||
ver_stride = p_Vid->height;
|
||||
hor_stride = MPP_ALIGN(hor_stride, 256) | 256;
|
||||
ver_stride = MPP_ALIGN(p_Vid->height, 16);
|
||||
ver_stride = MPP_ALIGN(ver_stride, 16);
|
||||
|
||||
mpp_frame_set_hor_stride(cur_mark->frame, hor_stride); // before crop
|
||||
mpp_frame_set_ver_stride(cur_mark->frame, ver_stride);
|
||||
|
||||
mpp_frame_set_width(cur_mark->frame, p_Vid->width); // after crop
|
||||
mpp_frame_set_height(cur_mark->frame, p_Vid->height);
|
||||
//mpp_log("hor_stride=%d, ver_stride=%d, width=%d, height=%d, crop_width=%d, crop_height =%d \n", hor_stride,
|
||||
// ver_stride, p_Vid->width, p_Vid->height, p_Vid->width_after_crop, p_Vid->height_after_crop);
|
||||
mpp_frame_set_width(cur_mark->frame, p_Vid->width_after_crop); // after crop
|
||||
mpp_frame_set_height(cur_mark->frame, p_Vid->height_after_crop);
|
||||
H264D_LOG("hor_stride=%d, ver_stride=%d, width=%d, height=%d, crop_width=%d, crop_height =%d \n", hor_stride,
|
||||
ver_stride, p_Vid->width, p_Vid->height, p_Vid->width_after_crop, p_Vid->height_after_crop);
|
||||
|
||||
mpp_frame_set_pts(cur_mark->frame, p_Vid->p_Cur->last_pts);
|
||||
mpp_frame_set_dts(cur_mark->frame, p_Vid->p_Cur->last_dts);
|
||||
|
@@ -243,7 +243,7 @@ static MPP_RET parser_one_nalu(H264_SLICE_t *currSlice)
|
||||
LogTrace(runlog, "nalu_type=SUB_SPS");
|
||||
break;
|
||||
case NALU_TYPE_SEI:
|
||||
FUN_CHECK(ret = process_sei(currSlice));
|
||||
//FUN_CHECK(ret = process_sei(currSlice));
|
||||
LogTrace(runlog, "nalu_type=SEI");
|
||||
currSlice->p_Dec->nalu_ret = NALU_SEI;
|
||||
break;
|
||||
@@ -590,9 +590,9 @@ MPP_RET parse_prepare_fast(H264dInputCtx_t *p_Inp, H264dCurCtx_t *p_Cur)
|
||||
p_strm->curdata = &p_Inp->in_buf[p_strm->nalu_offset++];
|
||||
pkt_impl->length--;
|
||||
if (p_strm->startcode_found) {
|
||||
//if (p_strm->nalu_len >= p_strm->nalu_max_size) {
|
||||
// FUN_CHECK(ret = realloc_buffer(&p_strm->nalu_buf, &p_strm->nalu_max_size, NALU_BUF_ADD_SIZE));
|
||||
//}
|
||||
if (p_strm->nalu_len >= p_strm->nalu_max_size) {
|
||||
FUN_CHECK(ret = realloc_buffer(&p_strm->nalu_buf, &p_strm->nalu_max_size, NALU_BUF_ADD_SIZE));
|
||||
}
|
||||
p_strm->nalu_buf[p_strm->nalu_len++] = *p_strm->curdata;
|
||||
if (p_strm->nalu_len == 1) {
|
||||
p_strm->nalu_type = p_strm->nalu_buf[0]&0x1F;
|
||||
@@ -607,6 +607,7 @@ MPP_RET parse_prepare_fast(H264dInputCtx_t *p_Inp, H264dCurCtx_t *p_Cur)
|
||||
p_strm->nalu_len += (RK_U32)pkt_impl->length;
|
||||
memcpy(&p_strm->nalu_buf[0], p_strm->curdata, pkt_impl->length + 1);
|
||||
pkt_impl->length = 0;
|
||||
p_Cur->p_Inp->task_valid = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -626,6 +627,13 @@ MPP_RET parse_prepare_fast(H264dInputCtx_t *p_Inp, H264dCurCtx_t *p_Cur)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (p_Cur->p_Inp->task_valid) {
|
||||
FUN_CHECK(ret = store_cur_nalu(&p_Dec->p_Cur->strm, p_Dec->dxva_ctx));
|
||||
FUN_CHECK(ret = add_empty_nalu(&p_Cur->strm));
|
||||
p_Cur->strm.head_offset = 0;
|
||||
p_Cur->last_dts = p_Cur->p_Inp->in_dts;
|
||||
p_Cur->last_pts = p_Cur->p_Inp->in_pts;
|
||||
}
|
||||
p_Inp->in_length = pkt_impl->length;
|
||||
//!< check input
|
||||
if (!p_Inp->in_length) {
|
||||
@@ -634,19 +642,10 @@ MPP_RET parse_prepare_fast(H264dInputCtx_t *p_Inp, H264dCurCtx_t *p_Cur)
|
||||
|
||||
p_strm->endcode_found = 1;
|
||||
p_Dec->nalu_ret = EndOfNalu;
|
||||
FUN_CHECK(ret = store_cur_nalu(&p_Dec->p_Cur->strm, p_Dec->dxva_ctx));
|
||||
|
||||
FUN_CHECK(ret = add_empty_nalu(&p_Cur->strm));
|
||||
p_Cur->strm.head_offset = 0;
|
||||
p_Cur->p_Inp->task_valid = 1;
|
||||
p_Cur->p_Dec->is_new_frame = 0;
|
||||
reset_nalu(p_strm);
|
||||
p_strm->startcode_found = 0;
|
||||
|
||||
p_Cur->last_dts = p_Cur->curr_dts;
|
||||
p_Cur->last_pts = p_Cur->curr_pts;
|
||||
p_Cur->curr_dts = p_Cur->p_Inp->in_dts;
|
||||
p_Cur->curr_pts = p_Cur->p_Inp->in_pts;
|
||||
}
|
||||
|
||||
__RETURN:
|
||||
@@ -766,9 +765,20 @@ MPP_RET parse_prepare_extra_data(H264dInputCtx_t *p_Inp, H264dCurCtx_t *p_Cur)
|
||||
RK_U32 nalu_header_bytes = 0;
|
||||
|
||||
p_strm->nalu_len = parse_nal_size(p_Inp->nal_size, p_strm->curdata);
|
||||
VAL_CHECK(ret, (p_strm->nalu_len > 0));
|
||||
H264D_LOG("[extra_data] nalu_len=%d, in_length=%d \n", p_strm->nalu_len, p_Inp->in_length);
|
||||
VAL_CHECK(ret, (RK_U32)(p_strm->nalu_len < p_Inp->in_length));
|
||||
if (p_strm->nalu_len <= 0 || p_strm->nalu_len >= p_Inp->in_length) {
|
||||
p_Cur->p_Dec->is_new_frame = 1;
|
||||
p_Cur->p_Dec->is_first_frame = 1;
|
||||
pkt_impl->length = 0;
|
||||
p_Inp->in_length = 0;
|
||||
p_strm->nalu_len = 0;
|
||||
p_strm->nalu_offset = 0;
|
||||
p_strm->startcode_found = 1;
|
||||
p_strm->endcode_found = 0;
|
||||
p_strm->nalu_buf = NULL;
|
||||
goto __FAILED;
|
||||
}
|
||||
//VAL_CHECK(ret, (RK_U32)(p_strm->nalu_len < p_Inp->in_length));
|
||||
|
||||
p_strm->curdata += p_Inp->nal_size;
|
||||
p_strm->nalu_offset += p_Inp->nal_size;
|
||||
@@ -869,6 +879,7 @@ MPP_RET parse_loop(H264_DecCtx_t *p_Dec)
|
||||
case SliceSTATE_ResetSlice:
|
||||
reset_slice(p_Dec->p_Vid);
|
||||
p_Dec->next_state = SliceSTATE_ReadNalu;
|
||||
H264D_LOG("SliceSTATE_ResetSlice");
|
||||
break;
|
||||
case SliceSTATE_ReadNalu:
|
||||
p_head = (H264dNaluHead_t *)p_curdata;
|
||||
@@ -884,6 +895,7 @@ MPP_RET parse_loop(H264_DecCtx_t *p_Dec)
|
||||
p_Dec->nalu_ret = EndOfNalu;
|
||||
p_Dec->next_state = SliceSTATE_ParseNalu;
|
||||
}
|
||||
H264D_LOG("SliceSTATE_ReadNalu");
|
||||
break;
|
||||
case SliceSTATE_ParseNalu:
|
||||
(ret = parser_one_nalu(&p_Dec->p_Cur->slice));
|
||||
@@ -894,21 +906,25 @@ MPP_RET parse_loop(H264_DecCtx_t *p_Dec)
|
||||
} else {
|
||||
p_Dec->next_state = SliceSTATE_ReadNalu;
|
||||
}
|
||||
H264D_LOG("SliceSTATE_ParseNalu");
|
||||
break;
|
||||
case SliceSTATE_InitPicture:
|
||||
(ret = init_picture(&p_Dec->p_Cur->slice));
|
||||
p_Dec->next_state = SliceSTATE_GetSliceData;
|
||||
H264D_LOG("SliceSTATE_InitPicture");
|
||||
break;
|
||||
case SliceSTATE_GetSliceData:
|
||||
(ret = fill_slice_syntax(&p_Dec->p_Cur->slice, p_Dec->dxva_ctx));
|
||||
p_Dec->p_Vid->iNumOfSlicesDecoded++;
|
||||
p_Dec->next_state = SliceSTATE_ResetSlice;
|
||||
H264D_LOG("SliceSTATE_GetSliceData");
|
||||
break;
|
||||
case SliceSTATE_RegisterOneFrame:
|
||||
commit_buffer(p_Dec->dxva_ctx);
|
||||
while_loop_flag = 0;
|
||||
p_Dec->is_parser_end = 1;
|
||||
p_Dec->next_state = SliceSTATE_ReadNalu;
|
||||
H264D_LOG("SliceSTATE_RegisterOneFrame");
|
||||
break;
|
||||
default:
|
||||
ret = MPP_NOK;
|
||||
|
@@ -179,11 +179,11 @@ static MPP_RET parser_sps(BitReadCtx_t *p_bitctx, H264_SPS_t *cur_sps, H264_DecC
|
||||
|| cur_sps->profile_idc == 128 || cur_sps->profile_idc == 138) {
|
||||
READ_UE(p_bitctx, &cur_sps->chroma_format_idc, "chroma_format_idc");
|
||||
ASSERT(cur_sps->chroma_format_idc < 4);
|
||||
if (cur_sps->chroma_format_idc >= 3) {
|
||||
H264D_ERR("ERROR: Not support chroma_format_idc=%d.", cur_sps->chroma_format_idc);
|
||||
p_Dec->err_ctx.err_flag |= VPU_FRAME_ERR_UNSUPPORT;
|
||||
goto __FAILED;
|
||||
}
|
||||
//if (cur_sps->chroma_format_idc >= 3) {
|
||||
// H264D_ERR("ERROR: Not support chroma_format_idc=%d.", cur_sps->chroma_format_idc);
|
||||
// p_Dec->err_ctx.err_flag |= VPU_FRAME_ERR_UNSUPPORT;
|
||||
// goto __FAILED;
|
||||
//}
|
||||
//if (cur_sps->chroma_format_idc == 3) {
|
||||
// READ_ONEBIT(p_bitctx, &cur_sps->separate_colour_plane_flag, "separate_colour_plane_flag");
|
||||
// LogError(p_bitctx->ctx, "Not support YUV444 format current.");
|
||||
|
@@ -780,9 +780,10 @@ MPP_RET mpp_buf_slot_set_prop(MppBufSlots slots, RK_S32 index, SlotPropType type
|
||||
*/
|
||||
generate_info_set(impl, frame);
|
||||
if (mpp_frame_info_cmp(impl->info, impl->info_set)) {
|
||||
#ifdef ANDROID
|
||||
MppFrameImpl *old = (MppFrameImpl *)impl->info;
|
||||
|
||||
impl->info_changed = 1;
|
||||
#ifdef ANDROID
|
||||
mpp_log("info change found\n");
|
||||
mpp_log("old width %4d height %4d stride hor %4d ver %4d\n",
|
||||
old->width, old->height, old->hor_stride, old->ver_stride);
|
||||
@@ -790,7 +791,6 @@ MPP_RET mpp_buf_slot_set_prop(MppBufSlots slots, RK_S32 index, SlotPropType type
|
||||
dst->width, dst->height, dst->hor_stride, dst->ver_stride);
|
||||
#endif
|
||||
// info change found here
|
||||
impl->info_changed = 1;
|
||||
}
|
||||
} break;
|
||||
case SLOT_BUFFER: {
|
||||
|
@@ -191,9 +191,9 @@ MPP_RET rkv_alloc_fifo_packet(H264dLogCtx_t *logctx, H264dRkvPkt_t *pkts)
|
||||
{
|
||||
MPP_RET ret = MPP_ERR_UNKNOW;
|
||||
LogCtx_t *log_driver = NULL;
|
||||
RK_U32 pps_size = 256 * 32 + 16;
|
||||
RK_U32 rps_size = 128 + 16;
|
||||
RK_U32 sclst_size = 256;
|
||||
RK_U32 pps_size = RKV_SPSPPS_SIZE + 64;
|
||||
RK_U32 rps_size = RKV_RPS_SIZE + 64;
|
||||
RK_U32 sclst_size = RKV_SCALING_LIST_SIZE + 64;
|
||||
RK_U32 regs_size = sizeof(H264dRkvRegs_t);
|
||||
|
||||
FunctionIn(logctx->parr[RUN_HAL]);
|
||||
@@ -476,6 +476,7 @@ void rkv_generate_regs(void *hal, HalTaskInfo *task, FifoCtx_t *pkt)
|
||||
mpp_buf_slot_get_prop(p_hal->packet_slots, task->dec.input, SLOT_BUFFER, &bitstream_buf);
|
||||
p_regs->swreg4_strm_rlc_base.sw_strm_rlc_base = mpp_buffer_get_fd(bitstream_buf);
|
||||
//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
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user