mirror of
https://github.com/nyanmisaka/mpp.git
synced 2025-10-19 07:24:34 +08:00
[h264d]1. add mvc key and output frame; 2. correct cabac_size; 3. direct use slice_id instead of calculation
git-svn-id: https://10.10.10.66:8443/svn/MediaProcessPlatform/trunk/mpp@547 6e48237b-75ef-9749-8fc9-41990f28c85a
This commit is contained in:
@@ -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]);
|
||||
|
||||
p_Inp->init = *init;
|
||||
|
||||
p_Inp->mvc_disable = 1;
|
||||
FunctionOut(p_Inp->p_Dec->logctx.parr[RUN_PARSE]);
|
||||
__RETURN:
|
||||
return ret = MPP_OK;
|
||||
@@ -274,7 +274,7 @@ static MPP_RET init_vid_ctx(H264dVideoCtx_t *p_Vid)
|
||||
p_Vid->subspsSet[i].num_views_minus1 = -1;
|
||||
p_Vid->subspsSet[i].num_level_values_signalled_minus1 = -1;
|
||||
}
|
||||
p_Vid->has_get_i_frame_flag = 0;
|
||||
p_Vid->iframe_cnt = 0;
|
||||
FunctionOut(p_Vid->p_Dec->logctx.parr[RUN_PARSE]);
|
||||
__RETURN:
|
||||
return ret = MPP_OK;
|
||||
@@ -538,6 +538,14 @@ MPP_RET h264d_reset(void *decoder)
|
||||
FunctionIn(p_Dec->logctx.parr[RUN_PARSE]);
|
||||
//mpp_log_f("reset In,g_framecnt=%d ", p_Dec->p_Vid->g_framecnt);
|
||||
|
||||
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));
|
||||
if (p_Dec->mvc_valid)
|
||||
{ // layer_id == 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));
|
||||
flush_muti_view_output(p_Dec->frame_slots, p_Dec->p_Vid->outlist, p_Dec->p_Vid);
|
||||
}
|
||||
//!< reset input parameter
|
||||
p_Dec->p_Inp->in_buf = NULL;
|
||||
p_Dec->p_Inp->pkt_eos = 0;
|
||||
@@ -551,7 +559,7 @@ MPP_RET h264d_reset(void *decoder)
|
||||
p_Dec->p_Vid->g_framecnt = 0;
|
||||
p_Dec->p_Vid->last_outputpoc[0] = -1;
|
||||
p_Dec->p_Vid->last_outputpoc[1] = -1;
|
||||
p_Dec->p_Vid->has_get_i_frame_flag = 0;
|
||||
p_Dec->p_Vid->iframe_cnt = 0;
|
||||
//!< reset current time stamp
|
||||
p_Dec->p_Cur->last_dts = 0;
|
||||
p_Dec->p_Cur->last_pts = 0;
|
||||
@@ -584,13 +592,7 @@ MPP_RET h264d_reset(void *decoder)
|
||||
memset(p_Dec->dpb_old[1], 0, MAX_DPB_SIZE * sizeof(H264_DpbInfo_t));
|
||||
|
||||
//!< reset dpb
|
||||
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));
|
||||
if (p_Dec->mvc_valid) {
|
||||
// layer_id == 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));
|
||||
}
|
||||
for (i = 0; i < MAX_MARK_SIZE; i++) {
|
||||
p_Dec->dpb_mark[i].top_used = 0;
|
||||
p_Dec->dpb_mark[i].bot_used = 0;
|
||||
|
@@ -941,7 +941,6 @@ static void write_picture(H264_StorePic_t *p, H264dVideoCtx_t *p_Vid)
|
||||
mpp_frame_set_poc(frame, p->poc);
|
||||
p_mark->poc = p->poc;
|
||||
p_mark->pts = mpp_frame_get_pts(frame);
|
||||
|
||||
mpp_frame_set_viewid(frame, p->layer_id);
|
||||
//if (p->layer_id == 1) {
|
||||
// mpp_frame_set_discard(frame, 1);
|
||||
@@ -950,36 +949,28 @@ static void write_picture(H264_StorePic_t *p, H264dVideoCtx_t *p_Vid)
|
||||
// mpp_frame_set_discard(frame, 1);
|
||||
//}
|
||||
|
||||
p_Vid->has_get_i_frame_flag = (p_Vid->has_get_i_frame_flag || (p->slice_type == I_SLICE)) ? 1 : 0;
|
||||
if (!p_Vid->has_get_i_frame_flag) {
|
||||
mpp_frame_set_discard(frame, 1);
|
||||
p_Vid->iframe_cnt += (p->slice_type == I_SLICE) ? 1 : 0;
|
||||
if (!p_Vid->iframe_cnt) {
|
||||
mpp_frame_set_errinfo(frame, VPU_FRAME_ERR_UNKNOW);
|
||||
}
|
||||
if (p->poc
|
||||
&& (p_Vid->last_outputpoc[p->layer_id] >= 0)
|
||||
&& (p->poc < p_Vid->last_outputpoc[p->layer_id])) {
|
||||
mpp_frame_set_discard(frame, 1);
|
||||
mpp_frame_set_errinfo(frame, VPU_FRAME_ERR_UNKNOW);
|
||||
}
|
||||
H264D_LOG("[dispaly] layer_id=%d, pic_num=%d, poc=%d, last_poc=%d, slice_type=%d(isdir=%d), 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, mpp_frame_get_pts(frame), p_Vid->g_framecnt);
|
||||
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);
|
||||
|
||||
|
||||
if (p_Vid->p_Dec->mvc_valid) {
|
||||
muti_view_output(p_Vid->p_Dec->frame_slots, p_mark, p_Vid);
|
||||
} else {
|
||||
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_mark->out_flag = 0;
|
||||
}
|
||||
// FPRINT(g_debug_file0, "[WRITE_PICTURE] lay_id=%d, g_frame_no=%d, mark_idx=%d, slot_idx=%d, pts=%lld \n",
|
||||
//p->layer_id, p_Vid->g_framecnt, p_mark->mark_idx, p_mark->slot_idx, mpp_frame_get_pts(frame));
|
||||
|
||||
//H264D_LOG("[WRITE_PICTURE] lay_id=%d, g_frame_no=%d, mark_idx=%d, slot_idx=%d, pts=%lld \n",
|
||||
// p->layer_id, p_Vid->g_framecnt, p_mark->mark_idx, p_mark->slot_idx, mpp_frame_get_pts(frame));
|
||||
|
||||
//LogInfo(p_Vid->p_Dec->logctx.parr[RUN_PARSE], "[WRITE_PICTURE] g_frame_cnt=%d", p_Vid->g_framecnt);
|
||||
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);
|
||||
} else
|
||||
{
|
||||
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_mark->out_flag = 0;
|
||||
}
|
||||
H264D_LOG("[dispaly] layer_id=%d, pic_num=%d, poc=%d, last_poc=%d, slice_type=%d(isdir=%d), 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, mpp_frame_get_pts(frame), p_Vid->g_framecnt);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2214,7 +2205,7 @@ MPP_RET prepare_init_dpb_info(H264_SLICE_t *currSlice)
|
||||
//}
|
||||
|
||||
//!< reset left parameters
|
||||
for (; i < 16; i++) {
|
||||
for (; i < MAX_DPB_SIZE; i++) {
|
||||
reset_dpb_info(&p_Dec->dpb_info[i]);
|
||||
}
|
||||
|
||||
@@ -2390,9 +2381,11 @@ __RETURN:
|
||||
MPP_RET update_dpb(H264_DecCtx_t *p_Dec)
|
||||
{
|
||||
MPP_RET ret = MPP_ERR_UNKNOW;
|
||||
|
||||
p_Dec->p_Vid->exit_picture_flag = 1;
|
||||
p_Dec->p_Vid->have_outpicture_flag = 1;
|
||||
if(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);
|
||||
if(MPP_OK != ret) {
|
||||
p_Dec->err_ctx.err_flag |= VPU_FRAME_ERR_UNKNOW;
|
||||
}
|
||||
p_Dec->p_Vid->iNumOfSlicesDecoded = 0;
|
||||
|
@@ -839,6 +839,7 @@ typedef struct h264d_input_ctx_t {
|
||||
RK_S64 in_pts;
|
||||
RK_S64 in_dts;
|
||||
RK_U8 has_get_eos;
|
||||
RK_U8 mvc_disable;
|
||||
//!< output data
|
||||
RK_U8 *out_buf;
|
||||
RK_U32 out_length;
|
||||
@@ -986,12 +987,12 @@ typedef struct h264d_video_ctx_t {
|
||||
RK_S32 have_outpicture_flag;
|
||||
RK_S32 exit_picture_flag;
|
||||
RK_S32 active_mvc_sps_flag;
|
||||
|
||||
//!< for error tolerance
|
||||
RK_U32 g_framecnt;
|
||||
RK_U32 dpb_size[MAX_NUM_DPB_LAYERS];
|
||||
struct h264d_outlist_t outlist[MAX_NUM_DPB_LAYERS];
|
||||
RK_S32 last_outputpoc[MAX_NUM_DPB_LAYERS];
|
||||
RK_U32 has_get_i_frame_flag;
|
||||
RK_U32 iframe_cnt;
|
||||
} H264dVideoCtx_t;
|
||||
|
||||
typedef struct h264d_mem_t {
|
||||
@@ -1013,7 +1014,7 @@ typedef enum nalu_state_tpye {
|
||||
ReadNaluError,
|
||||
StartofNalu,
|
||||
EndofStream,
|
||||
//ReallocBufError,
|
||||
MvcDisAble,
|
||||
MidOfNalu,
|
||||
EndOfNalu,
|
||||
StartOfPicture,
|
||||
|
@@ -378,13 +378,14 @@ __FAILED:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void dpb_mark_malloc(H264dVideoCtx_t *p_Vid, RK_S32 structure, RK_U8 combine_flag, RK_S32 layer_id)
|
||||
static void dpb_mark_malloc(H264dVideoCtx_t *p_Vid, H264_StorePic_t *dec_pic, RK_U8 combine_flag, RK_S32 layer_id)
|
||||
{
|
||||
RK_U8 idx = 1;
|
||||
H264_DpbMark_t *cur_mark = NULL;
|
||||
RK_U32 hor_stride = 0, ver_stride = 0;
|
||||
H264_DecCtx_t *p_Dec = p_Vid->p_Dec;
|
||||
H264_DpbMark_t *p_mark = p_Vid->p_Dec->dpb_mark;
|
||||
RK_S32 structure = dec_pic->structure;
|
||||
|
||||
//!< malloc
|
||||
if (!combine_flag) {
|
||||
@@ -547,7 +548,7 @@ static MPP_RET alloc_decpic(H264_SLICE_t *currSlice)
|
||||
|
||||
combine_flag = get_filed_dpb_combine_flag(p_Dpb, dec_pic);
|
||||
dec_pic->mem_malloc_type = Mem_Malloc;
|
||||
dpb_mark_malloc(p_Vid, dec_pic->structure, combine_flag, dec_pic->layer_id); // malloc dpb_memory
|
||||
dpb_mark_malloc(p_Vid, dec_pic, combine_flag, dec_pic->layer_id); // malloc dpb_memory
|
||||
dec_pic->mem_mark = p_Vid->active_dpb_mark[currSlice->layer_id];
|
||||
dec_pic->mem_mark->pic = dec_pic;
|
||||
dec_pic->colmv_no_used_flag = 0;
|
||||
|
@@ -225,6 +225,9 @@ static MPP_RET parser_one_nalu(H264_SLICE_t *currSlice)
|
||||
} else {
|
||||
currSlice->p_Dec->nalu_ret = StartOfSlice;
|
||||
}
|
||||
if (currSlice->layer_id && currSlice->p_Inp->mvc_disable) {
|
||||
currSlice->p_Dec->nalu_ret = MvcDisAble;
|
||||
}
|
||||
LogTrace(runlog, "nalu_type=SLICE.");
|
||||
break;
|
||||
case NALU_TYPE_SPS:
|
||||
@@ -603,7 +606,7 @@ MPP_RET parse_prepare_fast(H264dInputCtx_t *p_Inp, H264dCurCtx_t *p_Cur)
|
||||
//}
|
||||
|
||||
if (p_strm->nalu_type == NALU_TYPE_SLICE
|
||||
|| p_strm->nalu_type == NALU_TYPE_IDR) {
|
||||
|| p_strm->nalu_type == NALU_TYPE_IDR || p_strm->nalu_type == NALU_TYPE_SLC_EXT) {
|
||||
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;
|
||||
@@ -903,6 +906,12 @@ MPP_RET parse_loop(H264_DecCtx_t *p_Dec)
|
||||
p_Dec->next_state = SliceSTATE_GetSliceData;
|
||||
} else if (p_Dec->nalu_ret == StartOfPicture) {
|
||||
p_Dec->next_state = SliceSTATE_InitPicture;
|
||||
} else if (p_Dec->nalu_ret == MvcDisAble) {
|
||||
p_Dec->next_state = SliceSTATE_ResetSlice;
|
||||
p_Dec->dxva_ctx->slice_count = 0;
|
||||
p_Dec->dxva_ctx->strm_offset = 0;
|
||||
H264D_LOG("xxxxxxxx MVC disable");
|
||||
goto __RETURN;
|
||||
} else {
|
||||
p_Dec->next_state = SliceSTATE_ReadNalu;
|
||||
}
|
||||
@@ -935,9 +944,9 @@ MPP_RET parse_loop(H264_DecCtx_t *p_Dec)
|
||||
//}
|
||||
}
|
||||
FunctionOut(p_Dec->logctx.parr[RUN_PARSE]);
|
||||
//__RETURN:
|
||||
__RETURN:
|
||||
return ret = MPP_OK;
|
||||
__FAILED:
|
||||
//__FAILED:
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@@ -34,7 +34,7 @@ static void free_slice_drpm_buffer(H264_SLICE_t *currSlice) // dec_ref_pic_mark
|
||||
MPP_FREE(tmp_drpm);
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
static RK_S32 get_voidx(H264_subSPS_t *subset_spsSet, H264_subSPS_t **subset_sps, RK_S32 iViewId)
|
||||
{
|
||||
RK_S32 i = 0, iVOIdx = -1;
|
||||
@@ -68,7 +68,7 @@ static RK_S32 get_voidx(H264_subSPS_t *subset_spsSet, H264_subSPS_t **subset_sps
|
||||
|
||||
return iVOIdx;
|
||||
}
|
||||
#if 0
|
||||
|
||||
static RK_U32 is_new_picture(H264_SLICE_t *currSlice)
|
||||
{
|
||||
RK_U32 is_new_pic_flag = 0;
|
||||
@@ -351,7 +351,9 @@ static void init_slice_parmeters(H264_SLICE_t *currSlice)
|
||||
currSlice->inter_view_flag = 1;
|
||||
currSlice->anchor_pic_flag = currSlice->idr_flag;
|
||||
}
|
||||
currSlice->layer_id = get_voidx(p_Vid->subspsSet, &p_Vid->active_subsps, currSlice->view_id);
|
||||
//currSlice->layer_id = get_voidx(p_Vid->subspsSet, &p_Vid->active_subsps, currSlice->view_id);
|
||||
currSlice->layer_id = currSlice->view_id;
|
||||
H264D_LOG("currSlice->layer_id=%d", currSlice->layer_id);
|
||||
if (currSlice->layer_id >= 0) { // if not found, layer_id == -1
|
||||
currSlice->p_Dpb = p_Vid->p_Dpb_layer[currSlice->layer_id];
|
||||
}
|
||||
|
@@ -246,6 +246,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));
|
||||
}
|
||||
cur_sps->Valid = 1;
|
||||
(void)p_Dec;
|
||||
|
||||
return ret = MPP_OK;
|
||||
__BITREAD_ERR:
|
||||
|
@@ -57,7 +57,7 @@ static void fill_picture_parameters(const HEVCContext *h,
|
||||
const HEVCPPS *pps = (HEVCPPS *)h->pps_list[h->sh.pps_id];
|
||||
const HEVCSPS *sps = (HEVCSPS *)h->sps_list[pps->sps_id];
|
||||
|
||||
RK_U32 i, j;
|
||||
RK_S32 i, j;
|
||||
RK_U32 rps_used[16];
|
||||
RK_U32 nb_rps_used;
|
||||
|
||||
@@ -146,10 +146,10 @@ static void fill_picture_parameters(const HEVCContext *h,
|
||||
pp->num_tile_rows_minus1 = pps->num_tile_rows - 1;
|
||||
|
||||
if (!pps->uniform_spacing_flag) {
|
||||
for (i = 0; i < (RK_U32)pps->num_tile_columns; i++)
|
||||
for (i = 0; i < pps->num_tile_columns; i++)
|
||||
pp->column_width_minus1[i] = pps->column_width[i] - 1;
|
||||
|
||||
for (i = 0; i < (RK_U32)pps->num_tile_rows; i++)
|
||||
for (i = 0; i < pps->num_tile_rows; i++)
|
||||
pp->row_height_minus1[i] = pps->row_height[i] - 1;
|
||||
}
|
||||
}
|
||||
@@ -177,7 +177,7 @@ static void fill_picture_parameters(const HEVCContext *h,
|
||||
while (!frame && j < MPP_ARRAY_ELEMS(h->DPB)) {
|
||||
if (&h->DPB[j] != current_picture &&
|
||||
(h->DPB[j].flags & (HEVC_FRAME_FLAG_LONG_REF | HEVC_FRAME_FLAG_SHORT_REF))) {
|
||||
RK_S32 k = 0;
|
||||
RK_U32 k = 0;
|
||||
for (k = 0; k < nb_rps_used; k++) { /*skip fill RefPicList no used in rps*/
|
||||
if (rps_used[k] == h->DPB[j].poc) {
|
||||
frame = &h->DPB[j];
|
||||
@@ -204,7 +204,7 @@ static void fill_picture_parameters(const HEVCContext *h,
|
||||
const RefPicList *rpl = &h->rps[ref_idx]; \
|
||||
for (i = 0, j = 0; i < MPP_ARRAY_ELEMS(pp->ref_list); i++) { \
|
||||
const HEVCFrame *frame = NULL; \
|
||||
while (!frame && j < (RK_U32)rpl->nb_refs) \
|
||||
while (!frame && j < rpl->nb_refs) \
|
||||
frame = rpl->ref[j++]; \
|
||||
if (frame) \
|
||||
pp->ref_list[i] = get_refpic_index(pp, frame->slot_index); \
|
||||
|
@@ -842,6 +842,7 @@ MPP_RET mpp_buf_slot_get_prop(MppBufSlots slots, RK_S32 index, SlotPropType type
|
||||
} break;
|
||||
case SLOT_FRAME_PTR: {
|
||||
MppFrame *frame = (MppFrame *)val;
|
||||
mpp_assert(slot->status.has_frame);
|
||||
*frame = (slot->status.has_frame) ? (slot->frame) : (NULL);
|
||||
} break;
|
||||
case SLOT_BUFFER: {
|
||||
|
@@ -32,7 +32,7 @@
|
||||
#include "hal_h264d_rkv_pkt.h"
|
||||
#include "hal_h264d_rkv_reg.h"
|
||||
|
||||
const RK_U32 H264_RKV_Cabac_table[460 * 8] = {
|
||||
const RK_U32 H264_RKV_Cabac_table[926 * 4] = {
|
||||
0x3602f114, 0xf1144a03, 0x4a033602, 0x68e97fe4, 0x36ff35fa, 0x21173307,
|
||||
0x00150217, 0x31000901, 0x390576db, 0x41f54ef3, 0x310c3e01, 0x321149fc,
|
||||
0x2b094012, 0x431a001d, 0x68095a10, 0x68ec7fd2, 0x4ef34301, 0x3e0141f5,
|
||||
|
@@ -221,7 +221,7 @@ typedef struct h264d_rkv_regs_t {
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern const RK_U32 H264_RKV_Cabac_table[460 * 8];
|
||||
extern const RK_U32 H264_RKV_Cabac_table[926 * 4];
|
||||
|
||||
MPP_RET rkv_h264d_init (void *hal, MppHalCfg *cfg);
|
||||
MPP_RET rkv_h264d_deinit (void *hal);
|
||||
|
Reference in New Issue
Block a user