mirror of
https://github.com/nyanmisaka/mpp.git
synced 2025-10-07 01:52:46 +08:00
[mpp_frame.h] add dispaly && viewid functions
[mpp_buf_slot.cpp] add case SLOT_FRAME_PTR, get frame_impl pointer [mpp_dec.cpp] add display condition [h264_module] update time stamp && prepare function git-svn-id: https://10.10.10.66:8443/svn/MediaProcessPlatform/trunk/mpp@456 6e48237b-75ef-9749-8fc9-41990f28c85a
This commit is contained in:
@@ -153,6 +153,10 @@ RK_U32 mpp_frame_get_ver_stride(const MppFrame frame);
|
||||
void mpp_frame_set_ver_stride(MppFrame frame, RK_U32 ver_stride);
|
||||
RK_U32 mpp_frame_get_mode(const MppFrame frame);
|
||||
void mpp_frame_set_mode(MppFrame frame, RK_U32 mode);
|
||||
RK_U32 mpp_frame_get_display(const MppFrame frame);
|
||||
void mpp_frame_set_display(MppFrame frame, RK_U32 display);
|
||||
RK_U32 mpp_frame_get_viewid(const MppFrame frame);
|
||||
void mpp_frame_set_viewid(MppFrame frame, RK_U32 viewid);
|
||||
RK_S64 mpp_frame_get_pts(const MppFrame frame);
|
||||
void mpp_frame_set_pts(MppFrame frame, RK_S64 pts);
|
||||
RK_S64 mpp_frame_get_dts(const MppFrame frame);
|
||||
|
@@ -346,17 +346,17 @@ static MPP_RET init_dec_ctx(H264_DecCtx_t *p_Dec)
|
||||
FunctionIn(p_Dec->logctx.parr[RUN_PARSE]);
|
||||
p_Dec->mem = mpp_calloc(H264_DecMem_t, 1);
|
||||
MEM_CHECK(ret, p_Dec->mem);
|
||||
p_Dec->dpb_mark = p_Dec->mem->dpb_mark; //!< for write out, MAX_DPB_SIZE
|
||||
p_Dec->dpb_info = p_Dec->mem->dpb_info; //!< 16
|
||||
p_Dec->refpic_info_p = p_Dec->mem->refpic_info_p; //!< 32
|
||||
p_Dec->dpb_mark = p_Dec->mem->dpb_mark; //!< for write out, MAX_DPB_SIZE
|
||||
p_Dec->dpb_info = p_Dec->mem->dpb_info; //!< 16
|
||||
p_Dec->dpb_old[0] = p_Dec->mem->dpb_old[0];
|
||||
p_Dec->dpb_old[1] = p_Dec->mem->dpb_old[1];
|
||||
p_Dec->refpic_info_p = p_Dec->mem->refpic_info_p; //!< 32
|
||||
p_Dec->refpic_info_b[0] = p_Dec->mem->refpic_info_b[0]; //!< [2][32]
|
||||
p_Dec->refpic_info_b[1] = p_Dec->mem->refpic_info_b[1]; //!< [2][32]
|
||||
//!< init dxva memory
|
||||
p_Dec->mem->dxva_ctx.p_Dec = p_Dec;
|
||||
FUN_CHECK(ret = init_dxva_ctx(&p_Dec->mem->dxva_ctx));
|
||||
p_Dec->dxva_ctx = &p_Dec->mem->dxva_ctx;
|
||||
//!< init frame slots, store frame buffer size
|
||||
mpp_buf_slot_setup(p_Dec->frame_slots, MAX_MARK_SIZE);
|
||||
//!< init Dpb_memory Mark, for fpga check
|
||||
for (i = 0; i < MAX_MARK_SIZE; i++) {
|
||||
p_Dec->dpb_mark[i].top_used = 0;
|
||||
@@ -370,7 +370,7 @@ static MPP_RET init_dec_ctx(H264_DecCtx_t *p_Dec)
|
||||
mpp_packet_init(&p_Dec->task_pkt, p_Dec->dxva_ctx->bitstream, p_Dec->dxva_ctx->max_strm_size);
|
||||
MEM_CHECK(ret, p_Dec->task_pkt);
|
||||
//!< set Dec support decoder method
|
||||
p_Dec->spt_decode_mtds = MPP_DEC_BY_FRAME | MPP_DEC_BY_SLICE;
|
||||
p_Dec->spt_decode_mtds = MPP_DEC_BY_FRAME;
|
||||
p_Dec->next_state = SliceSTATE_ResetSlice;
|
||||
p_Dec->nalu_ret = NALU_NULL;
|
||||
p_Dec->is_first_frame = 1;
|
||||
@@ -384,8 +384,23 @@ __FAILED:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void get_pkt_timestamp(H264dCurStream_t *p_strm, H264dInputCtx_t *p_Inp, MppPacket pkt)
|
||||
{
|
||||
H264dTimeStamp_t *p_last = NULL, *p_curr = NULL;
|
||||
|
||||
if (!p_Inp->in_length){
|
||||
p_last = &p_strm->pkt_ts[p_strm->pkt_ts_idx];
|
||||
p_strm->pkt_ts_idx = (p_strm->pkt_ts_idx + 1) % MAX_PTS_NUM ;
|
||||
p_curr = &p_strm->pkt_ts[p_strm->pkt_ts_idx];
|
||||
|
||||
p_curr->begin_off = p_last->end_off;
|
||||
p_curr->end_off = p_curr->begin_off + mpp_packet_get_length(pkt);
|
||||
p_curr->pts = mpp_packet_get_pts(pkt);
|
||||
p_curr->dts = mpp_packet_get_dts(pkt);
|
||||
|
||||
mpp_log("[init_pts] prepare_pts=%lld, g_framecnt=%d \n",p_curr->pts, p_Inp->p_Vid->g_framecnt);
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
***********************************************************************
|
||||
@@ -473,40 +488,59 @@ MPP_RET h264d_reset(void *decoder)
|
||||
RK_U32 i = 0;
|
||||
MPP_RET ret = MPP_ERR_UNKNOW;
|
||||
H264_DecCtx_t *p_Dec = (H264_DecCtx_t *)decoder;
|
||||
H264dCurStream_t *p_strm = NULL;
|
||||
|
||||
INP_CHECK(ret, !decoder);
|
||||
FunctionIn(p_Dec->logctx.parr[RUN_PARSE]);
|
||||
mpp_log_f("reset In,g_framecnt=%d ", p_Dec->p_Vid->g_framecnt);
|
||||
|
||||
//!< reset input parameter
|
||||
p_Dec->p_Inp->in_buf = NULL;
|
||||
p_Dec->p_Inp->in_size = 0;
|
||||
p_Dec->p_Inp->is_eos = 0;
|
||||
p_Dec->p_Inp->pts = -1;
|
||||
p_Dec->p_Inp->dts = -1;
|
||||
p_Dec->p_Inp->pkt_eos = 0;
|
||||
p_Dec->p_Inp->task_eos = 0;
|
||||
p_Dec->p_Inp->in_pts = 0;
|
||||
p_Dec->p_Inp->in_dts = 0;
|
||||
p_Dec->p_Inp->out_buf = NULL;
|
||||
p_Dec->p_Inp->out_length = 0;
|
||||
//!< reset video parameter
|
||||
p_Dec->p_Vid->g_framecnt = 0;
|
||||
//!< reset current stream
|
||||
p_Dec->p_Cur->strm.prefixdata[0] = 0xff;
|
||||
p_Dec->p_Cur->strm.prefixdata[1] = 0xff;
|
||||
p_Dec->p_Cur->strm.prefixdata[2] = 0xff;
|
||||
p_Dec->p_Cur->strm.nalu_offset = 0;
|
||||
p_Dec->p_Cur->strm.nalu_len = 0;
|
||||
p_Dec->p_Cur->strm.head_offset = 0;
|
||||
p_Dec->p_Cur->strm.startcode_found = 0;
|
||||
p_Dec->p_Cur->strm.endcode_found = 0;
|
||||
//!< reset current time stamp
|
||||
p_Dec->p_Cur->last_dts = 0;
|
||||
p_Dec->p_Cur->last_pts = 0;
|
||||
p_Dec->p_Cur->curr_dts = 0;
|
||||
p_Dec->p_Cur->curr_pts = 0;
|
||||
//!< reset current stream
|
||||
p_strm = &p_Dec->p_Cur->strm;
|
||||
p_strm->prefixdata[0] = 0xff;
|
||||
p_strm->prefixdata[1] = 0xff;
|
||||
p_strm->prefixdata[2] = 0xff;
|
||||
p_strm->nalu_offset = 0;
|
||||
p_strm->nalu_len = 0;
|
||||
p_strm->head_offset = 0;
|
||||
p_strm->startcode_found = 0;
|
||||
p_strm->endcode_found = 0;
|
||||
p_strm->pkt_ts_idx = 0;
|
||||
p_strm->pkt_used_bytes = 0;
|
||||
memset(p_strm->pkt_ts, 0, MAX_PTS_NUM*sizeof(H264dTimeStamp_t));
|
||||
//!< reset decoder parameter
|
||||
p_Dec->next_state = SliceSTATE_ResetSlice;
|
||||
p_Dec->nalu_ret = NALU_NULL;
|
||||
p_Dec->is_first_frame = 1;
|
||||
p_Dec->is_new_frame = 0;
|
||||
p_Dec->is_parser_end = 0;
|
||||
p_Dec->is_new_frame = 0;
|
||||
p_Dec->is_parser_end = 0;
|
||||
p_Dec->dxva_ctx->strm_offset = 0;
|
||||
p_Dec->dxva_ctx->slice_count = 0;
|
||||
|
||||
memset(p_Dec->dpb_old[0], 0, MAX_DPB_SIZE * sizeof(H264_DpbInfo_t));
|
||||
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->p_Vid->active_mvc_sps_flag) { // layer_id == 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++) {
|
||||
@@ -539,15 +573,16 @@ MPP_RET h264d_flush(void *decoder)
|
||||
FunctionIn(p_Dec->logctx.parr[RUN_PARSE]);
|
||||
|
||||
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));
|
||||
//free_dpb(p_Dec->p_Vid->p_Dpb_layer[0]);
|
||||
if (p_Dec->p_Vid->active_mvc_sps_flag) { // layer_id == 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]);
|
||||
//if (p_Dec->mvc_valid)
|
||||
{ // layer_id == 1
|
||||
FUN_CHECK(ret = flush_dpb(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]);
|
||||
//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]);
|
||||
}
|
||||
mpp_buf_slot_set_prop(p_Dec->frame_slots, p_Dec->last_frame_slot_idx, SLOT_EOS, &p_Dec->p_Inp->is_eos);
|
||||
|
||||
mpp_buf_slot_set_prop(p_Dec->frame_slots, p_Dec->last_frame_slot_idx, SLOT_EOS, &p_Dec->p_Inp->task_eos);
|
||||
FPRINT(g_debug_file0, "[FLUSH] -------- flush over.------\n");
|
||||
FunctionOut(p_Dec->logctx.parr[RUN_PARSE]);
|
||||
__RETURN:
|
||||
return ret = MPP_OK;
|
||||
@@ -588,38 +623,50 @@ MPP_RET h264d_prepare(void *decoder, MppPacket pkt, HalDecTask *task)
|
||||
MPP_RET ret = MPP_ERR_UNKNOW;
|
||||
LogCtx_t *logctx = NULL;
|
||||
H264_DecCtx_t *p_Dec = (H264_DecCtx_t *)decoder;
|
||||
|
||||
INP_CHECK(ret, !decoder && !pkt && !task);
|
||||
FunctionIn(p_Dec->logctx.parr[RUN_PARSE]);
|
||||
logctx = p_Dec->logctx.parr[RUN_PARSE];
|
||||
//LogTrace(logctx, "Prepare In:len=%d, valid=%d ", mpp_packet_get_length(pkt), task->valid);
|
||||
|
||||
p_Dec->p_Inp->in_buf = (RK_U8 *)mpp_packet_get_pos(pkt);
|
||||
p_Dec->p_Inp->in_length = mpp_packet_get_length(pkt);
|
||||
p_Dec->p_Inp->is_eos = mpp_packet_get_eos(pkt);
|
||||
p_Dec->p_Inp->in_size = &((MppPacketImpl *)pkt)->length;
|
||||
p_Dec->p_Inp->in_pts = mpp_packet_get_pts(pkt);
|
||||
p_Dec->p_Inp->in_dts = mpp_packet_get_dts(pkt);
|
||||
//!< restore time stamp
|
||||
get_pkt_timestamp(&p_Dec->p_Cur->strm, p_Dec->p_Inp, pkt);
|
||||
mpp_err("[ pkt_in timeUs ] preprare input_pts=%lld \n",p_Dec->p_Inp->in_pts);
|
||||
if (mpp_packet_get_eos(pkt)) {
|
||||
p_Dec->p_Inp->in_buf = NULL;
|
||||
p_Dec->p_Inp->in_length = 0;
|
||||
p_Dec->p_Inp->pkt_eos = 1;
|
||||
p_Dec->p_Inp->in_size = NULL;
|
||||
} else {
|
||||
p_Dec->p_Inp->in_buf = (RK_U8 *)mpp_packet_get_pos(pkt);
|
||||
p_Dec->p_Inp->in_length = mpp_packet_get_length(pkt);
|
||||
p_Dec->p_Inp->pkt_eos = 0;
|
||||
p_Dec->p_Inp->in_size = &((MppPacketImpl *)pkt)->length;
|
||||
}
|
||||
|
||||
p_Dec->p_Inp->pts = mpp_packet_get_pts(pkt);
|
||||
p_Dec->p_Inp->dts = mpp_packet_get_dts(pkt);
|
||||
//mpp_err("[timePkt_in] pts=%lld, dts=%lld", p_Dec->p_Inp->pts, p_Dec->p_Inp->dts);
|
||||
|
||||
task->flags.eos = p_Dec->p_Inp->is_eos;
|
||||
if (p_Dec->p_Vid->g_framecnt == 1477) {
|
||||
pkt = pkt;
|
||||
}
|
||||
LogTrace(logctx, "[Prepare_In] in_length=%d, eos=%d, g_framecnt=%d", mpp_packet_get_length(pkt), mpp_packet_get_eos(pkt), p_Dec->p_Vid->g_framecnt);
|
||||
do {
|
||||
//FPRINT(g_debug_file0, "[Prepare_In] in_length=%d, eos=%d, g_framecnt=%d \n", mpp_packet_get_length(pkt), mpp_packet_get_eos(pkt), p_Dec->p_Vid->g_framecnt);
|
||||
|
||||
do {
|
||||
(ret = parse_prepare(p_Dec->p_Inp, p_Dec->p_Cur));
|
||||
task->valid = p_Dec->p_Inp->task_valid; //!< prepare valid flag
|
||||
task->valid = p_Dec->p_Inp->task_valid; //!< prepare valid flag
|
||||
LogTrace(logctx, "[Prepare_Ing] length=%d, valid=%d,strm_off=%d, g_framecnt=%d", mpp_packet_get_length(pkt), task->valid, p_Dec->dxva_ctx->strm_offset, p_Dec->p_Vid->g_framecnt);
|
||||
//FPRINT(g_debug_file0, "[Prepare_Ing] length=%d, valid=%d,strm_off=%d, g_framecnt=%d \n", mpp_packet_get_length(pkt), task->valid, p_Dec->dxva_ctx->strm_offset, p_Dec->p_Vid->g_framecnt);
|
||||
} while (mpp_packet_get_length(pkt) && !task->valid);
|
||||
//LogTrace(logctx, "Prepare Out: len=%d, valid=%d ", mpp_packet_get_length(pkt), task->valid);
|
||||
|
||||
if (task->valid) {
|
||||
mpp_packet_set_data(p_Dec->task_pkt, p_Dec->dxva_ctx->bitstream);
|
||||
mpp_packet_set_length(p_Dec->task_pkt, p_Dec->dxva_ctx->strm_offset);
|
||||
mpp_packet_set_size(p_Dec->task_pkt, p_Dec->dxva_ctx->max_strm_size);
|
||||
mpp_packet_set_size(p_Dec->task_pkt, p_Dec->dxva_ctx->max_strm_size);
|
||||
LogTrace(logctx, "[Prepare_Out] ptr=%08x, stream_len=%d, max_size=%d", p_Dec->dxva_ctx->bitstream, p_Dec->dxva_ctx->strm_offset, p_Dec->dxva_ctx->max_strm_size);
|
||||
|
||||
task->input_packet = p_Dec->task_pkt;
|
||||
FPRINT(g_debug_file0, "[Prepare_Out] g_framecnt=%d, stream_len=%d \n", p_Dec->p_Vid->g_framecnt, p_Dec->dxva_ctx->strm_offset);
|
||||
task->input_packet = p_Dec->task_pkt;
|
||||
task->flags.eos = p_Dec->p_Inp->pkt_eos;
|
||||
} else {
|
||||
task->input_packet = NULL;
|
||||
}
|
||||
@@ -649,15 +696,17 @@ MPP_RET h264d_parse(void *decoder, HalDecTask *in_task)
|
||||
in_task->valid = 0; // prepare end flag
|
||||
p_Dec->in_task = in_task;
|
||||
|
||||
mpp_packet_set_data(p_Dec->task_pkt, p_Dec->dxva_ctx->bitstream);
|
||||
mpp_packet_set_length(p_Dec->task_pkt, p_Dec->dxva_ctx->strm_offset);
|
||||
mpp_packet_set_size(p_Dec->task_pkt, p_Dec->dxva_ctx->max_strm_size);
|
||||
// mpp_packet_set_data(p_Dec->task_pkt, p_Dec->dxva_ctx->bitstream);
|
||||
// mpp_packet_set_length(p_Dec->task_pkt, p_Dec->dxva_ctx->strm_offset);
|
||||
// mpp_packet_set_size(p_Dec->task_pkt, p_Dec->dxva_ctx->max_strm_size);
|
||||
// LogTrace(p_Dec->logctx.parr[RUN_PARSE], "[Parse_In] stream_len=%d, eos=%d, g_framecnt=%d",
|
||||
//mpp_packet_get_length(p_Dec->task_pkt), in_task->flags.eos, p_Dec->p_Vid->g_framecnt);
|
||||
|
||||
//FPRINT(g_debug_file0, "[Parse_In] stream_len=%d, eos=%d, g_framecnt=%d \n",
|
||||
// mpp_packet_get_length(p_Dec->task_pkt), in_task->flags.eos, p_Dec->p_Vid->g_framecnt);
|
||||
|
||||
FUN_CHECK(ret = parse_loop(p_Dec));
|
||||
|
||||
LogTrace(p_Dec->logctx.parr[RUN_PARSE], "[Parse_In] stream_len=%d, eos=%d, g_framecnt=%d",
|
||||
mpp_packet_get_length(p_Dec->task_pkt),
|
||||
in_task->flags.eos,
|
||||
p_Dec->p_Vid->g_framecnt);
|
||||
FUN_CHECK(ret = parse_loop(p_Dec));
|
||||
if (p_Dec->is_parser_end) {
|
||||
p_Dec->is_parser_end = 0;
|
||||
//LogTrace(p_Dec->logctx.parr[RUN_PARSE], "[Prarse loop end]");
|
||||
@@ -667,7 +716,10 @@ MPP_RET h264d_parse(void *decoder, HalDecTask *in_task)
|
||||
FUN_CHECK(ret = update_dpb(p_Dec));
|
||||
//LogTrace(p_Dec->logctx.parr[RUN_PARSE], "[Update dpb end]");
|
||||
//mpp_log_f("[PARSE_OUT] line=%d, g_framecnt=%d",__LINE__, p_Dec->p_Vid->g_framecnt++/*in_task->g_framecnt*/);
|
||||
LogTrace(p_Dec->logctx.parr[RUN_PARSE], "[PARSE_OUT] line=%d, g_framecnt=%d", __LINE__, p_Dec->p_Vid->g_framecnt++);
|
||||
//LogTrace(p_Dec->logctx.parr[RUN_PARSE], "[PARSE_OUT] line=%d, g_framecnt=%d", __LINE__, p_Dec->p_Vid->g_framecnt);
|
||||
//FPRINT(g_debug_file0, "[PARSE_END] g_framecnt=%d \n", p_Dec->p_Vid->g_framecnt);
|
||||
|
||||
p_Dec->p_Vid->g_framecnt++;
|
||||
}
|
||||
|
||||
__RETURN:
|
||||
|
@@ -22,6 +22,7 @@
|
||||
|
||||
#include "mpp_mem.h"
|
||||
#include "mpp_common.h"
|
||||
#include "mpp_buf_slot.h"
|
||||
|
||||
#include "h264d_log.h"
|
||||
#include "h264d_scalist.h"
|
||||
@@ -628,20 +629,20 @@ static void free_dpb_memory_index(H264_DecCtx_t *p_Dec, H264_DpbMark_t *p, RK_S3
|
||||
} 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) {
|
||||
if (p->top_used == 0 && p->bot_used == 0 && (p->slot_idx != -1)) {
|
||||
if (p_Dec->p_Vid->g_framecnt == 692) {
|
||||
p = p;
|
||||
}
|
||||
mpp_buf_slot_clr_flag(p_Dec->frame_slots, p->slot_idx, SLOT_CODEC_USE);
|
||||
|
||||
//mpp_buf_slot_clr_flag(p_Dec->frame_slots, p->slot_idx, SLOT_HAL_INPUT);
|
||||
//mpp_buf_slot_clr_flag(p_Dec->frame_slots, p->slot_idx, SLOT_HAL_OUTPUT);
|
||||
//mpp_buf_slot_clr_flag(p_Dec->frame_slots, p->slot_idx, SLOT_HAL_INPUT);
|
||||
//mpp_buf_slot_clr_flag(p_Dec->frame_slots, p->slot_idx, SLOT_HAL_OUTPUT);
|
||||
//mpp_buf_slot_clr_flag(p_Dec->frame_slots, p->slot_idx, SLOT_QUEUE_USE);
|
||||
//FPRINT(g_debug_file0, "[FREE] g_frame_no=%d, structure=%d, mark_idx=%d, slot_idx=%d \n", p_Dec->p_Vid->g_framecnt, structure, p->mark_idx, p->slot_idx);
|
||||
//mpp_print_slot_flag_info(g_debug_file1, p_Dec->frame_slots, p->slot_idx);
|
||||
//FPRINT(g_debug_file1, "[FREE] g_frame_no=%d, structure=%d, mark_idx=%d, slot_idx=%d \n", p_Dec->p_Vid->g_framecnt, structure, p->mark_idx, p->slot_idx);
|
||||
//mpp_print_slot_flag_info(g_debug_file1, p_Dec->frame_slots, p->slot_idx);
|
||||
|
||||
p_Dec->last_frame_slot_idx = p->slot_idx;
|
||||
//p->slot_idx = -1;
|
||||
|
||||
p->slot_idx = -1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -819,29 +820,31 @@ __FAILED:
|
||||
static void write_picture(H264_StorePic_t *p, H264dVideoCtx_t *p_Vid)
|
||||
{
|
||||
H264_DpbMark_t *p_mark = NULL;
|
||||
|
||||
if (p->mem_malloc_type == Mem_Malloc || p->mem_malloc_type == Mem_Clone) {
|
||||
MppFrame frame;
|
||||
if (p->mem_malloc_type == Mem_Malloc /*|| p->mem_malloc_type == Mem_Clone*/) {
|
||||
p_mark = p->mem_mark;
|
||||
//if (p->structure == FRAME) {
|
||||
// p_mark->top_used = (p_mark->top_used > 0) ? (p_mark->top_used - 1) : 0;
|
||||
// p_mark->bot_used = (p_mark->bot_used > 0) ? (p_mark->bot_used - 1) : 0;
|
||||
//} else if (p->structure == TOP_FIELD) {
|
||||
// p_mark->top_used = (p_mark->top_used > 0) ? (p_mark->top_used - 1) : 0;
|
||||
//} else if (p->structure == BOTTOM_FIELD) {
|
||||
// p_mark->bot_used = (p_mark->bot_used > 0) ? (p_mark->bot_used - 1) : 0;
|
||||
//}
|
||||
//}
|
||||
//if (p->mem_malloc_type == Mem_Malloc) {
|
||||
// if (!p_mark->top_used || !p_mark->bot_used)
|
||||
// {
|
||||
// ASSERT(0);
|
||||
// }
|
||||
//mpp_log_f(" [Write_picture] In");
|
||||
mpp_buf_slot_set_flag(p_Vid->p_Dec->frame_slots, p_mark->slot_idx, SLOT_QUEUE_USE);
|
||||
mpp_buf_slot_enqueue(p_Vid->p_Dec->frame_slots, p_mark->slot_idx, QUEUE_DISPLAY);
|
||||
//FPRINT(g_debug_file1, "[WRITE_PICTURE] g_frame_no=%d, mark_idx=%d, slot_idx=%d \n", p_Vid->g_framecnt, p_mark->mark_idx, p_mark->slot_idx);
|
||||
mpp_buf_slot_get_prop(p_Vid->p_Dec->frame_slots, p_mark->slot_idx, SLOT_FRAME_PTR, &frame);
|
||||
mpp_log("[dispaly] layer_id %d pts %lld\n", p->layer_id, mpp_frame_get_pts(frame));
|
||||
|
||||
mpp_frame_set_viewid(frame, p->layer_id);
|
||||
//if (p->layer_id == 0) {
|
||||
// mpp_frame_set_display(frame, 0);
|
||||
//}
|
||||
//else
|
||||
{
|
||||
mpp_frame_set_display(frame, 1);
|
||||
}
|
||||
p_Vid->p_Dec->last_frame_slot_idx = p_mark->slot_idx;
|
||||
|
||||
mpp_buf_slot_set_flag(p_Vid->p_Dec->frame_slots, p_mark->slot_idx, SLOT_QUEUE_USE);
|
||||
mpp_buf_slot_enqueue(p_Vid->p_Dec->frame_slots, p_mark->slot_idx, QUEUE_DISPLAY);
|
||||
|
||||
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));
|
||||
//mpp_print_slot_flag_info(g_debug_file1, p_Vid->p_Dec->frame_slots, p_mark->slot_idx);
|
||||
// mpp_log_f(" [Write_picture] Out");
|
||||
//mpp_log_f(" [Write_picture] Out");
|
||||
|
||||
LogInfo(p_Vid->p_Dec->logctx.parr[RUN_PARSE], "[WRITE_PICTURE] g_frame_cnt=%d", p_Vid->g_framecnt);
|
||||
}
|
||||
|
||||
@@ -1735,6 +1738,112 @@ __FAILED:
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
static void reset_dpb_info(H264_DpbInfo_t *p)
|
||||
{
|
||||
p->picbuf = NULL;
|
||||
p->TOP_POC = 0;
|
||||
p->BOT_POC = 0;
|
||||
p->field_flag = 0;
|
||||
p->slot_index = -1;
|
||||
p->colmv_is_used = 0;
|
||||
p->frame_num = 0;
|
||||
p->is_long_term = 0;
|
||||
p->long_term_pic_num = 0;
|
||||
p->voidx = 0;
|
||||
p->view_id = 0;
|
||||
p->is_used = 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static MPP_RET adjust_input(H264_SLICE_t *currSlice)
|
||||
{
|
||||
RK_U32 i = 0, j = 0;
|
||||
RK_U32 find_flag = 0;
|
||||
|
||||
H264_DpbBuf_t *p_Dpb = currSlice->p_Dpb;
|
||||
H264_DecCtx_t *p_Dec = currSlice->p_Dec;
|
||||
H264_DpbInfo_t *new_dpb = p_Dec->dpb_info;
|
||||
H264_DpbInfo_t *old_dpb = p_Dec->dpb_old[currSlice->layer_id];
|
||||
|
||||
|
||||
//for (i = 0; i < MAX_DPB_SIZE; i++) {
|
||||
// if (new_dpb[i].picbuf) {
|
||||
// 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,
|
||||
// new_dpb[i].TOP_POC);
|
||||
// }
|
||||
//}
|
||||
//FPRINT(g_debug_file0, "--------- [new DPB] -------- \n");
|
||||
//for (i = 0; i < MAX_DPB_SIZE; i++) {
|
||||
// if (old_dpb[i].picbuf) {
|
||||
// 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,
|
||||
// old_dpb[i].TOP_POC);
|
||||
// }
|
||||
//}
|
||||
//FPRINT(g_debug_file0, "--------- [Old DPB] -------- \n");
|
||||
|
||||
//!< delete old dpb
|
||||
for (i = 0; i < MAX_DPB_SIZE; i++) {
|
||||
find_flag = 0;
|
||||
if (old_dpb[i].picbuf) {
|
||||
for (j = 0; j < MAX_DPB_SIZE; j++) {
|
||||
if(new_dpb[j].picbuf) {
|
||||
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;
|
||||
if (new_dpb[j].is_used & 0x1) {
|
||||
find_flag = (old_dpb[i].TOP_POC == new_dpb[j].TOP_POC) ? find_flag : 0;
|
||||
}
|
||||
if (new_dpb[j].is_used & 0x2) {
|
||||
find_flag = (old_dpb[i].BOT_POC == new_dpb[j].BOT_POC) ? find_flag : 0;
|
||||
}
|
||||
if (find_flag) { //!< found
|
||||
new_dpb[j].have_same = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//!< not found
|
||||
if (find_flag == 0) {
|
||||
reset_dpb_info(&old_dpb[i]);
|
||||
}
|
||||
}
|
||||
//!< add new dpb
|
||||
for (j = 0; j < MAX_DPB_SIZE; j++) {
|
||||
if ((new_dpb[j].picbuf == 0) || new_dpb[j].have_same) {
|
||||
continue;
|
||||
}
|
||||
for (i = 0; i < MAX_DPB_SIZE; i++) {
|
||||
if (old_dpb[i].picbuf == 0) {
|
||||
old_dpb[i] = new_dpb[j];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
//memcpy(new_dpb, old_dpb, 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++) {
|
||||
if (old_dpb[i].picbuf) {
|
||||
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, " dbp_idx=%d, longterm=%d, poc=%d \n", old_dpb[j].slot_index, old_dpb[j].is_long_term,
|
||||
// old_dpb[i].TOP_POC);
|
||||
j++;
|
||||
}
|
||||
}
|
||||
for (; j < 16; j++) {
|
||||
reset_dpb_info(&new_dpb[j]);
|
||||
}
|
||||
memcpy(old_dpb, new_dpb, MAX_DPB_SIZE*sizeof(H264_DpbInfo_t));
|
||||
|
||||
return MPP_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*!
|
||||
***********************************************************************
|
||||
* \brief
|
||||
@@ -1745,14 +1854,14 @@ __FAILED:
|
||||
MPP_RET prepare_init_dpb_info(H264_SLICE_t *currSlice)
|
||||
{
|
||||
RK_U32 i = 0, j = 0;
|
||||
RK_S32 slot_index = -1;
|
||||
H264_DpbBuf_t *p_Dpb = currSlice->p_Dpb;
|
||||
H264_DecCtx_t *p_Dec = currSlice->p_Dec;
|
||||
|
||||
memset(p_Dec->dpb_info, 0, MAX_DPB_SIZE * sizeof(H264_DpbInfo_t));
|
||||
memset(&p_Dec->in_task->refer, -1, sizeof(p_Dec->in_task->refer));
|
||||
|
||||
memset(p_Dec->dpb_info, 0, MAX_DPB_SIZE * sizeof(H264_DpbInfo_t));
|
||||
memset(&p_Dec->in_task->refer, -1, sizeof(p_Dec->in_task->refer));
|
||||
if (currSlice->idr_flag && !currSlice->layer_id) { // idr_flag==1 && layer_id==0
|
||||
memset(p_Dec->dpb_old[0], 0, MAX_DPB_SIZE * sizeof(H264_DpbInfo_t));
|
||||
memset(p_Dec->dpb_old[1], 0, MAX_DPB_SIZE * sizeof(H264_DpbInfo_t));
|
||||
goto __RETURN;
|
||||
}
|
||||
//!<---- reference
|
||||
@@ -1774,7 +1883,6 @@ MPP_RET prepare_init_dpb_info(H264_SLICE_t *currSlice)
|
||||
p_Dec->dpb_info[i].field_flag = p_Dpb->fs_ref[j]->frame->iCodingType == FIELD_CODING;
|
||||
p_Dec->dpb_info[i].slot_index = p_Dpb->fs_ref[j]->frame->mem_mark->slot_idx;
|
||||
p_Dec->dpb_info[i].colmv_is_used = (p_Dpb->fs_ref[j]->frame->colmv_no_used_flag ? 0 : 1);
|
||||
slot_index = p_Dpb->fs_ref[j]->frame->mem_mark->slot_idx;
|
||||
} else if (p_Dpb->fs_ref[j]->is_used) {
|
||||
if (p_Dpb->fs_ref[j]->is_used & 0x1) { // top
|
||||
p_Dec->dpb_info[i].picbuf = p_Dpb->fs_ref[j]->top_field;
|
||||
@@ -1784,7 +1892,6 @@ MPP_RET prepare_init_dpb_info(H264_SLICE_t *currSlice)
|
||||
p_Dec->dpb_info[i].field_flag = 1;
|
||||
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);
|
||||
slot_index = p_Dpb->fs_ref[j]->top_field->mem_mark->slot_idx;
|
||||
} 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].TOP_POC = 0;
|
||||
@@ -1792,7 +1899,6 @@ MPP_RET prepare_init_dpb_info(H264_SLICE_t *currSlice)
|
||||
p_Dec->dpb_info[i].field_flag = 1;
|
||||
p_Dec->dpb_info[i].slot_index = p_Dpb->fs_ref[j]->bottom_field->mem_mark->slot_idx;
|
||||
p_Dec->dpb_info[i].colmv_is_used = (p_Dpb->fs_ref[j]->bottom_field->colmv_no_used_flag ? 0 : 1);
|
||||
slot_index = p_Dpb->fs_ref[j]->bottom_field->mem_mark->slot_idx;
|
||||
}
|
||||
}
|
||||
p_Dec->dpb_info[i].frame_num = p_Dpb->fs_ref[j]->frame_num;
|
||||
@@ -1802,12 +1908,6 @@ MPP_RET prepare_init_dpb_info(H264_SLICE_t *currSlice)
|
||||
p_Dec->dpb_info[i].voidx = p_Dpb->fs_ref[j]->layer_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;
|
||||
//!< set frame slot
|
||||
if (slot_index >= 0) {
|
||||
p_Dec->in_task->refer[i] = slot_index;
|
||||
mpp_buf_slot_set_flag(p_Dec->frame_slots, slot_index, SLOT_HAL_INPUT);
|
||||
mpp_buf_slot_set_flag(p_Dec->frame_slots, slot_index, SLOT_CODEC_USE);
|
||||
}
|
||||
}
|
||||
//!<---- long term reference
|
||||
for (j = 0; j < p_Dpb->ltref_frames_in_buffer; i++, j++) {
|
||||
@@ -1831,7 +1931,6 @@ MPP_RET prepare_init_dpb_info(H264_SLICE_t *currSlice)
|
||||
p_Dec->dpb_info[i].slot_index = p_Dpb->fs_ltref[j]->frame->mem_mark->slot_idx;
|
||||
p_Dec->dpb_info[i].colmv_is_used = (p_Dpb->fs_ltref[j]->frame->colmv_no_used_flag ? 0 : 1);
|
||||
p_Dec->dpb_info[i].long_term_pic_num = p_Dpb->fs_ltref[j]->frame->long_term_pic_num;
|
||||
slot_index = p_Dpb->fs_ltref[j]->frame->mem_mark->slot_idx;
|
||||
} else if (p_Dpb->fs_ltref[j]->is_used) {
|
||||
if (p_Dpb->fs_ltref[j]->is_used & 0x1) {
|
||||
p_Dec->dpb_info[i].picbuf = p_Dpb->fs_ltref[j]->top_field;
|
||||
@@ -1841,7 +1940,6 @@ MPP_RET prepare_init_dpb_info(H264_SLICE_t *currSlice)
|
||||
p_Dec->dpb_info[i].slot_index = p_Dpb->fs_ltref[j]->top_field->mem_mark->slot_idx;
|
||||
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;
|
||||
slot_index = p_Dpb->fs_ltref[j]->top_field->mem_mark->slot_idx;
|
||||
} 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].TOP_POC = 0;
|
||||
@@ -1850,7 +1948,6 @@ MPP_RET prepare_init_dpb_info(H264_SLICE_t *currSlice)
|
||||
p_Dec->dpb_info[i].slot_index = p_Dpb->fs_ltref[j]->bottom_field->mem_mark->slot_idx;
|
||||
p_Dec->dpb_info[i].colmv_is_used = (p_Dpb->fs_ltref[j]->bottom_field->colmv_no_used_flag ? 0 : 1);
|
||||
p_Dec->dpb_info[i].long_term_pic_num = p_Dpb->fs_ltref[j]->bottom_field->long_term_pic_num;
|
||||
slot_index = p_Dpb->fs_ltref[j]->bottom_field->mem_mark->slot_idx;
|
||||
}
|
||||
}
|
||||
p_Dec->dpb_info[i].frame_num = p_Dpb->fs_ltref[j]->long_term_frame_idx; //long term use long_term_frame_idx
|
||||
@@ -1859,135 +1956,121 @@ MPP_RET prepare_init_dpb_info(H264_SLICE_t *currSlice)
|
||||
p_Dec->dpb_info[i].voidx = p_Dpb->fs_ltref[j]->layer_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;
|
||||
//!< set frame slot
|
||||
if (slot_index >= 0) {
|
||||
p_Dec->in_task->refer[i] = slot_index;
|
||||
mpp_buf_slot_set_flag(p_Dec->frame_slots, slot_index, SLOT_HAL_INPUT);
|
||||
mpp_buf_slot_set_flag(p_Dec->frame_slots, slot_index, SLOT_CODEC_USE);
|
||||
}
|
||||
}
|
||||
//!< inter-layer reference (for multi-layered codecs)
|
||||
for (j = 0; j < p_Dpb->used_size_il; i++, j++) {
|
||||
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)
|
||||
break;
|
||||
p_Dec->dpb_info[i].picbuf = p_Dpb->fs_ilref[j]->frame;
|
||||
|
||||
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].BOT_POC = p_Dpb->fs_ilref[j]->frame->bot_poc_mmco5;
|
||||
} else {
|
||||
p_Dec->dpb_info[i].TOP_POC = p_Dpb->fs_ilref[j]->frame->top_poc;
|
||||
p_Dec->dpb_info[i].BOT_POC = p_Dpb->fs_ilref[j]->frame->bottom_poc;
|
||||
}
|
||||
p_Dec->dpb_info[i].field_flag = p_Dpb->fs_ilref[j]->frame->iCodingType == FIELD_CODING;
|
||||
p_Dec->dpb_info[i].slot_index = p_Dpb->fs_ilref[j]->frame->mem_mark->slot_idx;
|
||||
p_Dec->dpb_info[i].colmv_is_used = (p_Dpb->fs_ilref[j]->frame->colmv_no_used_flag ? 0 : 1);
|
||||
slot_index = p_Dpb->fs_ilref[j]->frame->mem_mark->slot_idx;
|
||||
} else if (currSlice->structure != FRAME && p_Dpb->fs_ilref[j]->is_used) {
|
||||
if (p_Dpb->fs_ilref[j]->is_used == 0x3) {
|
||||
if (p_Dpb->fs_ilref[j]->inter_view_flag[currSlice->structure == BOTTOM_FIELD] == 0)
|
||||
break;
|
||||
p_Dec->dpb_info[i].picbuf = p_Dpb->fs_ilref[j]->top_field;
|
||||
|
||||
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;
|
||||
} else {
|
||||
p_Dec->dpb_info[i].TOP_POC = p_Dpb->fs_ilref[j]->top_field->top_poc;
|
||||
}
|
||||
if (p_Dpb->fs_ilref[j]->bottom_field->is_mmco_5) {
|
||||
p_Dec->dpb_info[i].BOT_POC = p_Dpb->fs_ilref[j]->bottom_field->bot_poc_mmco5;
|
||||
} else {
|
||||
p_Dec->dpb_info[i].BOT_POC = p_Dpb->fs_ilref[j]->bottom_field->bottom_poc;
|
||||
}
|
||||
p_Dec->dpb_info[i].field_flag = p_Dpb->fs_ilref[j]->frame->iCodingType == FIELD_CODING;
|
||||
p_Dec->dpb_info[i].slot_index = p_Dpb->fs_ilref[j]->frame->mem_mark->slot_idx;
|
||||
p_Dec->dpb_info[i].colmv_is_used = (p_Dpb->fs_ilref[j]->frame->colmv_no_used_flag ? 0 : 1);
|
||||
slot_index = p_Dpb->fs_ilref[j]->frame->mem_mark->slot_idx;
|
||||
}
|
||||
if (p_Dpb->fs_ilref[j]->is_used & 0x1) {
|
||||
if (p_Dpb->fs_ilref[j]->inter_view_flag[0] == 0)
|
||||
break;
|
||||
p_Dec->dpb_info[i].picbuf = p_Dpb->fs_ilref[j]->top_field;
|
||||
|
||||
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;
|
||||
} else {
|
||||
p_Dec->dpb_info[i].TOP_POC = p_Dpb->fs_ilref[j]->top_field->top_poc;
|
||||
}
|
||||
p_Dec->dpb_info[i].BOT_POC = 0;
|
||||
p_Dec->dpb_info[i].field_flag = 1;
|
||||
p_Dec->dpb_info[i].slot_index = p_Dpb->fs_ilref[j]->top_field->mem_mark->slot_idx;
|
||||
p_Dec->dpb_info[i].colmv_is_used = (p_Dpb->fs_ilref[j]->top_field->colmv_no_used_flag ? 0 : 1);
|
||||
slot_index = p_Dpb->fs_ilref[j]->top_field->mem_mark->slot_idx;
|
||||
} else { // if(p_Dpb->fs_ref[j]->is_used & 0x2)
|
||||
if (p_Dpb->fs_ilref[j]->inter_view_flag[1] == 0)
|
||||
break;
|
||||
p_Dec->dpb_info[i].picbuf = p_Dpb->fs_ilref[j]->bottom_field;
|
||||
|
||||
p_Dec->dpb_info[i].TOP_POC = 0;
|
||||
if (p_Dpb->fs_ilref[j]->bottom_field->is_mmco_5) {
|
||||
p_Dec->dpb_info[i].BOT_POC = p_Dpb->fs_ilref[j]->bottom_field->bot_poc_mmco5;
|
||||
} else {
|
||||
p_Dec->dpb_info[i].BOT_POC = p_Dpb->fs_ilref[j]->bottom_field->bottom_poc;
|
||||
}
|
||||
p_Dec->dpb_info[i].field_flag = 1;
|
||||
p_Dec->dpb_info[i].slot_index = p_Dpb->fs_ilref[j]->bottom_field->mem_mark->slot_idx;
|
||||
p_Dec->dpb_info[i].colmv_is_used = (p_Dpb->fs_ilref[j]->bottom_field->colmv_no_used_flag ? 0 : 1);
|
||||
slot_index = p_Dpb->fs_ilref[j]->bottom_field->mem_mark->slot_idx;
|
||||
}
|
||||
}
|
||||
p_Dec->dpb_info[i].frame_num = p_Dpb->fs_ilref[j]->frame_num;
|
||||
p_Dec->dpb_info[i].is_long_term = 0; //p_Dpb->fs_ilref[j]->is_long_term;
|
||||
p_Dec->dpb_info[i].is_ilt_flag = 1;
|
||||
p_Dec->dpb_info[i].long_term_pic_num = 0;
|
||||
p_Dec->dpb_info[i].long_term_frame_idx = 0;
|
||||
p_Dec->dpb_info[i].voidx = p_Dpb->fs_ilref[j]->layer_id;
|
||||
p_Dec->dpb_info[i].view_id = p_Dpb->fs_ilref[j]->view_id;
|
||||
p_Dec->dpb_info[i].is_used = p_Dpb->fs_ilref[j]->is_used;
|
||||
//!< set frame slot
|
||||
if (slot_index >= 0) {
|
||||
p_Dec->in_task->refer[i] = slot_index;
|
||||
mpp_buf_slot_set_flag(p_Dec->frame_slots, slot_index, SLOT_HAL_INPUT);
|
||||
mpp_buf_slot_set_flag(p_Dec->frame_slots, slot_index, SLOT_CODEC_USE);
|
||||
}
|
||||
}
|
||||
|
||||
//for(j = 0; j < i; j++) {
|
||||
// FPRINT(g_debug_file0, "i=%2d, framenum=%2d,", j, p_Dec->dpb_info[j].frame_num);
|
||||
// FPRINT(g_debug_file0, " longterm=%d, poc=%d, voidx=%d, is_ilt=%d, layid=%d \n", p_Dec->dpb_info[j].is_long_term,
|
||||
// p_Dec->dpb_info[j].TOP_POC, p_Dec->dpb_info[j].voidx, p_Dec->dpb_info[j].is_ilt_flag, currSlice->layer_id);
|
||||
//}
|
||||
//FPRINT(g_debug_file0, "--------- [FLUSH_CNT] flush framecnt=%d -------- \n", p_Dec->p_Vid->g_framecnt);
|
||||
#if 1
|
||||
//!< inter-layer reference (for multi-layered codecs)
|
||||
for (j = 0; j < p_Dpb->used_size_il; i++, j++) {
|
||||
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)
|
||||
break;
|
||||
p_Dec->dpb_info[i].picbuf = p_Dpb->fs_ilref[j]->frame;
|
||||
|
||||
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].BOT_POC = p_Dpb->fs_ilref[j]->frame->bot_poc_mmco5;
|
||||
} else {
|
||||
p_Dec->dpb_info[i].TOP_POC = p_Dpb->fs_ilref[j]->frame->top_poc;
|
||||
p_Dec->dpb_info[i].BOT_POC = p_Dpb->fs_ilref[j]->frame->bottom_poc;
|
||||
}
|
||||
p_Dec->dpb_info[i].field_flag = p_Dpb->fs_ilref[j]->frame->iCodingType == FIELD_CODING;
|
||||
p_Dec->dpb_info[i].slot_index = p_Dpb->fs_ilref[j]->frame->mem_mark->slot_idx;
|
||||
p_Dec->dpb_info[i].colmv_is_used = (p_Dpb->fs_ilref[j]->frame->colmv_no_used_flag ? 0 : 1);
|
||||
} else if (currSlice->structure != FRAME && p_Dpb->fs_ilref[j]->is_used) {
|
||||
if (p_Dpb->fs_ilref[j]->is_used == 0x3) {
|
||||
if (p_Dpb->fs_ilref[j]->inter_view_flag[currSlice->structure == BOTTOM_FIELD] == 0)
|
||||
break;
|
||||
p_Dec->dpb_info[i].picbuf = p_Dpb->fs_ilref[j]->top_field;
|
||||
|
||||
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;
|
||||
} else {
|
||||
p_Dec->dpb_info[i].TOP_POC = p_Dpb->fs_ilref[j]->top_field->top_poc;
|
||||
}
|
||||
if (p_Dpb->fs_ilref[j]->bottom_field->is_mmco_5) {
|
||||
p_Dec->dpb_info[i].BOT_POC = p_Dpb->fs_ilref[j]->bottom_field->bot_poc_mmco5;
|
||||
} else {
|
||||
p_Dec->dpb_info[i].BOT_POC = p_Dpb->fs_ilref[j]->bottom_field->bottom_poc;
|
||||
}
|
||||
p_Dec->dpb_info[i].field_flag = p_Dpb->fs_ilref[j]->frame->iCodingType == FIELD_CODING;
|
||||
p_Dec->dpb_info[i].slot_index = p_Dpb->fs_ilref[j]->frame->mem_mark->slot_idx;
|
||||
p_Dec->dpb_info[i].colmv_is_used = (p_Dpb->fs_ilref[j]->frame->colmv_no_used_flag ? 0 : 1);
|
||||
}
|
||||
if (p_Dpb->fs_ilref[j]->is_used & 0x1) {
|
||||
if (p_Dpb->fs_ilref[j]->inter_view_flag[0] == 0)
|
||||
break;
|
||||
p_Dec->dpb_info[i].picbuf = p_Dpb->fs_ilref[j]->top_field;
|
||||
|
||||
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;
|
||||
} else {
|
||||
p_Dec->dpb_info[i].TOP_POC = p_Dpb->fs_ilref[j]->top_field->top_poc;
|
||||
}
|
||||
p_Dec->dpb_info[i].BOT_POC = 0;
|
||||
p_Dec->dpb_info[i].field_flag = 1;
|
||||
p_Dec->dpb_info[i].slot_index = p_Dpb->fs_ilref[j]->top_field->mem_mark->slot_idx;
|
||||
p_Dec->dpb_info[i].colmv_is_used = (p_Dpb->fs_ilref[j]->top_field->colmv_no_used_flag ? 0 : 1);
|
||||
} else { // if(p_Dpb->fs_ref[j]->is_used & 0x2)
|
||||
if (p_Dpb->fs_ilref[j]->inter_view_flag[1] == 0)
|
||||
break;
|
||||
p_Dec->dpb_info[i].picbuf = p_Dpb->fs_ilref[j]->bottom_field;
|
||||
|
||||
p_Dec->dpb_info[i].TOP_POC = 0;
|
||||
if (p_Dpb->fs_ilref[j]->bottom_field->is_mmco_5) {
|
||||
p_Dec->dpb_info[i].BOT_POC = p_Dpb->fs_ilref[j]->bottom_field->bot_poc_mmco5;
|
||||
} else {
|
||||
p_Dec->dpb_info[i].BOT_POC = p_Dpb->fs_ilref[j]->bottom_field->bottom_poc;
|
||||
}
|
||||
p_Dec->dpb_info[i].field_flag = 1;
|
||||
p_Dec->dpb_info[i].slot_index = p_Dpb->fs_ilref[j]->bottom_field->mem_mark->slot_idx;
|
||||
p_Dec->dpb_info[i].colmv_is_used = (p_Dpb->fs_ilref[j]->bottom_field->colmv_no_used_flag ? 0 : 1);
|
||||
}
|
||||
}
|
||||
p_Dec->dpb_info[i].frame_num = p_Dpb->fs_ilref[j]->frame_num;
|
||||
p_Dec->dpb_info[i].is_long_term = 0;//p_Dpb->fs_ilref[j]->is_long_term;
|
||||
p_Dec->dpb_info[i].is_ilt_flag = 1;
|
||||
p_Dec->dpb_info[i].long_term_pic_num = 0;
|
||||
p_Dec->dpb_info[i].long_term_frame_idx = 0;
|
||||
p_Dec->dpb_info[i].voidx = p_Dpb->fs_ilref[j]->layer_id;
|
||||
p_Dec->dpb_info[i].view_id = p_Dpb->fs_ilref[j]->view_id;
|
||||
p_Dec->dpb_info[i].is_used = p_Dpb->fs_ilref[j]->is_used;
|
||||
}
|
||||
#endif
|
||||
|
||||
//for(j = 0; j < i; j++) {
|
||||
// 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);
|
||||
// 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,
|
||||
// p_Dec->dpb_info[j].TOP_POC);
|
||||
//}
|
||||
//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
|
||||
for (; i < 16; 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);
|
||||
|
||||
if (p_Dec->p_Vid->g_framecnt == 20) {
|
||||
i = i;
|
||||
}
|
||||
//!< reset left parameters
|
||||
for (; i < 16; i++) {
|
||||
p_Dec->dpb_info[i].picbuf = NULL;
|
||||
p_Dec->dpb_info[i].TOP_POC = 0;
|
||||
p_Dec->dpb_info[i].BOT_POC = 0;
|
||||
p_Dec->dpb_info[i].field_flag = 0;
|
||||
p_Dec->dpb_info[i].slot_index = -1;
|
||||
p_Dec->dpb_info[i].colmv_is_used = 0;
|
||||
p_Dec->dpb_info[i].frame_num = 0;
|
||||
p_Dec->dpb_info[i].is_long_term = 0;
|
||||
p_Dec->dpb_info[i].long_term_pic_num = 0;
|
||||
p_Dec->dpb_info[i].voidx = 0;
|
||||
p_Dec->dpb_info[i].view_id = 0;
|
||||
p_Dec->dpb_info[i].is_used = 0;
|
||||
p_Dec->in_task->refer[i] = -1;
|
||||
}
|
||||
//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);
|
||||
//}
|
||||
for (i = 0; i < MAX_DPB_SIZE; i++) {
|
||||
if (p_Dec->dpb_info[i].picbuf && (p_Dec->dpb_info[i].slot_index >= 0)) {
|
||||
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_CODEC_USE);
|
||||
}
|
||||
}
|
||||
|
||||
__RETURN:
|
||||
return MPP_OK;
|
||||
@@ -2009,11 +2092,9 @@ MPP_RET prepare_init_ref_info(H264_SLICE_t *currSlice)
|
||||
RK_S32 layer_id = 0, voidx = 0, is_used = 0;
|
||||
H264_DecCtx_t *p_Dec = currSlice->p_Dec;
|
||||
|
||||
//memset(p_Dec->dpb_info, 0, MAX_DPB_SIZE * sizeof(H264_DpbInfo_t));
|
||||
memset(p_Dec->refpic_info_p, 0, MAX_REF_SIZE * sizeof(H264_RefPicInfo_t));
|
||||
memset(p_Dec->refpic_info_b[0], 0, MAX_REF_SIZE * sizeof(H264_RefPicInfo_t));
|
||||
memset(p_Dec->refpic_info_b[1], 0, MAX_REF_SIZE * sizeof(H264_RefPicInfo_t));
|
||||
//memset(&p_Dec->in_task->refer, -1, sizeof(p_Dec->in_task->refer));
|
||||
|
||||
if (currSlice->idr_flag && !currSlice->layer_id) { // idr_flag==1 && layer_id==0
|
||||
goto __RETURN;
|
||||
|
@@ -327,8 +327,8 @@ 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++) {
|
||||
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->dpb_info[dpb_idx].picbuf ? 1 : 0);
|
||||
dpb_valid = currSlice->p_Dec->refpic_info_p[i].valid;
|
||||
//dpb_valid = (currSlice->p_Dec->dpb_info[dpb_idx].picbuf ? 1 : 0);
|
||||
if (dpb_valid) {
|
||||
bottom_flag = currSlice->p_Dec->refpic_info_p[i].bottom_flag;
|
||||
fill_picture_entry(&p_long->RefPicList[0][i], dpb_idx, bottom_flag);
|
||||
@@ -340,8 +340,8 @@ MPP_RET fill_slice_syntax(H264_SLICE_t *currSlice, H264dDxvaCtx_t *dxva_ctx)
|
||||
for (list = 0; list < 2; list++) {
|
||||
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_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->refpic_info_b[list][i].valid;
|
||||
//dpb_valid = (currSlice->p_Dec->dpb_info[dpb_idx].picbuf ? 1 : 0);
|
||||
if (dpb_valid) {
|
||||
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);
|
||||
|
@@ -39,12 +39,12 @@
|
||||
#define MAX_MARK_SIZE 35 //!< for malloc buffer mark, can be changed
|
||||
|
||||
|
||||
#define NALU_BUF_MAX_SIZE 10*1024
|
||||
#define NALU_BUF_ADD_SIZE 1024
|
||||
#define HEAD_BUF_MAX_SIZE 10*1024*1024
|
||||
#define HEAD_BUF_ADD_SIZE 1024
|
||||
#define SODB_BUF_MAX_SIZE 10*1024*1024
|
||||
#define SODB_BUF_ADD_SIZE 1024
|
||||
#define NALU_BUF_MAX_SIZE 1024
|
||||
#define NALU_BUF_ADD_SIZE 512
|
||||
#define HEAD_BUF_MAX_SIZE 10*1024
|
||||
#define HEAD_BUF_ADD_SIZE 512
|
||||
#define SODB_BUF_MAX_SIZE 10*1024
|
||||
#define SODB_BUF_ADD_SIZE 512
|
||||
|
||||
|
||||
//!< AVC Profile IDC definitions
|
||||
@@ -223,6 +223,8 @@ typedef struct h264_dpb_info_t {
|
||||
RK_U32 top_valid;
|
||||
RK_U32 bot_valid;
|
||||
struct h264_store_pic_t *picbuf;
|
||||
|
||||
RK_U32 have_same;
|
||||
} H264_DpbInfo_t;
|
||||
|
||||
//!< refence picture information
|
||||
@@ -815,9 +817,11 @@ typedef struct h264d_dxva_ctx_t {
|
||||
struct h264_dec_ctx_t *p_Dec;
|
||||
} H264dDxvaCtx_t;
|
||||
|
||||
|
||||
|
||||
|
||||
//!< input parameter
|
||||
typedef struct h264d_input_ctx_t {
|
||||
RK_U32 is_eos;
|
||||
typedef struct h264d_input_ctx_t {
|
||||
struct h264_dec_ctx_t *p_Dec;
|
||||
struct h264d_cur_ctx_t *p_Cur; //!< current parameters, use in read nalu
|
||||
struct h264d_video_ctx_t *p_Vid; //!< parameters for video decoder
|
||||
@@ -827,20 +831,33 @@ typedef struct h264d_input_ctx_t {
|
||||
RK_U8 *in_buf;
|
||||
size_t *in_size;
|
||||
size_t in_length;
|
||||
RK_S64 pts;
|
||||
RK_S64 dts;
|
||||
RK_U32 pkt_eos;
|
||||
|
||||
RK_S64 in_pts;
|
||||
RK_S64 in_dts;
|
||||
//!< output data
|
||||
RK_U8 *out_buf;
|
||||
RK_U32 out_length;
|
||||
RK_U8 task_valid;
|
||||
RK_U32 task_eos;
|
||||
} H264dInputCtx_t;
|
||||
|
||||
//!< TimeStamp context
|
||||
#define MAX_PTS_NUM 5
|
||||
typedef struct h264d_timestamp_t{
|
||||
RK_U64 begin_off;
|
||||
RK_U64 end_off;
|
||||
RK_S64 pts;
|
||||
RK_S64 dts;
|
||||
}H264dTimeStamp_t;
|
||||
|
||||
//!< current stream
|
||||
typedef struct h264d_curstrm_t {
|
||||
RK_U32 nalu_offset; //!< The offset of the input stream
|
||||
|
||||
RK_U32 nalu_max_size; //!< Cur Unit Buffer size
|
||||
|
||||
RK_U8 *curdata;
|
||||
|
||||
RK_S32 nal_unit_type;
|
||||
RK_U32 nalu_len;
|
||||
RK_U8 *nalu_buf; //!< store read nalu data
|
||||
@@ -852,6 +869,12 @@ typedef struct h264d_curstrm_t {
|
||||
RK_U8 prefixdata[START_PREFIX_3BYTE];
|
||||
RK_U8 startcode_found;
|
||||
RK_U8 endcode_found;
|
||||
//!< time stamp
|
||||
//RK_S32 has_fetch_ts;
|
||||
RK_U8 pkt_ts_idx;
|
||||
RK_U64 pkt_used_bytes; //!< byte offset from starting packet start
|
||||
|
||||
H264dTimeStamp_t pkt_ts[MAX_PTS_NUM];
|
||||
} H264dCurStream_t;
|
||||
|
||||
//!< current parameters
|
||||
@@ -870,6 +893,11 @@ typedef struct h264d_cur_ctx_t {
|
||||
struct h264d_input_ctx_t *p_Inp;
|
||||
struct h264_dec_ctx_t *p_Dec;
|
||||
struct h264d_video_ctx_t *p_Vid; //!< parameters for video decoder
|
||||
|
||||
RK_S64 last_pts;
|
||||
RK_S64 last_dts;
|
||||
RK_S64 curr_pts;
|
||||
RK_S64 curr_dts;
|
||||
} H264dCurCtx_t;
|
||||
|
||||
//!< parameters for video decoder
|
||||
@@ -939,13 +967,14 @@ typedef struct h264d_video_ctx_t {
|
||||
RK_S32 active_mvc_sps_flag;
|
||||
|
||||
RK_U32 g_framecnt;
|
||||
|
||||
RK_U32 dpb_size[MAX_NUM_DPB_LAYERS];
|
||||
} H264dVideoCtx_t;
|
||||
|
||||
typedef struct h264d_mem_t {
|
||||
struct h264_dpb_mark_t dpb_mark[MAX_MARK_SIZE]; //!< for fpga register check, dpb mark
|
||||
struct h264_dpb_info_t dpb_info[MAX_DPB_SIZE]; //!< 16
|
||||
struct h264_refpic_info_t refpic_info_p[MAX_REF_SIZE]; //!< 32
|
||||
struct h264_dpb_info_t dpb_old[2][MAX_DPB_SIZE];
|
||||
struct h264_refpic_info_t refpic_info_p[MAX_REF_SIZE]; //!< 32
|
||||
struct h264_refpic_info_t refpic_info_b[2][MAX_REF_SIZE]; //!< [2][32]
|
||||
struct h264d_dxva_ctx_t dxva_ctx;
|
||||
} H264_DecMem_t;
|
||||
@@ -999,6 +1028,7 @@ typedef struct h264_dec_ctx_t {
|
||||
struct h264d_mem_t *mem;
|
||||
struct h264_dpb_mark_t *dpb_mark; //!< for write out, MAX_DPB_SIZE
|
||||
struct h264_dpb_info_t *dpb_info; //!< 16
|
||||
struct h264_dpb_info_t *dpb_old[2]; //!< 16
|
||||
struct h264_refpic_info_t *refpic_info_p; //!< 32
|
||||
struct h264_refpic_info_t *refpic_info_b[2]; //!< [2][32]
|
||||
struct h264d_dxva_ctx_t *dxva_ctx;
|
||||
@@ -1012,6 +1042,7 @@ typedef struct h264_dec_ctx_t {
|
||||
RK_U8 is_first_frame;
|
||||
RK_U8 is_new_frame;
|
||||
RK_U8 is_parser_end;
|
||||
RK_U8 mvc_valid;
|
||||
struct h264d_logctx_t logctx; //!< debug log file
|
||||
struct log_ctx_t logctxbuf[LOG_MAX];
|
||||
|
||||
|
@@ -393,19 +393,29 @@ static void dpb_mark_malloc(H264dVideoCtx_t *p_Vid, RK_S32 structure, RK_U8 comb
|
||||
ASSERT(idx <= MAX_MARK_SIZE);
|
||||
mpp_buf_slot_get_unused(p_Vid->p_Dec->frame_slots, &p_mark[idx].slot_idx);
|
||||
cur_mark = &p_mark[idx];
|
||||
// LogInfo(p_Vid->p_Dec->logctx.parr[RUN_PARSE], "[MALLOC] g_frame_no=%d, mark_idx=%d, slot_idx=%d \n", p_Vid->g_framecnt, cur_mark->mark_idx, cur_mark->slot_idx);
|
||||
// mpp_print_slot_flag_info(g_debug_file1, p_Dec->frame_slots, cur_mark->slot_idx);
|
||||
|
||||
if(p_Vid->g_framecnt == 255)
|
||||
{
|
||||
idx = idx;
|
||||
}
|
||||
//LogInfo(p_Vid->p_Dec->logctx.parr[RUN_PARSE], "[MALLOC] g_frame_no=%d, mark_idx=%d, slot_idx=%d \n", p_Vid->g_framecnt, cur_mark->mark_idx, cur_mark->slot_idx);
|
||||
//mpp_print_slot_flag_info(g_debug_file1, p_Dec->frame_slots, cur_mark->slot_idx);
|
||||
mpp_log("[Malloc] lay_id=%d, g_framecnt=%d, mark_idx=%d, slot_idx=%d, pts=%lld \n", layer_id,
|
||||
p_Vid->g_framecnt, cur_mark->mark_idx, cur_mark->slot_idx, p_Vid->p_Inp->in_pts);
|
||||
|
||||
mpp_frame_set_hor_stride(cur_mark->frame, p_Vid->width); // before crop
|
||||
mpp_frame_set_ver_stride(cur_mark->frame, p_Vid->height);
|
||||
|
||||
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);
|
||||
|
||||
mpp_frame_set_pts(cur_mark->frame, p_Vid->p_Inp->pts);
|
||||
|
||||
//mpp_log("[Decpicture] width=%d, height=%d, slot_idx=%d\n", p_Vid->width, p_Vid->height, cur_mark->slot_idx);
|
||||
mpp_buf_slot_set_prop(p_Dec->frame_slots, cur_mark->slot_idx, SLOT_FRAME, cur_mark->frame);
|
||||
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);
|
||||
mpp_log("[ timeUs ] alloc_pts=%lld, input_pts=%lld \n", p_Vid->p_Cur->last_pts, p_Vid->p_Inp->in_pts);
|
||||
|
||||
mpp_buf_slot_set_prop(p_Dec->frame_slots, cur_mark->slot_idx, SLOT_FRAME, cur_mark->frame);
|
||||
FPRINT(g_debug_file0, "[Malloc] g_framecnt=%d, mark_idx=%d, slot_idx=%d, lay_id=%d, pts=%lld \n",
|
||||
p_Vid->g_framecnt, cur_mark->mark_idx, cur_mark->slot_idx, layer_id, p_Vid->p_Inp->in_pts);
|
||||
|
||||
p_Vid->active_dpb_mark[layer_id] = cur_mark;
|
||||
}
|
||||
@@ -417,6 +427,8 @@ static void dpb_mark_malloc(H264dVideoCtx_t *p_Vid, RK_S32 structure, RK_U8 comb
|
||||
if (structure == FRAME || structure == BOTTOM_FIELD) {
|
||||
cur_mark->bot_used += 1;
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
|
@@ -75,9 +75,9 @@ static void reset_slice(H264dVideoCtx_t *p_Vid)
|
||||
static MPP_RET realloc_buffer(RK_U8 **buf, RK_U32 *max_size, RK_U32 add_size)
|
||||
{
|
||||
MPP_RET ret = MPP_ERR_UNKNOW;
|
||||
*buf = mpp_realloc(*buf, RK_U8, *max_size + add_size);
|
||||
MEM_CHECK(ret, *buf);
|
||||
*max_size += add_size;
|
||||
(*buf) = mpp_realloc((*buf), RK_U8, ((*max_size) + add_size));
|
||||
MEM_CHECK(ret, (*buf));
|
||||
(*max_size) += add_size;
|
||||
|
||||
return ret = MPP_OK;
|
||||
__FAILED:
|
||||
@@ -90,7 +90,7 @@ static void reset_nalu(H264dCurStream_t *p_strm)
|
||||
p_strm->startcode_found = p_strm->endcode_found;
|
||||
p_strm->nalu_len = 0;
|
||||
p_strm->nal_unit_type = NALU_TYPE_NULL;
|
||||
p_strm->endcode_found = 0;
|
||||
p_strm->endcode_found = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,8 +118,7 @@ static MPP_RET read_one_nalu(H264dInputCtx_t *p_Inp, H264dCurStream_t *p_strm)
|
||||
H264_DecCtx_t *p_Dec = p_Inp->p_Dec;
|
||||
|
||||
FunctionIn(logctx->parr[RUN_PARSE]);
|
||||
reset_nalu(p_strm);
|
||||
|
||||
reset_nalu(p_strm);
|
||||
while (p_Inp->in_length > 0) {
|
||||
p_strm->curdata = &p_Inp->in_buf[p_strm->nalu_offset++];
|
||||
(*p_Inp->in_size) -= 1;
|
||||
@@ -137,9 +136,10 @@ static MPP_RET read_one_nalu(H264dInputCtx_t *p_Inp, H264dCurStream_t *p_strm)
|
||||
while (p_strm->nalu_buf[p_strm->nalu_len - 1] == 0x00) { //!< find non-zeros byte
|
||||
p_strm->nalu_len--;
|
||||
}
|
||||
p_Dec->nalu_ret = EndOfNalu;
|
||||
p_Dec->nalu_ret = EndOfNalu;
|
||||
break;
|
||||
}
|
||||
p_Dec->nalu_ret = MidOfNalu;
|
||||
}
|
||||
if (!p_Inp->in_length) { //!< check input
|
||||
p_strm->nalu_offset = 0;
|
||||
@@ -200,6 +200,7 @@ static MPP_RET parser_nalu_header(H264_SLICE_t *currSlice)
|
||||
goto __FAILED;
|
||||
} else { //!< MVC
|
||||
currSlice->mvcExt.valid = 1;
|
||||
p_Cur->p_Dec->mvc_valid = 1;
|
||||
READ_ONEBIT(p_bitctx, &currSlice->mvcExt.non_idr_flag, "nalu_type");
|
||||
READ_BITS(p_bitctx, 6, &currSlice->mvcExt.priority_id, "priority_id");
|
||||
READ_BITS(p_bitctx, 10, &currSlice->mvcExt.view_id, "view_id");
|
||||
@@ -318,7 +319,7 @@ __FAILED:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static MPP_RET parse_nalu_header(H264dCurCtx_t *p_Cur)
|
||||
static MPP_RET analyze_cur_nalu(H264dCurCtx_t *p_Cur)
|
||||
{
|
||||
MPP_RET ret = MPP_ERR_UNKNOW;
|
||||
RK_U32 nalu_header_bytes = 0;
|
||||
@@ -331,16 +332,17 @@ static MPP_RET parse_nalu_header(H264dCurCtx_t *p_Cur)
|
||||
RK_U32 svc_extension_flag = -1;
|
||||
|
||||
FunctionIn(logctx->parr[RUN_PARSE]);
|
||||
mpp_set_bitread_ctx(p_bitctx, p_strm->nalu_buf, p_strm->nalu_len);
|
||||
memset(p_bitctx, 0, sizeof(BitReadCtx_t));
|
||||
mpp_set_bitread_ctx(p_bitctx, p_strm->nalu_buf, 4);
|
||||
set_bitread_logctx(p_bitctx, logctx->parr[LOG_READ_NALU]);
|
||||
READ_BITS(p_bitctx, 1, &forbidden_bit);
|
||||
ASSERT(forbidden_bit == 0);
|
||||
READ_BITS(p_bitctx, 2, &nal_reference_idc);
|
||||
READ_BITS(p_bitctx, 5, &p_strm->nal_unit_type);
|
||||
if (g_nalu_cnt1 == 29) {
|
||||
g_nalu_cnt1 = g_nalu_cnt1;
|
||||
}
|
||||
//FPRINT(g_debug_file1, "g_nalu_cnt=%d, nal_type=%d, sodb_len=%d \n", g_nalu_cnt1++, p_strm->nal_unit_type, p_strm->nalu_len);
|
||||
//if (g_nalu_cnt1 == 29) {
|
||||
// g_nalu_cnt1 = g_nalu_cnt1;
|
||||
//}
|
||||
//FPRINT(g_debug_file0, "[Analyze_NALU] g_framecnt=%d, g_nalu_cnt=%d, nal_type=%d, sodb_len=%d \n", p_Cur->p_Vid->g_framecnt, g_nalu_cnt1++, p_strm->nal_unit_type, p_strm->nalu_len);
|
||||
|
||||
nalu_header_bytes = 1;
|
||||
if ((p_strm->nal_unit_type == NALU_TYPE_PREFIX) || (p_strm->nal_unit_type == NALU_TYPE_SLC_EXT)) {
|
||||
@@ -359,6 +361,11 @@ static MPP_RET parse_nalu_header(H264dCurCtx_t *p_Cur)
|
||||
if ( p_strm->nal_unit_type == NALU_TYPE_SLICE || p_strm->nal_unit_type == NALU_TYPE_IDR) {
|
||||
mpp_set_bitread_ctx(p_bitctx, (p_strm->nalu_buf + nalu_header_bytes), 4); // reset
|
||||
READ_UE(p_bitctx, &first_mb_in_slice);
|
||||
//if (first_mb_in_slice == 0)
|
||||
{
|
||||
//FPRINT(g_debug_file0, "[Analyze_NALU] first_mb_in_sile ==0 \n")
|
||||
first_mb_in_slice = first_mb_in_slice;
|
||||
}
|
||||
|
||||
if (!p_Cur->p_Dec->is_first_frame && (first_mb_in_slice == 0)) {
|
||||
p_Cur->p_Dec->is_new_frame = 1;
|
||||
@@ -374,13 +381,13 @@ __FAILED:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static MPP_RET add_empty_nalu(H264dCurCtx_t *p_Cur)
|
||||
static MPP_RET add_empty_nalu(H264dCurStream_t *p_strm)
|
||||
{
|
||||
MPP_RET ret = MPP_ERR_UNKNOW;
|
||||
RK_U8 *p_des = NULL;
|
||||
H264dCurStream_t *p_strm = &p_Cur->strm;
|
||||
|
||||
if (p_strm->head_offset >= p_strm->head_max_size) {
|
||||
RK_U32 add_size = 0;
|
||||
add_size = MPP_MAX(sizeof(H264dNaluHead_t), HEAD_BUF_ADD_SIZE);
|
||||
if ((p_strm->head_offset + add_size) >= p_strm->head_max_size) {
|
||||
|
||||
FUN_CHECK(ret = realloc_buffer(&p_strm->head_buf, &p_strm->head_max_size, HEAD_BUF_ADD_SIZE));
|
||||
}
|
||||
@@ -389,14 +396,13 @@ static MPP_RET add_empty_nalu(H264dCurCtx_t *p_Cur)
|
||||
((H264dNaluHead_t *)p_des)->is_frame_end = 1;
|
||||
((H264dNaluHead_t *)p_des)->nal_unit_type = 0;
|
||||
((H264dNaluHead_t *)p_des)->sodb_len = 0;
|
||||
p_strm->head_offset += sizeof(H264dNaluHead_t);
|
||||
p_strm->head_offset += add_size;
|
||||
|
||||
return ret = MPP_OK;
|
||||
__FAILED:
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
static MPP_RET store_cur_nalu(H264dCurCtx_t *p_Cur)
|
||||
{
|
||||
MPP_RET ret = MPP_ERR_UNKNOW;
|
||||
@@ -415,8 +421,8 @@ static MPP_RET store_cur_nalu(H264dCurCtx_t *p_Cur)
|
||||
|| (p_strm->nal_unit_type == NALU_TYPE_SEI)
|
||||
|| (p_strm->nal_unit_type == NALU_TYPE_PREFIX)
|
||||
|| (p_strm->nal_unit_type == NALU_TYPE_SLC_EXT)) {
|
||||
if (p_strm->head_offset >= p_strm->head_max_size) {
|
||||
add_size = MPP_MAX(HEAD_BUF_ADD_SIZE, p_strm->nalu_len);
|
||||
add_size = MPP_MAX(HEAD_BUF_ADD_SIZE, p_strm->nalu_len);
|
||||
if ((p_strm->head_offset + add_size) >= p_strm->head_max_size) {
|
||||
FUN_CHECK(ret = realloc_buffer(&p_strm->head_buf, &p_strm->head_max_size, add_size));
|
||||
}
|
||||
p_des = &p_strm->head_buf[p_strm->head_offset];
|
||||
@@ -431,8 +437,8 @@ static MPP_RET store_cur_nalu(H264dCurCtx_t *p_Cur)
|
||||
if ((p_strm->nal_unit_type == NALU_TYPE_SLICE)
|
||||
|| (p_strm->nal_unit_type == NALU_TYPE_IDR)) {
|
||||
dxva_ctx = p_Cur->p_Dec->dxva_ctx;
|
||||
if (dxva_ctx->strm_offset >= dxva_ctx->max_strm_size) {
|
||||
add_size = MPP_MAX(SODB_BUF_ADD_SIZE, p_strm->nalu_len);
|
||||
add_size = MPP_MAX(SODB_BUF_ADD_SIZE, p_strm->nalu_len);
|
||||
if ((dxva_ctx->strm_offset + add_size) >= dxva_ctx->max_strm_size) {
|
||||
realloc_buffer(&dxva_ctx->bitstream, &dxva_ctx->max_strm_size, add_size);
|
||||
}
|
||||
p_des = &dxva_ctx->bitstream[dxva_ctx->strm_offset];
|
||||
@@ -448,6 +454,96 @@ __FAILED:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void insert_timestamp(H264dCurCtx_t *p_Cur, H264dCurStream_t *p_strm)
|
||||
{
|
||||
RK_U8 i = 0;
|
||||
H264dTimeStamp_t *p_curr = NULL;
|
||||
RK_U64 used_bytes = p_Cur->strm.pkt_used_bytes;
|
||||
|
||||
|
||||
|
||||
for (i = 0; i < MAX_PTS_NUM; i++) {
|
||||
p_curr = &p_strm->pkt_ts[i];
|
||||
if ( (used_bytes > p_curr->begin_off)
|
||||
&& (used_bytes < p_curr->end_off) ) {
|
||||
p_Cur->curr_dts = p_curr->dts;
|
||||
p_Cur->curr_pts = p_curr->pts;
|
||||
mpp_err("[TimePkt] insert_pts=%lld, pkt_pts=%lld \n", p_curr->pts, p_Cur->p_Inp->in_pts);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//p_Cur->dts = p_Cur->p_Inp->in_dts;
|
||||
//p_Cur->pts = p_Cur->p_Inp->in_pts;
|
||||
}
|
||||
|
||||
|
||||
static MPP_RET judge_is_new_frame(H264dCurCtx_t *p_Cur, H264dCurStream_t *p_strm)
|
||||
{
|
||||
MPP_RET ret = MPP_ERR_UNKNOW;
|
||||
RK_U32 nalu_header_bytes = 0;
|
||||
RK_U32 first_mb_in_slice = 0;
|
||||
H264dLogCtx_t *logctx = &p_Cur->p_Dec->logctx;
|
||||
BitReadCtx_t *p_bitctx = &p_Cur->bitctx;
|
||||
RK_U32 forbidden_bit = -1;
|
||||
RK_U32 nal_reference_idc = -1;
|
||||
RK_U32 svc_extension_flag = -1;
|
||||
|
||||
FunctionIn(logctx->parr[RUN_PARSE]);
|
||||
memset(p_bitctx, 0, sizeof(BitReadCtx_t));
|
||||
mpp_set_bitread_ctx(p_bitctx, p_strm->nalu_buf, 4);
|
||||
set_bitread_logctx(p_bitctx, logctx->parr[LOG_READ_NALU]);
|
||||
READ_BITS(p_bitctx, 1, &forbidden_bit);
|
||||
ASSERT(forbidden_bit == 0);
|
||||
READ_BITS(p_bitctx, 2, &nal_reference_idc);
|
||||
READ_BITS(p_bitctx, 5, &p_strm->nal_unit_type);
|
||||
//if (g_nalu_cnt1 == 29) {
|
||||
// g_nalu_cnt1 = g_nalu_cnt1;
|
||||
//}
|
||||
//FPRINT(g_debug_file0, "[Analyze_NALU] g_framecnt=%d, g_nalu_cnt=%d, nal_type=%d, sodb_len=%d \n", p_Cur->p_Vid->g_framecnt, g_nalu_cnt1++, p_strm->nal_unit_type, p_strm->nalu_len);
|
||||
|
||||
nalu_header_bytes = 1;
|
||||
if ((p_strm->nal_unit_type == NALU_TYPE_PREFIX) || (p_strm->nal_unit_type == NALU_TYPE_SLC_EXT)) {
|
||||
READ_BITS(p_bitctx, 1, &svc_extension_flag);
|
||||
if (svc_extension_flag) {
|
||||
LogInfo(logctx->parr[RUN_PARSE], "svc_extension is not supported.");
|
||||
goto __FAILED;
|
||||
} else {
|
||||
if (p_strm->nal_unit_type == NALU_TYPE_SLC_EXT) {
|
||||
p_strm->nal_unit_type = NALU_TYPE_SLICE;
|
||||
}
|
||||
}
|
||||
nalu_header_bytes += 3;
|
||||
}
|
||||
//-- parse slice
|
||||
if ( p_strm->nal_unit_type == NALU_TYPE_SLICE || p_strm->nal_unit_type == NALU_TYPE_IDR) {
|
||||
mpp_set_bitread_ctx(p_bitctx, (p_strm->nalu_buf + nalu_header_bytes), 4); // reset
|
||||
READ_UE(p_bitctx, &first_mb_in_slice);
|
||||
//!< get time stamp
|
||||
if (first_mb_in_slice == 0) {
|
||||
p_Cur->last_dts = p_Cur->curr_dts;
|
||||
p_Cur->last_pts = p_Cur->curr_pts;
|
||||
//insert_timestamp(p_Cur, p_strm);
|
||||
mpp_log("[init_pts]p_Cur->last_pts=%lld, p_Cur->cur_pts=%lld, inp_pts=%lld, g_framecnt=%d \n",
|
||||
p_Cur->last_pts, p_Cur->curr_pts, p_Cur->p_Inp->in_pts, p_Cur->p_Vid->g_framecnt);
|
||||
p_Cur->curr_dts = p_Cur->p_Inp->in_dts;
|
||||
p_Cur->curr_pts = p_Cur->p_Inp->in_pts;
|
||||
|
||||
if (!p_Cur->p_Dec->is_first_frame) {
|
||||
p_Cur->p_Dec->is_new_frame = 1;
|
||||
}
|
||||
p_Cur->p_Dec->is_first_frame = 0;
|
||||
}
|
||||
}
|
||||
FunctionOut(logctx->parr[RUN_PARSE]);
|
||||
return ret = MPP_OK;
|
||||
__BITREAD_ERR:
|
||||
return ret = p_bitctx->ret;
|
||||
__FAILED:
|
||||
return ret;
|
||||
}
|
||||
|
||||
#if 0
|
||||
/*!
|
||||
***********************************************************************
|
||||
* \brief
|
||||
@@ -460,27 +556,27 @@ MPP_RET parse_prepare(H264dInputCtx_t *p_Inp, H264dCurCtx_t *p_Cur)
|
||||
FunctionIn(p_Inp->p_Dec->logctx.parr[RUN_PARSE]);
|
||||
|
||||
p_Inp->task_valid = 0;
|
||||
if (p_Cur->p_Inp->is_eos) {
|
||||
if (p_Cur->p_Dec->is_new_frame) {
|
||||
FUN_CHECK(ret = store_cur_nalu(p_Cur));
|
||||
p_Cur->p_Dec->is_new_frame = 0;
|
||||
} else if (p_Cur->p_Inp->pkt_eos) {
|
||||
if (p_Inp->p_Dec->nalu_ret == HaveNoStream) {
|
||||
FUN_CHECK(ret = parse_nalu_header(p_Cur));
|
||||
FUN_CHECK(ret = store_cur_nalu(p_Cur));
|
||||
//FUN_CHECK(ret = analyze_cur_nalu(p_Cur));
|
||||
//FUN_CHECK(ret = store_cur_nalu(p_Cur));
|
||||
}
|
||||
FUN_CHECK(ret = add_empty_nalu(p_Cur));
|
||||
FUN_CHECK(ret = add_empty_nalu(&p_Cur->strm));
|
||||
p_Inp->task_valid = 1;
|
||||
LogInfo(p_Inp->p_Dec->logctx.parr[RUN_PARSE], "----- end of stream ----");
|
||||
goto __RETURN;
|
||||
} else if (p_Cur->p_Dec->is_new_frame) {
|
||||
FUN_CHECK(ret = store_cur_nalu(p_Cur));
|
||||
p_Cur->p_Dec->is_new_frame = 0;
|
||||
}
|
||||
|
||||
FUN_CHECK(ret = read_one_nalu(p_Inp, &p_Cur->strm));
|
||||
|
||||
if (p_Inp->p_Dec->nalu_ret == EndOfNalu) {
|
||||
FUN_CHECK(ret = parse_nalu_header(p_Cur));
|
||||
FUN_CHECK(ret = analyze_cur_nalu(p_Cur));
|
||||
if (p_Cur->p_Dec->is_new_frame) {
|
||||
//!< add an empty nalu to tell frame end
|
||||
FUN_CHECK(ret = add_empty_nalu(p_Cur));
|
||||
FUN_CHECK(ret = add_empty_nalu(&p_Cur->strm));
|
||||
//!< reset curstream parameters
|
||||
p_Cur->strm.head_offset = 0;
|
||||
p_Inp->task_valid = 1;
|
||||
@@ -496,8 +592,94 @@ __RETURN:
|
||||
__FAILED:
|
||||
return ret;
|
||||
}
|
||||
#else
|
||||
/*!
|
||||
***********************************************************************
|
||||
* \brief
|
||||
* prepare function for parser
|
||||
***********************************************************************
|
||||
*/
|
||||
MPP_RET parse_prepare(H264dInputCtx_t *p_Inp, H264dCurCtx_t *p_Cur)
|
||||
{
|
||||
MPP_RET ret = MPP_ERR_UNKNOW;
|
||||
H264dLogCtx_t *logctx = &p_Inp->p_Dec->logctx;
|
||||
H264_DecCtx_t *p_Dec = p_Inp->p_Dec;
|
||||
H264dCurStream_t *p_strm = &p_Cur->strm;
|
||||
RK_U32 nalu_header_bytes = 0;
|
||||
|
||||
FunctionIn(logctx->parr[RUN_PARSE]);
|
||||
p_Dec->nalu_ret = NALU_NULL;
|
||||
p_Inp->task_valid = 0;
|
||||
|
||||
if (p_Inp->pkt_eos) {
|
||||
FUN_CHECK(ret = store_cur_nalu(p_Dec->p_Cur));
|
||||
FUN_CHECK(ret = add_empty_nalu(p_strm));
|
||||
p_Dec->p_Inp->task_valid = 1;
|
||||
p_Dec->p_Inp->task_eos = 1;
|
||||
LogInfo(p_Inp->p_Dec->logctx.parr[RUN_PARSE], "----- end of stream ----");
|
||||
goto __RETURN;
|
||||
}
|
||||
|
||||
while (p_Inp->in_length > 0) {
|
||||
p_strm->curdata = &p_Inp->in_buf[p_strm->nalu_offset++];
|
||||
(*p_Inp->in_size) -= 1;
|
||||
p_Inp->in_length--;
|
||||
p_strm->pkt_used_bytes++;
|
||||
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));
|
||||
}
|
||||
p_strm->nalu_buf[p_strm->nalu_len++] = *p_strm->curdata;
|
||||
if (p_strm->nalu_len == 1) {
|
||||
p_strm->nal_unit_type = p_strm->nalu_buf[0]&0x1F;
|
||||
nalu_header_bytes += 1;
|
||||
if ((p_strm->nal_unit_type == NALU_TYPE_PREFIX)
|
||||
|| (p_strm->nal_unit_type == NALU_TYPE_SLC_EXT)) {
|
||||
nalu_header_bytes += 3;
|
||||
}
|
||||
}
|
||||
if (p_strm->nalu_len == (nalu_header_bytes + 4)) {
|
||||
FUN_CHECK(ret = judge_is_new_frame(p_Cur, p_strm));
|
||||
if (p_Cur->p_Dec->is_new_frame) {
|
||||
//!< add an empty nalu to tell frame end
|
||||
FUN_CHECK(ret = add_empty_nalu(&p_Cur->strm));
|
||||
//!< reset curstream parameters
|
||||
p_Cur->strm.head_offset = 0;
|
||||
p_Cur->p_Inp->task_valid = 1;
|
||||
p_Cur->p_Dec->is_new_frame = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
find_prefix_code(p_strm->curdata, p_strm);
|
||||
|
||||
if (p_strm->endcode_found) {
|
||||
p_strm->nalu_len -= START_PREFIX_3BYTE;
|
||||
//!< find non-zeros byte
|
||||
while (p_strm->nalu_buf[p_strm->nalu_len - 1] == 0x00) {
|
||||
p_strm->nalu_len--;
|
||||
break;
|
||||
}
|
||||
p_Dec->nalu_ret = EndOfNalu;
|
||||
FUN_CHECK(ret = store_cur_nalu(p_Dec->p_Cur));
|
||||
reset_nalu(p_strm);
|
||||
break;
|
||||
}
|
||||
}
|
||||
//!< check input
|
||||
if (!p_Inp->in_length) {
|
||||
p_strm->nalu_offset = 0;
|
||||
p_Dec->nalu_ret = HaveNoStream;
|
||||
}
|
||||
|
||||
__RETURN:
|
||||
FunctionOut(logctx->parr[RUN_PARSE]);
|
||||
|
||||
return ret = MPP_OK;
|
||||
__FAILED:
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
/*!
|
||||
***********************************************************************
|
||||
@@ -518,6 +700,7 @@ MPP_RET parse_loop(H264_DecCtx_t *p_Dec)
|
||||
switch (p_Dec->next_state) {
|
||||
case SliceSTATE_ResetSlice:
|
||||
reset_slice(p_Dec->p_Vid);
|
||||
p_Dec->next_state = SliceSTATE_ReadNalu;
|
||||
//FPRINT(g_debug_file0, "SliceSTATE_ResetSlice\n");
|
||||
break;
|
||||
case SliceSTATE_ReadNalu:
|
||||
@@ -533,6 +716,7 @@ MPP_RET parse_loop(H264_DecCtx_t *p_Dec)
|
||||
p_curdata += p_head->sodb_len;
|
||||
p_Dec->nalu_ret = EndOfNalu;
|
||||
p_Dec->next_state = SliceSTATE_ParseNalu;
|
||||
}
|
||||
//FPRINT(g_debug_file0, "SliceSTATE_ReadNalu\n");
|
||||
break;
|
||||
case SliceSTATE_ParseNalu:
|
||||
@@ -543,21 +727,25 @@ MPP_RET parse_loop(H264_DecCtx_t *p_Dec)
|
||||
p_Dec->next_state = SliceSTATE_InitPicture;
|
||||
} else {
|
||||
p_Dec->next_state = SliceSTATE_ReadNalu;
|
||||
}
|
||||
//FPRINT(g_debug_file0, "SliceSTATE_ParseNalu\n");
|
||||
break;
|
||||
case SliceSTATE_InitPicture:
|
||||
(ret = init_picture(&p_Dec->p_Cur->slice));
|
||||
p_Dec->next_state = SliceSTATE_GetSliceData;
|
||||
//FPRINT(g_debug_file0, "SliceSTATE_InitPicture\n");
|
||||
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;
|
||||
//FPRINT(g_debug_file0, "SliceSTATE_GetSliceData\n");
|
||||
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;
|
||||
//FPRINT(g_debug_file0, "SliceSTATE_RegisterOneFrame\n");
|
||||
break;
|
||||
default:
|
||||
|
@@ -538,7 +538,10 @@ MPP_RET activate_sps(H264dVideoCtx_t *p_Vid, H264_SPS_t *sps, H264_subSPS_t *sub
|
||||
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 = init_dpb(p_Vid, p_Vid->p_Dpb_layer[1], 2));
|
||||
update_last_video_pars(p_Vid, p_Vid->active_sps, 1);
|
||||
update_last_video_pars(p_Vid, p_Vid->active_sps, 1);
|
||||
//!< init frame slots, store frame buffer size
|
||||
p_Vid->dpb_size[1] = p_Vid->p_Dpb_layer[1]->size;
|
||||
mpp_buf_slot_setup(p_Vid->p_Dec->frame_slots, p_Vid->dpb_size[0] + p_Vid->dpb_size[1] + 2);
|
||||
}
|
||||
} else { //!< layer_id == 0
|
||||
p_Vid->active_sps = sps;
|
||||
@@ -550,7 +553,10 @@ MPP_RET activate_sps(H264dVideoCtx_t *p_Vid, H264_SPS_t *sps, H264_subSPS_t *sub
|
||||
FUN_CHECK(ret = flush_dpb(p_Vid->p_Dpb_layer[0], 1));
|
||||
}
|
||||
FUN_CHECK(ret = init_dpb(p_Vid, p_Vid->p_Dpb_layer[0], 1));
|
||||
update_last_video_pars(p_Vid, p_Vid->active_sps, 0);
|
||||
update_last_video_pars(p_Vid, p_Vid->active_sps, 0);
|
||||
//!< init frame slots, store frame buffer size
|
||||
p_Vid->dpb_size[0] = p_Vid->p_Dpb_layer[0]->size;
|
||||
mpp_buf_slot_setup(p_Vid->p_Dec->frame_slots, p_Vid->dpb_size[0] + 2);
|
||||
}
|
||||
}
|
||||
update_video_pars(p_Vid, p_Vid->active_sps);
|
||||
|
@@ -221,7 +221,8 @@ typedef enum SlotPropType_e {
|
||||
SLOT_EOS,
|
||||
SLOT_FRAME,
|
||||
SLOT_BUFFER,
|
||||
SLOT_PROP_BUTT,
|
||||
SLOT_FRAME_PTR,
|
||||
SLOT_PROP_BUTT,
|
||||
} SlotPropType;
|
||||
|
||||
MPP_RET mpp_buf_slot_set_prop(MppBufSlots slots, RK_S32 index, SlotPropType type, void *val);
|
||||
|
@@ -825,6 +825,8 @@ MPP_RET mpp_buf_slot_get_prop(MppBufSlots slots, RK_S32 index, SlotPropType type
|
||||
} break;
|
||||
case SLOT_FRAME: {
|
||||
MppFrame *frame = (MppFrame *)val;
|
||||
//*frame = (slot->status.has_frame) ? (slot->frame) : (NULL);
|
||||
|
||||
mpp_assert(slot->status.has_frame);
|
||||
if (slot->status.has_frame) {
|
||||
mpp_frame_init(frame);
|
||||
@@ -832,6 +834,10 @@ MPP_RET mpp_buf_slot_get_prop(MppBufSlots slots, RK_S32 index, SlotPropType type
|
||||
mpp_frame_copy(*frame, slot->frame);
|
||||
} else
|
||||
*frame = NULL;
|
||||
} break;
|
||||
case SLOT_FRAME_PTR: {
|
||||
MppFrame *frame = (MppFrame *)val;
|
||||
*frame = (slot->status.has_frame) ? (slot->frame) : (NULL);
|
||||
} break;
|
||||
case SLOT_BUFFER: {
|
||||
MppBuffer *buffer = (MppBuffer *)val;
|
||||
@@ -843,7 +849,6 @@ MPP_RET mpp_buf_slot_get_prop(MppBufSlots slots, RK_S32 index, SlotPropType type
|
||||
|
||||
return MPP_OK;
|
||||
}
|
||||
|
||||
MPP_RET mpp_slots_set_prop(MppBufSlots slots, SlotsPropType type, void *val)
|
||||
{
|
||||
if (NULL == slots || NULL == val || type >= SLOTS_PROP_BUTT) {
|
||||
|
@@ -24,6 +24,7 @@
|
||||
#include "mpp_common.h"
|
||||
|
||||
#include "mpp.h"
|
||||
#include "mpp_frame.h"
|
||||
#include "mpp_buffer_impl.h"
|
||||
#include "mpp_packet_impl.h"
|
||||
#include "mpp_frame_impl.h"
|
||||
@@ -604,9 +605,11 @@ void *mpp_dec_hal_thread(void *data)
|
||||
RK_S32 index;
|
||||
while (MPP_OK == mpp_buf_slot_dequeue(frame_slots, &index, QUEUE_DISPLAY)) {
|
||||
MppFrame frame;
|
||||
RK_U32 display;
|
||||
mpp_buf_slot_get_prop(frame_slots, index, SLOT_FRAME, &frame);
|
||||
if (!dec->reset_flag) {
|
||||
mpp_put_frame(mpp, frame);
|
||||
display = mpp_frame_get_display(frame);
|
||||
if (!dec->reset_flag && display) {
|
||||
mpp_put_frame(mpp, frame);
|
||||
} else {
|
||||
mpp_frame_deinit(&frame);
|
||||
}
|
||||
|
@@ -42,6 +42,9 @@
|
||||
#define H264dSTM_HEADER 0x4d525453
|
||||
#define H264dERR_HEADER 0x524f5245
|
||||
|
||||
|
||||
#define FPGA_TEST 0
|
||||
|
||||
const enum {
|
||||
H264ScalingList4x4Length = 16,
|
||||
H264ScalingList8x8Length = 64,
|
||||
@@ -50,6 +53,8 @@ const enum {
|
||||
|
||||
static void rkv_write_sps_to_fifo(H264dHalCtx_t *p_hal, FifoCtx_t *pkt)
|
||||
{
|
||||
FunctionIn(p_hal->logctx.parr[RUN_HAL]);
|
||||
|
||||
fifo_write_bits(pkt, -1, 4, "seq_parameter_set_id"); //!< not used in hard
|
||||
fifo_write_bits(pkt, -1, 8, "profile_idc"); //!< not used in hard
|
||||
fifo_write_bits(pkt, -1, 1, "constraint_set3_flag"); //!< not used in hard
|
||||
@@ -97,13 +102,14 @@ static void rkv_write_sps_to_fifo(H264dHalCtx_t *p_hal, FifoCtx_t *pkt)
|
||||
fifo_write_bits(pkt, 0, 10, "non_anchor_ref_l1");
|
||||
}
|
||||
fifo_align_bits(pkt, 32);
|
||||
FunctionOut(p_hal->logctx.parr[RUN_HAL]);
|
||||
}
|
||||
|
||||
static void rkv_write_pps_to_fifo(H264dHalCtx_t *p_hal, FifoCtx_t *pkt)
|
||||
{
|
||||
RK_U32 Scaleing_list_address = 0;
|
||||
RK_U32 offset = RKV_CABAC_TAB_SIZE + RKV_SPSPPS_SIZE + RKV_RPS_SIZE;
|
||||
|
||||
FunctionIn(p_hal->logctx.parr[RUN_HAL]);
|
||||
fifo_write_bits(pkt, -1, 8, "pps_pic_parameter_set_id");
|
||||
fifo_write_bits(pkt, -1, 5, "pps_seq_parameter_set_id");
|
||||
fifo_write_bits(pkt, p_hal->pp->entropy_coding_mode_flag, 1, "entropy_coding_mode_flag");
|
||||
@@ -128,7 +134,12 @@ static void rkv_write_pps_to_fifo(H264dHalCtx_t *p_hal, FifoCtx_t *pkt)
|
||||
} else {
|
||||
Scaleing_list_address += offset;
|
||||
}
|
||||
fifo_write_bits(pkt, Scaleing_list_address, 32, "Scaleing_list_address");
|
||||
#if FPGA_TEST
|
||||
fifo_write_bits(pkt, 0, 32, "Scaleing_list_address");
|
||||
#else
|
||||
fifo_write_bits(pkt, Scaleing_list_address, 32, "Scaleing_list_address");
|
||||
#endif
|
||||
FunctionOut(p_hal->logctx.parr[RUN_HAL]);
|
||||
}
|
||||
|
||||
|
||||
@@ -181,6 +192,7 @@ MPP_RET rkv_alloc_fifo_packet(H264dLogCtx_t *logctx, H264dRkvPkt_t *pkts)
|
||||
RK_U32 sclst_size = 256;
|
||||
RK_U32 regs_size = 512;
|
||||
|
||||
FunctionIn(logctx->parr[RUN_HAL]);
|
||||
//!< initial packages header and malloc buffer
|
||||
FUN_CHECK(ret = fifo_packet_alloc(&pkts->spspps, H264dPPS_HEADER, pps_size));
|
||||
FUN_CHECK(ret = fifo_packet_alloc(&pkts->rps, H264dRPS_HEADER, rps_size));
|
||||
@@ -206,6 +218,7 @@ MPP_RET rkv_alloc_fifo_packet(H264dLogCtx_t *logctx, H264dRkvPkt_t *pkts)
|
||||
pkts->scanlist.fp_data = NULL;
|
||||
pkts->reg.fp_data = NULL;
|
||||
}
|
||||
FunctionOut(logctx->parr[RUN_HAL]);
|
||||
return ret = MPP_OK;
|
||||
__FAILED:
|
||||
rkv_free_fifo_packet(pkts);
|
||||
@@ -225,6 +238,8 @@ void rkv_prepare_spspps_packet(void *hal, FifoCtx_t *pkt)
|
||||
RK_S32 i = 0;
|
||||
RK_S32 is_long_term = 0, voidx = 0;
|
||||
H264dHalCtx_t *p_hal = (H264dHalCtx_t *)hal;
|
||||
|
||||
FunctionIn(p_hal->logctx.parr[RUN_HAL]);
|
||||
fifo_packet_reset(pkt);
|
||||
LogInfo(pkt->logctx, "------------------ Frame SPS_PPS begin ------------------------");
|
||||
rkv_write_sps_to_fifo(p_hal, pkt);
|
||||
@@ -240,6 +255,7 @@ void rkv_prepare_spspps_packet(void *hal, FifoCtx_t *pkt)
|
||||
}
|
||||
fifo_align_bits(pkt, 64);
|
||||
fifo_fwrite_data(pkt); //!< "PPSH" header 32 bit
|
||||
FunctionOut(p_hal->logctx.parr[RUN_HAL]);
|
||||
}
|
||||
/*!
|
||||
***********************************************************************
|
||||
@@ -257,7 +273,7 @@ void rkv_prepare_framerps_packet(void *hal, FifoCtx_t *pkt)
|
||||
RK_U16 frame_num_wrap = 0;
|
||||
H264dHalCtx_t *p_hal = (H264dHalCtx_t *)hal;
|
||||
DXVA_PicParams_H264_MVC *pp = p_hal->pp;
|
||||
|
||||
FunctionIn(p_hal->logctx.parr[RUN_HAL]);
|
||||
fifo_packet_reset(pkt);
|
||||
LogInfo(pkt->logctx, "------------------ Frame RPS begin ------------------------");
|
||||
max_frame_num = 1 << (pp->log2_max_frame_num_minus4 + 4);
|
||||
@@ -304,6 +320,7 @@ void rkv_prepare_framerps_packet(void *hal, FifoCtx_t *pkt)
|
||||
fifo_align_bits(pkt, 128);
|
||||
fifo_flush_bits(pkt);
|
||||
fifo_fwrite_data(pkt); //!< "RPSH" header 32 bit
|
||||
FunctionOut(p_hal->logctx.parr[RUN_HAL]);
|
||||
}
|
||||
/*!
|
||||
***********************************************************************
|
||||
@@ -316,7 +333,7 @@ void rkv_prepare_scanlist_packet(void *hal, FifoCtx_t *pkt)
|
||||
{
|
||||
RK_S32 i = 0;
|
||||
H264dHalCtx_t *p_hal = (H264dHalCtx_t *)hal;
|
||||
|
||||
FunctionIn(p_hal->logctx.parr[RUN_HAL]);
|
||||
if (p_hal->pp->scaleing_list_enable_flag) {
|
||||
fifo_packet_reset(pkt);
|
||||
LogInfo(pkt->logctx, "------------------ Scanlist begin ------------------------");
|
||||
@@ -328,6 +345,7 @@ void rkv_prepare_scanlist_packet(void *hal, FifoCtx_t *pkt)
|
||||
}
|
||||
fifo_fwrite_data(pkt); //!< "SCLS" header 32 bit
|
||||
}
|
||||
FunctionOut(p_hal->logctx.parr[RUN_HAL]);
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -354,14 +372,15 @@ void rkv_generate_regs(void *hal, HalTaskInfo *task, FifoCtx_t *pkt)
|
||||
DXVA_PicParams_H264_MVC *pp = p_hal->pp;
|
||||
H264dRkvRegs_t *p_regs = (H264dRkvRegs_t *)p_hal->regs;
|
||||
|
||||
memset(p_regs, 0, sizeof(H264dRkvRegs_t));
|
||||
FunctionIn(p_hal->logctx.parr[RUN_HAL]);
|
||||
|
||||
memset(p_regs, 0, sizeof(H264dRkvRegs_t));
|
||||
p_regs->swreg2_sysctrl.sw_dec_mode = 1; //!< h264
|
||||
|
||||
if (p_regs->swreg2_sysctrl.sw_rlc_mode == 1) {
|
||||
p_regs->swreg5_stream_rlc_len.sw_stream_len = 0;
|
||||
} else {
|
||||
p_regs->swreg5_stream_rlc_len.sw_stream_len = p_hal->strm_len;
|
||||
p_regs->swreg5_stream_rlc_len.sw_stream_len = mpp_packet_get_length(task->dec.input_packet);
|
||||
}
|
||||
//!< caculate the yuv_frame_size and mv_size
|
||||
mb_width = pp->wFrameWidthInMbsMinus1 + 1;
|
||||
@@ -413,8 +432,11 @@ void rkv_generate_regs(void *hal, HalTaskInfo *task, FifoCtx_t *pkt)
|
||||
p_regs->swreg40_cur_poc.sw_cur_poc = pp->CurrFieldOrderCnt[0];
|
||||
p_regs->swreg74_h264_cur_poc1.sw_h264_cur_poc1 = pp->CurrFieldOrderCnt[1];
|
||||
mpp_buf_slot_get_prop(p_hal->frame_slots, pp->CurrPic.Index7Bits, SLOT_BUFFER, &frame_buf); //!< current out phy addr
|
||||
//p_regs->swreg7_decout_base.sw_decout_base = pp->CurrPic.Index7Bits + 1;
|
||||
p_regs->swreg7_decout_base.sw_decout_base = mpp_buffer_get_fd(frame_buf);
|
||||
#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) >> 4;
|
||||
#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];
|
||||
@@ -429,8 +451,11 @@ void rkv_generate_regs(void *hal, HalTaskInfo *task, FifoCtx_t *pkt)
|
||||
} else {
|
||||
mpp_buf_slot_get_prop(p_hal->frame_slots, pp->RefFrameList[i].Index7Bits, SLOT_BUFFER, &frame_buf); //!< reference phy addr
|
||||
}
|
||||
//p_regs->swreg10_24_refer0_14_base[i].sw_refer_base = pp->RefFrameList[i].Index7Bits + 1;
|
||||
#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) >> 4;
|
||||
#endif
|
||||
}
|
||||
p_regs->swreg72_refer30_poc = pp->FieldOrderCntList[i][0];
|
||||
p_regs->swreg73_refer31_poc = pp->FieldOrderCntList[i][1];
|
||||
@@ -443,19 +468,22 @@ void rkv_generate_regs(void *hal, HalTaskInfo *task, FifoCtx_t *pkt)
|
||||
} else {
|
||||
mpp_buf_slot_get_prop(p_hal->frame_slots, pp->RefFrameList[15].Index7Bits, SLOT_BUFFER, &frame_buf); //!< reference phy addr
|
||||
}
|
||||
// p_regs->swreg48_refer15_base.sw_refer_base = pp->RefFrameList[15].Index7Bits + 1;
|
||||
#if FPGA_TEST
|
||||
p_regs->swreg48_refer15_base.sw_refer_base = pp->RefFrameList[15].Index7Bits + 1;
|
||||
#else
|
||||
p_regs->swreg48_refer15_base.sw_refer_base = mpp_buffer_get_fd(frame_buf) >> 4;
|
||||
|
||||
p_regs->swreg6_cabactbl_prob_base.sw_cabactbl_base = mpp_buffer_get_fd(p_hal->cabac_buf);
|
||||
#endif
|
||||
p_regs->swreg6_cabactbl_prob_base.sw_cabactbl_base = mpp_buffer_get_fd(p_hal->cabac_buf) >> 4;
|
||||
|
||||
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);
|
||||
p_regs->swreg4_strm_rlc_base.sw_strm_rlc_base = mpp_buffer_get_fd(bitstream_buf) >> 4;
|
||||
|
||||
fifo_packet_reset(pkt);
|
||||
fifo_write_bytes(pkt, (void *)p_hal->regs, sizeof(H264dRkvRegs_t));
|
||||
fifo_align_bits(pkt, 64);
|
||||
fifo_flush_bits(pkt);
|
||||
fifo_fwrite_data(pkt); //!< "REGH" header 32 bit
|
||||
FunctionOut(p_hal->logctx.parr[RUN_HAL]);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@@ -33,7 +33,7 @@
|
||||
#define RKV_SPSPPS_SIZE (256*32 + 128) /* bytes */
|
||||
#define RKV_RPS_SIZE (128 + 128) /* bytes */
|
||||
#define RKV_SCALING_LIST_SIZE (6*16+2*64 + 128) /* bytes */
|
||||
|
||||
#define RKV_ERROR_INFO_SIZE (256*144*4) /* bytes */
|
||||
typedef struct h264d_rkv_packet_t {
|
||||
FifoCtx_t spspps;
|
||||
FifoCtx_t rps;
|
||||
|
@@ -220,7 +220,7 @@ MPP_RET rkv_h264d_init(void *hal, MppHalCfg *cfg)
|
||||
|
||||
MEM_CHECK(ret, p_hal->pkts = mpp_calloc_size(void, sizeof(H264dRkvPkt_t)));
|
||||
//!< malloc cabac+scanlis + packets + poc_buf
|
||||
cabac_size = RKV_CABAC_TAB_SIZE + RKV_SPSPPS_SIZE + RKV_RPS_SIZE + RKV_SCALING_LIST_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));
|
||||
//!< copy cabac table bytes
|
||||
FUN_CHECK(ret = mpp_buffer_write(p_hal->cabac_buf, 0, (void *)H264_RKV_Cabac_table, sizeof(H264_RKV_Cabac_table)));
|
||||
@@ -299,9 +299,13 @@ MPP_RET rkv_h264d_gen_regs(void *hal, HalTaskInfo *task)
|
||||
mpp_buffer_write(p_hal->cabac_buf, strm_offset, (void *)pkts->rps.pbuf, RKV_RPS_SIZE);
|
||||
p_regs->swreg43_rps_base.sw_rps_base = hw_base + strm_offset;
|
||||
|
||||
strm_offset += RKV_SCALING_LIST_SIZE;
|
||||
strm_offset += RKV_RPS_SIZE;
|
||||
mpp_buffer_write(p_hal->cabac_buf, strm_offset, (void *)pkts->scanlist.pbuf, RKV_SCALING_LIST_SIZE);
|
||||
|
||||
strm_offset += RKV_SCALING_LIST_SIZE;
|
||||
strm_offset += mpp_buffer_get_fd(p_hal->cabac_buf) >> 4;
|
||||
p_regs->swreg75_h264_errorinfo_base.sw_errorinfo_base = strm_offset;
|
||||
|
||||
|
||||
((HalDecTask*)&task->dec)->valid = 0;
|
||||
FunctionOut(p_hal->logctx.parr[RUN_HAL]);
|
||||
|
@@ -237,6 +237,7 @@ const HalRegDrv_t g_vdpu_drv[VDPU_MAX_SIZE + 1] = {
|
||||
{ VDPU_DEC_OUT_DIS , 3 , 1, 15, "sw03_dec_out_dis " },
|
||||
{ VDPU_FILTERING_DIS , 3 , 1, 14, "sw03_filtering_dis " },
|
||||
{ VDPU_PIC_FIXED_QUANT , 3 , 1, 13, "sw03_pic_fixed_quant " },
|
||||
{ VDPU_MVC_E , 3 , 1, 13, "sw03_mvc_e " },
|
||||
{ VDPU_WRITE_MVS_E , 3 , 1, 12, "sw03_write_mvs_e " },
|
||||
{ VDPU_REFTOPFIRST_E , 3 , 1, 11, "sw03_reftopfirst_e " },
|
||||
{ VDPU_SEQ_MBAFF_E , 3 , 1, 10, "sw03_seq_mbaff_e " },
|
||||
@@ -952,14 +953,6 @@ const RK_U32 g_refBase[16] = {
|
||||
VDPU_REFER15_BASE
|
||||
};
|
||||
|
||||
const enum {
|
||||
H264ScalingList4x4Length = 16,
|
||||
H264ScalingList8x8Length = 64,
|
||||
} ScalingListLength;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef ANDROID
|
||||
RK_S32 VPUClientGetIOMMUStatus()
|
||||
@@ -1073,6 +1066,13 @@ MPP_RET vdpu_set_vlc_regs(void *hal, HalRegDrvCtx_t *p_drv)
|
||||
}
|
||||
FUN_CHECK(ret = hal_set_regdrv(p_drv, VDPU_REFER_LTERM_E, longTermflags << 16));
|
||||
FUN_CHECK(ret = hal_set_regdrv(p_drv, VDPU_REFER_VALID_E, validFlags << 16));
|
||||
|
||||
|
||||
//FPRINT(g_debug_file0, "ref_valid_e=%08x, longterm=%08x, mvc_e=%d, cur_poc=%d \n",
|
||||
// validFlags << 16, longTermflags << 16, 0, p_hal->pp->CurrFieldOrderCnt[0]);
|
||||
|
||||
//FPRINT(g_debug_file0, "--------- [FLUSH_CNT] flush framecnt=%d -------- \n", p_hal->iDecodedNum++);
|
||||
|
||||
}
|
||||
|
||||
for (i = 0; i < 16; i++) {
|
||||
@@ -1104,17 +1104,48 @@ MPP_RET vdpu_set_vlc_regs(void *hal, HalRegDrvCtx_t *p_drv)
|
||||
*pocBase++ = p_hal->pp->CurrFieldOrderCnt[0];
|
||||
*pocBase++ = p_hal->pp->CurrFieldOrderCnt[1];
|
||||
}
|
||||
#if 0
|
||||
|
||||
|
||||
|
||||
//pocBase = (RK_U32 *) ((RK_U8 *)mpp_buffer_get_ptr(p_hal->cabac_buf) + VDPU_CABAC_TAB_SIZE);
|
||||
//for (i = 0; i < VDPU_POC_BUF_SIZE / 4; i++)
|
||||
//{
|
||||
// FPRINT(g_debug_file0, "i=%d, poc_value=%d, idx=%d \n", i, *pocBase++, p_hal->pp->RefFrameList[i / 2].Index7Bits);
|
||||
//}
|
||||
//pocBase = (RK_U32 *) ((RK_U8 *)mpp_buffer_get_ptr(p_hal->cabac_buf) + VDPU_CABAC_TAB_SIZE);
|
||||
//for (i = 0; i < VDPU_POC_BUF_SIZE / 4; i++)
|
||||
//{
|
||||
// FPRINT(g_debug_file1, "i=%d, poc_value=%d, idx=%d \n", i, *pocBase++, p_hal->pp->RefFrameList[i / 2].Index7Bits);
|
||||
//}
|
||||
//FPRINT(g_debug_file0, "------ g_framecnt=%d \n", p_hal->in_task->g_framecnt);
|
||||
|
||||
|
||||
pocBase = (RK_U32 *) ((RK_U8 *)mpp_buffer_get_ptr(p_hal->cabac_buf) + VDPU_CABAC_TAB_SIZE);
|
||||
for(i = 0; i < 16; i++) {
|
||||
RK_S32 dpb_idx = 0, longTermTmp = 0;
|
||||
if (p_hal->pp->RefFrameList[i / 2].bPicEntry != 0xff) {
|
||||
FPRINT(g_debug_file1, "i=%2d, picnum=%d, framenum=%2d,", i, p_hal->pp->FrameNumList[i], p_hal->pp->FrameNumList[i]);
|
||||
longTermTmp = p_hal->pp->RefFrameList[i].AssociatedFlag;
|
||||
dpb_idx = p_hal->pp->RefFrameList[i / 2].Index7Bits;
|
||||
FPRINT(g_debug_file1, " dbp_idx=%d, longterm=%d, poc=%d \n", dpb_idx, longTermTmp, *pocBase);
|
||||
}
|
||||
pocBase +=2;
|
||||
}
|
||||
hal_get_regdrv((HalRegDrvCtx_t *)p_hal->regs, VDPU_REFER_VALID_E, &validFlags);
|
||||
FPRINT(g_debug_file1, " view=%d, nonivref=%d, iv_base=%08x, ref_valid_e=%d, mvc_e=%d, cur_poc=%d \n", 0, 0, 0x0, validFlags, 0, *pocBase);
|
||||
FPRINT(g_debug_file1, "--------- [FLUSH_CNT] flush framecnt=%d --------\n", p_hal->iDecodedNum);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
FUN_CHECK(ret = hal_set_regdrv(p_drv, VDPU_CABAC_E , p_hal->pp->entropy_coding_mode_flag));
|
||||
//!< stream position update
|
||||
FUN_CHECK(ret = hal_set_regdrv(p_drv, VDPU_START_CODE_E , 1));
|
||||
@@ -1185,15 +1216,14 @@ __FAILED:
|
||||
//extern "C"
|
||||
MPP_RET vdpu_set_asic_regs(void *hal, HalRegDrvCtx_t *p_drv)
|
||||
{
|
||||
RK_U32 i = 0;
|
||||
RK_U32 i = 0, j = 0;
|
||||
RK_U32 validTmp = 0;
|
||||
RK_U32 outPhyAddr = 0;
|
||||
RK_U32 dirMvOffset = 0;
|
||||
RK_U32 picSizeInMbs = 0;
|
||||
RK_U8 *p_start = NULL;
|
||||
MPP_RET ret = MPP_ERR_UNKNOW;
|
||||
MppBuffer frame_buf = NULL;
|
||||
FifoCtx_t pkt_scanlist = { 0 };
|
||||
|
||||
|
||||
H264dHalCtx_t *p_hal = (H264dHalCtx_t *)hal;
|
||||
DXVA_PicParams_H264_MVC *pp = p_hal->pp;
|
||||
@@ -1202,16 +1232,19 @@ MPP_RET vdpu_set_asic_regs(void *hal, HalRegDrvCtx_t *p_drv)
|
||||
|
||||
FunctionIn(p_hal->logctx.parr[RUN_HAL]);
|
||||
/* reference picture physis address */
|
||||
LogTrace(p_hal->logctx.parr[RUN_HAL], "reference mpp_buffer_get_fd begin");
|
||||
for (i = 0; i < MPP_ARRAY_ELEMS(pp->RefFrameList); i++) {
|
||||
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
|
||||
}
|
||||
for (i = 0, j = 0xff; i < MPP_ARRAY_ELEMS(pp->RefFrameList); i++) {
|
||||
if (pp->RefFrameList[i].bPicEntry != 0xff) {
|
||||
mpp_buf_slot_get_prop(p_hal->frame_slots, pp->RefFrameList[i].Index7Bits, SLOT_BUFFER, &frame_buf); //!< reference phy addr
|
||||
j = i;
|
||||
} else/* if(j == 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, j, SLOT_BUFFER, &frame_buf); //!< current out phy addr
|
||||
//}
|
||||
|
||||
FUN_CHECK(ret = hal_set_regdrv(p_drv, g_refBase[i], mpp_buffer_get_fd(frame_buf)));
|
||||
}
|
||||
LogTrace(p_hal->logctx.parr[RUN_HAL], "reference mpp_buffer_get_fd end");
|
||||
/* inter-view reference picture */
|
||||
if (pp->curr_layer_id && priv->ilt_dpb[0].valid /*pp->inter_view_flag*/) {
|
||||
mpp_buf_slot_get_prop(p_hal->frame_slots, priv->ilt_dpb[0].slot_index, SLOT_BUFFER, &frame_buf); //!< current out phy addr
|
||||
@@ -1222,10 +1255,8 @@ MPP_RET vdpu_set_asic_regs(void *hal, HalRegDrvCtx_t *p_drv)
|
||||
}
|
||||
FUN_CHECK(ret = hal_set_regdrv(p_drv, VDPU_MVC_E, pp->curr_layer_id));
|
||||
FUN_CHECK(ret = hal_set_regdrv(p_drv, VDPU_FILTERING_DIS, 0)); //!< filterDisable = 0;
|
||||
LogTrace(p_hal->logctx.parr[RUN_HAL], "current mpp_buffer_get_fd begin");
|
||||
mpp_buf_slot_get_prop(p_hal->frame_slots, pp->CurrPic.Index7Bits, SLOT_BUFFER, &frame_buf); //!< current out phy addr
|
||||
outPhyAddr = mpp_buffer_get_fd(frame_buf);
|
||||
LogTrace(p_hal->logctx.parr[RUN_HAL], "current mpp_buffer_get_fd end");
|
||||
if (pp->field_pic_flag && pp->CurrPic.AssociatedFlag) {
|
||||
if (VPUClientGetIOMMUStatus() > 0) {
|
||||
outPhyAddr |= ((pp->wFrameWidthInMbsMinus1 + 1) * 16) << 10;
|
||||
@@ -1233,7 +1264,7 @@ MPP_RET vdpu_set_asic_regs(void *hal, HalRegDrvCtx_t *p_drv)
|
||||
outPhyAddr += (pp->wFrameWidthInMbsMinus1 + 1) * 16;
|
||||
}
|
||||
}
|
||||
FUN_CHECK(ret = hal_set_regdrv(p_drv, VDPU_DEC_OUT_BASE, outPhyAddr)); //!< outPhyAddr, pp->CurrPic.Index7Bits
|
||||
FUN_CHECK(ret = hal_set_regdrv(p_drv, VDPU_DEC_OUT_BASE, outPhyAddr)); //!< outPhyAddr, pp->CurrPic.Index7Bits
|
||||
|
||||
FUN_CHECK(ret = hal_set_regdrv(p_drv, VDPU_CH_QP_OFFSET, pp->chroma_qp_index_offset));
|
||||
FUN_CHECK(ret = hal_set_regdrv(p_drv, VDPU_CH_QP_OFFSET2, pp->second_chroma_qp_index_offset));
|
||||
@@ -1249,33 +1280,66 @@ MPP_RET vdpu_set_asic_regs(void *hal, HalRegDrvCtx_t *p_drv)
|
||||
FUN_CHECK(ret = hal_set_regdrv(p_drv, VDPU_DIR_MV_BASE, outPhyAddr + dirMvOffset));
|
||||
}
|
||||
|
||||
|
||||
FUN_CHECK(ret = hal_set_regdrv(p_drv, VDPU_WRITE_MVS_E, (p_long->nal_ref_idc != 0))); //!< defalut set 1
|
||||
FUN_CHECK(ret = hal_set_regdrv(p_drv, VDPU_DIR_8X8_INFER_E, pp->direct_8x8_inference_flag));
|
||||
FUN_CHECK(ret = hal_set_regdrv(p_drv, VDPU_WEIGHT_PRED_E, pp->weighted_pred_flag));
|
||||
FUN_CHECK(ret = hal_set_regdrv(p_drv, VDPU_WEIGHT_BIPR_IDC, pp->weighted_bipred_idc));
|
||||
FUN_CHECK(ret = hal_set_regdrv(p_drv, VDPU_REFIDX1_ACTIVE, (pp->num_ref_idx_l1_active_minus1 + 1)));
|
||||
FUN_CHECK(ret = hal_set_regdrv(p_drv, VDPU_FIELDPIC_FLAG_E, !pp->frame_mbs_only_flag));
|
||||
FUN_CHECK(ret = hal_set_regdrv(p_drv, VDPU_FIELDPIC_FLAG_E, !pp->frame_mbs_only_flag));
|
||||
|
||||
FUN_CHECK(ret = hal_set_regdrv(p_drv, VDPU_PIC_INTERLACE_E, !pp->frame_mbs_only_flag && (pp->MbaffFrameFlag || pp->field_pic_flag)));
|
||||
FUN_CHECK(ret = hal_set_regdrv(p_drv, VDPU_PIC_INTERLACE_E, !pp->frame_mbs_only_flag && (pp->MbaffFrameFlag || pp->field_pic_flag)));
|
||||
FUN_CHECK(ret = hal_set_regdrv(p_drv, VDPU_PIC_FIELDMODE_E, pp->field_pic_flag));
|
||||
FUN_CHECK(ret = hal_set_regdrv(p_drv, VDPU_PIC_TOPFIELD_E, !pp->CurrPic.AssociatedFlag)); //!< bottomFieldFlag
|
||||
FUN_CHECK(ret = hal_set_regdrv(p_drv, VDPU_PIC_TOPFIELD_E, !pp->CurrPic.AssociatedFlag)); //!< bottomFieldFlag
|
||||
FUN_CHECK(ret = hal_set_regdrv(p_drv, VDPU_SEQ_MBAFF_E, pp->MbaffFrameFlag));
|
||||
FUN_CHECK(ret = hal_set_regdrv(p_drv, VDPU_8X8TRANS_FLAG_E, pp->transform_8x8_mode_flag));
|
||||
FUN_CHECK(ret = hal_set_regdrv(p_drv, VDPU_BLACKWHITE_E, p_long->profileIdc >= 100 && pp->chroma_format_idc == 0));
|
||||
FUN_CHECK(ret = hal_set_regdrv(p_drv, VDPU_TYPE1_QUANT_E, pp->scaleing_list_enable_flag));
|
||||
|
||||
if (p_hal->pp->scaleing_list_enable_flag) {
|
||||
p_start = (RK_U8 *)mpp_buffer_get_ptr(p_hal->cabac_buf) + VDPU_CABAC_TAB_SIZE + VDPU_POC_BUF_SIZE;
|
||||
RK_U32 temp = 0;
|
||||
RK_U32 *ptr = NULL;
|
||||
|
||||
fifo_packet_init(&pkt_scanlist, p_start, VDPU_SCALING_LIST_SIZE);
|
||||
for (i = 0; i < 6; ++i) { //!< 4x4, 6 lists
|
||||
fifo_write_bytes(&pkt_scanlist, p_hal->qm->bScalingLists4x4[i], H264ScalingList4x4Length);
|
||||
}
|
||||
for (i = 0; i < 2; ++i) {
|
||||
fifo_write_bytes(&pkt_scanlist, p_hal->qm->bScalingLists8x8[i], H264ScalingList8x8Length);
|
||||
}
|
||||
}
|
||||
ptr = (RK_U32 *)((RK_U8 *)mpp_buffer_get_ptr(p_hal->cabac_buf) + VDPU_CABAC_TAB_SIZE + VDPU_POC_BUF_SIZE);
|
||||
for(i = 0; i < 6; i++) {
|
||||
for(j = 0; j < 4; j++) {
|
||||
temp = (p_hal->qm->bScalingLists4x4[i][4 * j + 0] << 24) |
|
||||
(p_hal->qm->bScalingLists4x4[i][4 * j + 1] << 16) |
|
||||
(p_hal->qm->bScalingLists4x4[i][4 * j + 2] << 8) |
|
||||
(p_hal->qm->bScalingLists4x4[i][4 * j + 3]);
|
||||
*ptr++ = temp;
|
||||
}
|
||||
}
|
||||
for(i = 0; i < 2; i++) {
|
||||
for(j = 0; j < 16; j++) {
|
||||
temp = (p_hal->qm->bScalingLists8x8[i][4 * j + 0] << 24) |
|
||||
(p_hal->qm->bScalingLists8x8[i][4 * j + 1] << 16) |
|
||||
(p_hal->qm->bScalingLists8x8[i][4 * j + 2] << 8) |
|
||||
(p_hal->qm->bScalingLists8x8[i][4 * j + 3]);
|
||||
*ptr++ = temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
{
|
||||
RK_U8 i = 0, j = 0;
|
||||
RK_U8 *ptr = (RK_U8 *)mpp_buffer_get_ptr(p_hal->cabac_buf) + VDPU_CABAC_TAB_SIZE + VDPU_POC_BUF_SIZE;
|
||||
for(i = 0; i < 6; i++) {
|
||||
for(j = 0; j < 16; j++) {
|
||||
FPRINT(g_debug_file1, "[i=%2d][j=%2d]=%d, ", i, j, *ptr);
|
||||
ptr++;
|
||||
}
|
||||
FPRINT(g_debug_file1, "\n");
|
||||
}
|
||||
for(i = 6; i < 8; i++) {
|
||||
for(j = 0; j < 64; j++) {
|
||||
FPRINT(g_debug_file1, "[i=%2d][j=%2d]=%d, ", i, j, *ptr);
|
||||
ptr++;
|
||||
}
|
||||
FPRINT(g_debug_file1, "\n");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
FUN_CHECK(ret = hal_set_regdrv(p_drv, VDPU_DEC_OUT_DIS, 0)); //!< set defalut 0
|
||||
FUN_CHECK(ret = hal_set_regdrv(p_drv, VDPU_CH_8PIX_ILEAV_E, 0));
|
||||
|
@@ -141,7 +141,7 @@
|
||||
#endif
|
||||
|
||||
/* Check validity of values */
|
||||
/* data discard and tiled mode can not be on simultaneously */
|
||||
/* data display and tiled mode can not be on simultaneously */
|
||||
#if (DEC_X170_DATA_DISCARD_ENABLE && (DEC_X170_OUTPUT_FORMAT == DEC_X170_OUTPUT_FORMAT_TILED))
|
||||
#error "Bad value specified: DEC_X170_DATA_DISCARD_ENABLE && (DEC_X170_OUTPUT_FORMAT == DEC_X170_OUTPUT_FORMAT_TILED)"
|
||||
#endif
|
||||
|
@@ -35,16 +35,17 @@
|
||||
|
||||
|
||||
|
||||
//static void print_single_regs(HalRegDrvCtx_t *p_drv, const HalRegDrv_t *pcur)
|
||||
//{
|
||||
// RK_S32 val = 0;
|
||||
// hal_get_regdrv(p_drv, pcur->syn_id, (RK_U32 *)&val);
|
||||
// LogInfo((LogCtx_t *)p_drv->log, "name=[%24s], reg=[%.2d], bit=[%.2d], len=[%.2d], val=[%8d]",
|
||||
// pcur->name, pcur->reg_id, pcur->bitpos, pcur->bitlen, val);
|
||||
//}
|
||||
static void print_single_regs(HalRegDrvCtx_t *p_drv, const HalRegDrv_t *pcur)
|
||||
{
|
||||
RK_S32 val = 0;
|
||||
hal_get_regdrv(p_drv, pcur->syn_id, (RK_U32 *)&val);
|
||||
LogInfo((LogCtx_t *)p_drv->log, "name=[%24s], reg=[%.2d], bit=[%.2d], len=[%.2d], val=[%8d]",
|
||||
pcur->name, pcur->reg_id, pcur->bitpos, pcur->bitlen, val);
|
||||
}
|
||||
|
||||
|
||||
RK_U32 g_print_init_value = 1;
|
||||
|
||||
static MPP_RET vdpu_h264d_print_regs(H264dHalCtx_t *p_hal, HalRegDrvCtx_t *p_drv)
|
||||
{
|
||||
RK_U32 i = 0;
|
||||
@@ -55,9 +56,9 @@ static MPP_RET vdpu_h264d_print_regs(H264dHalCtx_t *p_hal, HalRegDrvCtx_t *p_drv
|
||||
INP_CHECK(ret, NULL == p_drv);
|
||||
logctx = (LogCtx_t *)p_drv->log;
|
||||
if (LogEnable(logctx, LOG_LEVEL_INFO)) {
|
||||
#if 0
|
||||
if (g_print_init_value) {
|
||||
g_print_init_value = 0;
|
||||
#if 1
|
||||
if (g_print_init_value) {
|
||||
g_print_init_value = 0;
|
||||
LogInfo((LogCtx_t *)p_drv->log, "---------------- VDPU REG START ------------------ ");
|
||||
//!< ---------------- init register -------------
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_DEC_MODE ]);
|
||||
@@ -95,87 +96,88 @@ static MPP_RET vdpu_h264d_print_regs(H264dHalCtx_t *p_hal, HalRegDrvCtx_t *p_drv
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
LogInfo(logctx, "[SET_REG] g_framecnt=%d, ---- DECODE BEING -------", p_hal->in_task->g_framecnt);
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_DEC_OUT_DIS ]);
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_RLC_MODE_E ]);
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_INIT_QP ]);
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_REFIDX0_ACTIVE ]);
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_REF_FRAMES ]);
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_FRAMENUM_LEN ]);
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_FRAMENUM ]);
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_CONST_INTRA_E ]);
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_FILT_CTRL_PRES ]);
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_RDPIC_CNT_PRES ]);
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_REFPIC_MK_LEN ]);
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_IDR_PIC_E ]);
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_IDR_PIC_ID ]);
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_PPS_ID ]);
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_POC_LENGTH ]);
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_REFER_LTERM_E ]);
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_REFER_VALID_E ]);
|
||||
for (i = 0; i < 16; i++) {
|
||||
if (p_hal->pp->RefFrameList[i].bPicEntry != 0xff) { //!< valid
|
||||
print_single_regs(p_drv, &p_drv->p_emt[g_refPicNum[i]]);
|
||||
}
|
||||
}
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_PICORD_COUNT_E ]);
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_CABAC_E ]);
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_START_CODE_E ]);
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_STRM_START_BIT ]);
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_RLC_VLC_BASE ]);
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_STREAM_LEN ]);
|
||||
/* P lists */
|
||||
for (i = 0; i < MPP_ARRAY_ELEMS(g_refPicListP); i++) {
|
||||
print_single_regs(p_drv, &p_drv->p_emt[g_refPicListP[i]]);
|
||||
}
|
||||
/* B lists */
|
||||
for (i = 0; i < MPP_ARRAY_ELEMS(g_refPicList0); i++) {
|
||||
print_single_regs(p_drv, &p_drv->p_emt[g_refPicList0[i]]);
|
||||
print_single_regs(p_drv, &p_drv->p_emt[g_refPicList1[i]]);
|
||||
}
|
||||
/* reference based address */
|
||||
for (i = 0; i < MPP_ARRAY_ELEMS(g_refBase); i++) {
|
||||
print_single_regs(p_drv, &p_drv->p_emt[g_refBase[i]]);
|
||||
}
|
||||
/* inter-view reference picture */
|
||||
if (p_hal->pp->curr_layer_id && p_hal->pp->inter_view_flag) {
|
||||
#if 1
|
||||
{
|
||||
LogInfo(logctx, "[SET_REG] g_framecnt=%d, ---- DECODE BEING -------", p_hal->iDecodedNum);
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_DEC_OUT_DIS ]);
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_RLC_MODE_E ]);
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_INIT_QP ]);
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_REFIDX0_ACTIVE ]);
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_REF_FRAMES ]);
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_FRAMENUM_LEN ]);
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_FRAMENUM ]);
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_CONST_INTRA_E ]);
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_FILT_CTRL_PRES ]);
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_RDPIC_CNT_PRES ]);
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_REFPIC_MK_LEN ]);
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_IDR_PIC_E ]);
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_IDR_PIC_ID ]);
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_PPS_ID ]);
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_POC_LENGTH ]);
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_REFER_LTERM_E ]);
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_REFER_VALID_E ]);
|
||||
for (i = 0; i < 16; i++) {
|
||||
if (p_hal->pp->RefFrameList[i].bPicEntry != 0xff) { //!< valid
|
||||
print_single_regs(p_drv, &p_drv->p_emt[g_refPicNum[i]]);
|
||||
}
|
||||
}
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_PICORD_COUNT_E ]);
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_CABAC_E ]);
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_START_CODE_E ]);
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_STRM_START_BIT ]);
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_RLC_VLC_BASE ]);
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_STREAM_LEN ]);
|
||||
/* P lists */
|
||||
for (i = 0; i < MPP_ARRAY_ELEMS(g_refPicListP); i++) {
|
||||
print_single_regs(p_drv, &p_drv->p_emt[g_refPicListP[i]]);
|
||||
}
|
||||
/* B lists */
|
||||
for (i = 0; i < MPP_ARRAY_ELEMS(g_refPicList0); i++) {
|
||||
print_single_regs(p_drv, &p_drv->p_emt[g_refPicList0[i]]);
|
||||
print_single_regs(p_drv, &p_drv->p_emt[g_refPicList1[i]]);
|
||||
}
|
||||
/* reference based address */
|
||||
for (i = 0; i < MPP_ARRAY_ELEMS(g_refBase); i++) {
|
||||
print_single_regs(p_drv, &p_drv->p_emt[g_refBase[i]]);
|
||||
}
|
||||
/* inter-view reference picture */
|
||||
if (p_hal->pp->curr_layer_id && p_hal->pp->inter_view_flag) {
|
||||
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_INTER_VIEW_BASE]);
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_REFER_VALID_E]);
|
||||
}
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_INTER_VIEW_BASE]);
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_REFER_VALID_E]);
|
||||
}
|
||||
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_PIC_FIXED_QUANT]); //!< VDPU_MVC_E
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_FILTERING_DIS]); //!< filterDisable = 0;
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_DEC_OUT_BASE]); //!< outPhyAddr, pp->CurrPic.Index7Bits
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_PIC_FIXED_QUANT]); //!< VDPU_MVC_E
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_FILTERING_DIS]); //!< filterDisable = 0;
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_DEC_OUT_BASE]); //!< outPhyAddr, pp->CurrPic.Index7Bits
|
||||
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_CH_QP_OFFSET]);
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_CH_QP_OFFSET2]);
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_CH_QP_OFFSET]);
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_CH_QP_OFFSET2]);
|
||||
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_DIR_MV_BASE]);
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_WRITE_MVS_E]); //!< defalut set 1
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_DIR_8X8_INFER_E]);
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_WEIGHT_PRED_E]);
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_WEIGHT_BIPR_IDC]);
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_REFIDX1_ACTIVE]);
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_FIELDPIC_FLAG_E]);
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_PIC_INTERLACE_E]);
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_PIC_FIELDMODE_E]);
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_PIC_TOPFIELD_E]); //!< bottomFieldFlag
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_SEQ_MBAFF_E]);
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_8X8TRANS_FLAG_E]);
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_BLACKWHITE_E]);
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_TYPE1_QUANT_E]);
|
||||
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_DEC_OUT_DIS]); //!< set defalut 0
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_CH_8PIX_ILEAV_E]);
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_DEC_E]);
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_QTABLE_BASE]);
|
||||
LogInfo((LogCtx_t *)p_drv->log, "--------- [FLUSH_CNT] flush framecnt=%d -------- \n", p_hal->in_task->g_framecnt);
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_DEC_IRQ_STAT]);
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_DEC_IRQ]);
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_DEC_PIC_INF]);
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_DIR_MV_BASE]);
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_WRITE_MVS_E]); //!< defalut set 1
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_DIR_8X8_INFER_E]);
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_WEIGHT_PRED_E]);
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_WEIGHT_BIPR_IDC]);
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_REFIDX1_ACTIVE]);
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_FIELDPIC_FLAG_E]);
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_PIC_INTERLACE_E]);
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_PIC_FIELDMODE_E]);
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_PIC_TOPFIELD_E]); //!< bottomFieldFlag
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_SEQ_MBAFF_E]);
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_8X8TRANS_FLAG_E]);
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_BLACKWHITE_E]);
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_TYPE1_QUANT_E]);
|
||||
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_DEC_OUT_DIS]); //!< set defalut 0
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_CH_8PIX_ILEAV_E]);
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_DEC_E]);
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_QTABLE_BASE]);
|
||||
LogInfo((LogCtx_t *)p_drv->log, "--------- [FLUSH_CNT] flush framecnt=%d -------- \n", p_hal->iDecodedNum);
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_DEC_IRQ_STAT]);
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_DEC_IRQ]);
|
||||
print_single_regs(p_drv, &p_drv->p_emt[VDPU_DEC_PIC_INF]);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
(void)i;
|
||||
@@ -291,6 +293,9 @@ static MPP_RET vdpu_adjust_input(H264dHalCtx_t *p_hal)
|
||||
H264dVdpuDpb_t *old_dpb = priv->old_dpb[pp->curr_layer_id];
|
||||
H264dVdpuDpb_t *ilt_dpb = priv->ilt_dpb;
|
||||
|
||||
|
||||
assert(pp->curr_layer_id == 0);
|
||||
|
||||
//!< change input dxva into pdb structure
|
||||
priv->new_dpb_cnt = 0;
|
||||
priv->ilt_dpb_cnt = 0;
|
||||
@@ -318,6 +323,7 @@ static MPP_RET vdpu_adjust_input(H264dHalCtx_t *p_hal)
|
||||
}
|
||||
//!< inter-view frame flag
|
||||
if (new_dpb[i].is_ilt) {
|
||||
assert(0);
|
||||
ilt_dpb[priv->ilt_dpb_cnt] = new_dpb[i];
|
||||
ilt_dpb[priv->ilt_dpb_cnt].valid = 1;
|
||||
priv->ilt_dpb_cnt++;
|
||||
@@ -327,65 +333,90 @@ static MPP_RET vdpu_adjust_input(H264dHalCtx_t *p_hal)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (p_hal->iDecodedNum == 3)
|
||||
{
|
||||
i = i;
|
||||
}
|
||||
|
||||
//for (i = 0; i < MPP_ARRAY_ELEMS(pp->RefFrameList); i++) {
|
||||
// if (new_dpb[i].valid) {
|
||||
// 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,
|
||||
// new_dpb[i].TOP_POC);
|
||||
// }
|
||||
//}
|
||||
//FPRINT(g_debug_file0, "--------- [new DPB] -------- \n");
|
||||
//for (i = 0; i < MPP_ARRAY_ELEMS(pp->RefFrameList); i++) {
|
||||
// if (old_dpb[i].valid) {
|
||||
// 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,
|
||||
// old_dpb[i].TOP_POC);
|
||||
// }
|
||||
//}
|
||||
//FPRINT(g_debug_file0, "--------- [Old DPB] -------- \n");
|
||||
|
||||
//!< delete old dpb
|
||||
for (i = 0; i < MPP_ARRAY_ELEMS(pp->RefFrameList); i++) {
|
||||
if (priv->new_dpb[i].valid == 0) {
|
||||
continue;
|
||||
}
|
||||
for (j = 0; j <= priv->new_dpb_cnt; j++) {
|
||||
find_flag = (old_dpb[i].frame_num == new_dpb[j].frame_num) ? 1 : 0;
|
||||
if (new_dpb[j].top_used) {
|
||||
find_flag = (old_dpb[i].TOP_POC == new_dpb[j].TOP_POC) ? find_flag : 0;
|
||||
}
|
||||
if (new_dpb[j].bot_used) {
|
||||
find_flag = (old_dpb[i].BOT_POC == new_dpb[j].BOT_POC) ? find_flag : 0;
|
||||
}
|
||||
if (find_flag) { //!< found
|
||||
new_dpb[j].have_same = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
find_flag = 0;
|
||||
|
||||
if (old_dpb[i].valid) {
|
||||
for (j = 0; j < MPP_ARRAY_ELEMS(pp->RefFrameList); j++) {
|
||||
if(new_dpb[j].valid) {
|
||||
find_flag = (old_dpb[i].frame_num == new_dpb[j].frame_num) ? 1 : 0;
|
||||
if (new_dpb[j].top_used) {
|
||||
find_flag = (old_dpb[i].TOP_POC == new_dpb[j].TOP_POC) ? find_flag : 0;
|
||||
}
|
||||
if (new_dpb[j].bot_used) {
|
||||
find_flag = (old_dpb[i].BOT_POC == new_dpb[j].BOT_POC) ? find_flag : 0;
|
||||
}
|
||||
if (find_flag) { //!< found
|
||||
new_dpb[j].have_same = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//!< not found
|
||||
if (find_flag == 0) {
|
||||
memset(&old_dpb[i], 0, sizeof(H264dVdpuDpb_t));
|
||||
}
|
||||
}
|
||||
//!< add new dpb
|
||||
for (j = 0; j <= priv->new_dpb_cnt; j++) {
|
||||
if (priv->new_dpb[j].have_same) {
|
||||
continue;
|
||||
}
|
||||
for (j = 0; j < MPP_ARRAY_ELEMS(pp->RefFrameList); j++) {
|
||||
if ((new_dpb[j].valid == 0) || new_dpb[j].have_same) {
|
||||
continue;
|
||||
}
|
||||
for (i = 0; i < MPP_ARRAY_ELEMS(pp->RefFrameList); i++) {
|
||||
if (old_dpb[i].valid) {
|
||||
continue;
|
||||
}
|
||||
old_dpb[i] = new_dpb[j];
|
||||
if (old_dpb[i].valid == 0) {
|
||||
old_dpb[i] = new_dpb[j];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
//!< re-fill reference dxva syntax
|
||||
pp->UsedForReferenceFlags = 0;
|
||||
pp->NonExistingFrameFlags = 0;
|
||||
memset(pp->RefFrameList, 0, sizeof(pp->RefFrameList));
|
||||
memset(pp->RefFrameList, 0xff, sizeof(pp->RefFrameList));
|
||||
memset(pp->FieldOrderCntList, 0, sizeof(pp->FieldOrderCntList));
|
||||
memset(pp->LongTermPicNumList, 0, sizeof(pp->LongTermPicNumList));
|
||||
memset(pp->FrameNumList, 0, sizeof(pp->FrameNumList));
|
||||
|
||||
for (i = 0; i < MPP_ARRAY_ELEMS(pp->RefFrameList); i++) {
|
||||
if (new_dpb[i].valid) {
|
||||
pp->RefFrameList[i].Index7Bits = new_dpb[i].slot_index;
|
||||
pp->RefFrameList[i].AssociatedFlag = new_dpb[i].is_long_term;
|
||||
if (old_dpb[i].valid) {
|
||||
pp->RefFrameList[i].Index7Bits = old_dpb[i].slot_index;
|
||||
pp->RefFrameList[i].AssociatedFlag = old_dpb[i].is_long_term;
|
||||
|
||||
pp->FieldOrderCntList[i][0] = new_dpb[i].TOP_POC;
|
||||
pp->FieldOrderCntList[i][1] = new_dpb[i].BOT_POC;
|
||||
pp->FrameNumList[i] = new_dpb[i].frame_num;
|
||||
pp->LongTermPicNumList[i] = new_dpb[i].LongTermPicNum;
|
||||
pp->NonExistingFrameFlags |= new_dpb[i].non_exist_frame ? (1 << i) : 0;
|
||||
if (new_dpb[i].top_used) { //!< top_field
|
||||
pp->FieldOrderCntList[i][0] = old_dpb[i].TOP_POC;
|
||||
pp->FieldOrderCntList[i][1] = old_dpb[i].BOT_POC;
|
||||
pp->FrameNumList[i] = old_dpb[i].frame_num;
|
||||
pp->LongTermPicNumList[i] = old_dpb[i].LongTermPicNum;
|
||||
pp->NonExistingFrameFlags |= old_dpb[i].non_exist_frame ? (1 << i) : 0;
|
||||
if (old_dpb[i].top_used) { //!< top_field
|
||||
pp->UsedForReferenceFlags |= 1 << (2 * i + 0);
|
||||
}
|
||||
if (new_dpb[i].bot_used) { //!< bot_field
|
||||
pp->UsedForReferenceFlags |= 1 << (2 * i + 1);
|
||||
}
|
||||
//if (old_dpb[i].bot_used) { //!< bot_field
|
||||
// pp->UsedForReferenceFlags |= 1 << (2 * i + 1);
|
||||
//}
|
||||
} else {
|
||||
pp->RefFrameList[i].bPicEntry = 0xff;
|
||||
pp->FieldOrderCntList[i][0] = 0;
|
||||
@@ -394,6 +425,15 @@ static MPP_RET vdpu_adjust_input(H264dHalCtx_t *p_hal)
|
||||
}
|
||||
}
|
||||
|
||||
//for (i = 0; i < MPP_ARRAY_ELEMS(pp->RefFrameList); i++) {
|
||||
// if (old_dpb[i].valid) {
|
||||
// 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,
|
||||
// old_dpb[i].TOP_POC);
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
return MPP_OK;
|
||||
}
|
||||
|
||||
@@ -506,7 +546,7 @@ MPP_RET vdpu_h264d_gen_regs(void *hal, HalTaskInfo *task)
|
||||
FunctionIn(p_hal->logctx.parr[RUN_HAL]);
|
||||
LogTrace(p_hal->logctx.parr[RUN_HAL], "[Generate register begin]");
|
||||
|
||||
FUN_CHECK(ret = vdpu_adjust_input(p_hal));
|
||||
//FUN_CHECK(ret = vdpu_adjust_input(p_hal));
|
||||
FUN_CHECK(ret = vdpu_set_pic_regs(hal, p_drv));
|
||||
FUN_CHECK(ret = vdpu_set_vlc_regs(hal, p_drv));
|
||||
FUN_CHECK(ret = vdpu_set_ref_regs(hal, p_drv));
|
||||
@@ -546,7 +586,7 @@ MPP_RET vdpu_h264d_start(void *hal, HalTaskInfo *task)
|
||||
ret = MPP_ERR_VPUHW;
|
||||
mpp_err_f("H264 VDPU FlushRegs fail. \n");
|
||||
} else {
|
||||
mpp_log("H264 VDPU FlushRegs success, frame_no=%d. \n", p_hal->iDecodedNum);
|
||||
mpp_log("H264 VDPU FlushRegs success, pid=%d, hal_frame_no=%d. \n", getpid(), p_hal->iDecodedNum);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@@ -156,6 +156,8 @@ MPP_FRAME_ACCESSORS(RK_U32, height)
|
||||
MPP_FRAME_ACCESSORS(RK_U32, hor_stride)
|
||||
MPP_FRAME_ACCESSORS(RK_U32, ver_stride)
|
||||
MPP_FRAME_ACCESSORS(RK_U32, mode)
|
||||
MPP_FRAME_ACCESSORS(RK_U32, display)
|
||||
MPP_FRAME_ACCESSORS(RK_U32, viewid)
|
||||
MPP_FRAME_ACCESSORS(RK_S64, pts)
|
||||
MPP_FRAME_ACCESSORS(RK_S64, dts)
|
||||
MPP_FRAME_ACCESSORS(RK_U32, eos)
|
||||
|
@@ -43,6 +43,17 @@ struct MppFrameImpl_t {
|
||||
* 7 - deinterlaced paired field
|
||||
*/
|
||||
RK_U32 mode;
|
||||
/*
|
||||
* current decoded frame whether to display
|
||||
*
|
||||
* 0 - display
|
||||
* 1 - display
|
||||
*/
|
||||
RK_U32 display;
|
||||
/*
|
||||
* send decoded frame belong which view
|
||||
*/
|
||||
RK_U32 viewid;
|
||||
|
||||
/*
|
||||
* pts - display time stamp
|
||||
|
@@ -514,7 +514,7 @@ static MPP_RET read_next_nalu(InputParams *p_in)
|
||||
//{
|
||||
// g_debug_file0 = fopen("rk_debugfile_view0.txt", "wb");
|
||||
//}
|
||||
//FPRINT(g_debug_file0, "g_nalu_cnt = %d, nal_unit_type = %d, nalu_size = %d\n", g_nalu_cnt2++, nal_unit_type, p_in->IO.nalubytes);
|
||||
//FPRINT(g_debug_file0, "[Read_NALU] g_nalu_cnt = %d, nal_unit_type = %d, nalu_size = %d\n", g_nalu_cnt2++, nal_unit_type, p_in->IO.nalubytes);
|
||||
|
||||
nalu_header_bytes = 1;
|
||||
if ((nal_unit_type == NALU_TYPE_PREFIX) || (nal_unit_type == NALU_TYPE_SLC_EXT)) {
|
||||
|
@@ -44,13 +44,13 @@ static MPP_RET manual_set_env(void)
|
||||
#if defined(_MSC_VER)
|
||||
mpp_env_set_u32("h264d_log_help", 1 );
|
||||
mpp_env_set_u32("h264d_log_show", 1 );
|
||||
mpp_env_set_u32("h264d_log_ctrl", 0x803B );
|
||||
mpp_env_set_u32("h264d_log_ctrl", 0x800B );
|
||||
mpp_env_set_u32("h264d_log_level", 5 );
|
||||
mpp_env_set_u32("h264d_log_decframe", 0 );
|
||||
mpp_env_set_u32("h264d_log_begframe", 0 );
|
||||
mpp_env_set_u32("h264d_log_endframe", 0 );
|
||||
mpp_env_set_u32("h264d_log_yuv", 0 );
|
||||
mpp_env_set_u32("h264d_chg_org", 1 ); //!< 0:VDPU 1: RKVDEC
|
||||
mpp_env_set_u32("h264d_chg_org", 0 ); //!< 0:VDPU 1: RKVDEC
|
||||
mpp_env_set_str("h264d_log_outpath", "F:/h264_log/allegro_dat" );
|
||||
mpp_env_set_str("h264d_log_cmppath", "F:/h264_log_driver/trunk_dat" );
|
||||
#endif
|
||||
@@ -106,11 +106,11 @@ static MPP_RET decoder_init(MppDec *pApi)
|
||||
hal_cfg.coding = pApi->coding;
|
||||
hal_cfg.work_mode = HAL_MODE_LIBVPU;
|
||||
mpp_env_get_u32("h264d_chg_org", &hal_device_id, 0);
|
||||
//if (hal_device_id == 1) {
|
||||
//if (hal_device_id == 1) {
|
||||
hal_cfg.device_id = HAL_RKVDEC;
|
||||
//} else {
|
||||
//} else {
|
||||
// hal_cfg.device_id = HAL_VDPU;
|
||||
//}
|
||||
//}
|
||||
hal_cfg.frame_slots = pApi->frame_slots;
|
||||
hal_cfg.packet_slots = pApi->packet_slots;
|
||||
hal_cfg.task_count = parser_cfg.task_count;
|
||||
@@ -135,7 +135,8 @@ int main(int argc, char **argv)
|
||||
MppPacket pkt = NULL;
|
||||
MppFrame out_frame = NULL;
|
||||
RK_U32 out_yuv_flag = 0;
|
||||
MppBuffer dec_pkt_buf, dec_pic_buf;
|
||||
MppBuffer dec_pkt_buf = NULL;
|
||||
MppBuffer dec_pic_buf = NULL;
|
||||
MppBufferGroup mFrameGroup = NULL;
|
||||
MppBufferGroup mStreamGroup = NULL;
|
||||
|
||||
@@ -162,9 +163,9 @@ int main(int argc, char **argv)
|
||||
//if (g_debug_file0 == NULL) {
|
||||
// g_debug_file0 = fopen("rk_debugfile_view0.txt", "wb");
|
||||
//}
|
||||
//if (g_debug_file1 == NULL) {
|
||||
// g_debug_file1 = fopen("rk_debugfile_view1.txt", "wb");
|
||||
//}
|
||||
//if (g_debug_file1 == NULL) {
|
||||
// g_debug_file1 = fopen("rk_debugfile_view1.txt", "wb");
|
||||
//}
|
||||
|
||||
MEM_CHECK(ret, pIn && pApi && task);
|
||||
mpp_log("== test start == \n");
|
||||
@@ -178,7 +179,7 @@ int main(int argc, char **argv)
|
||||
|
||||
//!< init decoder
|
||||
FUN_CHECK(ret = decoder_init(pApi));
|
||||
|
||||
|
||||
//!< initial task
|
||||
memset(task, 0, sizeof(HalTaskInfo));
|
||||
memset(task->dec.refer, -1, sizeof(task->dec.refer));
|
||||
@@ -187,12 +188,16 @@ int main(int argc, char **argv)
|
||||
do {
|
||||
//!< get one packet
|
||||
if (pkt == NULL) {
|
||||
if (pIn->is_eof || (pIn->iFrmdecoded >= pIn->iDecFrmNum)) {
|
||||
if (pIn->is_eof ||
|
||||
(pIn->iDecFrmNum && (pIn->iFrmdecoded >= pIn->iDecFrmNum))) {
|
||||
mpp_packet_init(&pkt, NULL, 0);
|
||||
mpp_packet_set_eos(pkt);
|
||||
//FPRINT(g_debug_file0, "[READ_PKT]pIn->iFrmdecoded=%d, strm_pkt_len=%d, is_eof=%d \n", pIn->iFrmdecoded, 0, 1);
|
||||
} else {
|
||||
FUN_CHECK(ret = h264d_read_one_frame(pIn));
|
||||
mpp_packet_init(&pkt, pIn->strm.pbuf, pIn->strm.strmbytes);
|
||||
//FPRINT(g_debug_file0, "[READ_PKT]pIn->iFrmdecoded=%d, strm_pkt_len=%d, is_eof=%d \n",
|
||||
//pIn->iFrmdecoded, pIn->strm.strmbytes, 0);
|
||||
}
|
||||
mpp_log("---- decoder, read_one_frame Frame_no = %d \n", pIn->iFrmdecoded++);
|
||||
}
|
||||
@@ -247,6 +252,7 @@ int main(int argc, char **argv)
|
||||
}
|
||||
mpp_buf_slot_clr_flag(pApi->packet_slots, task->dec.input, SLOT_HAL_INPUT);
|
||||
mpp_buf_slot_clr_flag(pApi->frame_slots, task->dec.output, SLOT_HAL_OUTPUT);
|
||||
|
||||
//!< write frame out
|
||||
mpp_env_get_u32("h264d_log_yuv", &out_yuv_flag, 0);
|
||||
mpp_log("h264d_log_yuv=%d", out_yuv_flag);
|
||||
@@ -262,7 +268,6 @@ int main(int argc, char **argv)
|
||||
framebuf = mpp_frame_get_buffer(out_frame);
|
||||
ptr = mpp_buffer_get_ptr(framebuf);
|
||||
if (out_yuv_flag && pIn->fp_yuv_data) {
|
||||
|
||||
fwrite(ptr, 1, stride_w * stride_h * 3 / 2, pIn->fp_yuv_data);
|
||||
fflush(pIn->fp_yuv_data);
|
||||
}
|
||||
@@ -282,29 +287,26 @@ int main(int argc, char **argv)
|
||||
memset(task->dec.refer, -1, sizeof(task->dec.refer));
|
||||
task->dec.input = -1;
|
||||
}
|
||||
if (end_of_flag) {
|
||||
break;
|
||||
}
|
||||
} while (!pIn->iDecFrmNum || (pIn->iFrmdecoded < pIn->iDecFrmNum + 2));
|
||||
} while (!end_of_flag);
|
||||
|
||||
//FPRINT(g_debug_file1, "[FLUSH] flush begin \n");
|
||||
//!< flush dpb and send to display
|
||||
FUN_CHECK(ret = mpp_dec_flush(pApi));
|
||||
while (MPP_OK == mpp_buf_slot_dequeue(pApi->frame_slots, &frame_slot_idx, QUEUE_DISPLAY)) {
|
||||
mpp_log("get_display for index = %d", frame_slot_idx);
|
||||
mpp_buf_slot_get_prop(pApi->frame_slots, frame_slot_idx, SLOT_FRAME, &out_frame);
|
||||
if (out_frame) {
|
||||
mpp_frame_deinit(&out_frame);
|
||||
}
|
||||
mpp_buf_slot_clr_flag(pApi->frame_slots, frame_slot_idx, SLOT_QUEUE_USE);
|
||||
}
|
||||
//!< flush dpb and send to display
|
||||
FUN_CHECK(ret = mpp_dec_flush(pApi));
|
||||
while (MPP_OK == mpp_buf_slot_dequeue(pApi->frame_slots, &frame_slot_idx, QUEUE_DISPLAY)) {
|
||||
mpp_log("get_display for index = %d", frame_slot_idx);
|
||||
mpp_buf_slot_get_prop(pApi->frame_slots, frame_slot_idx, SLOT_FRAME, &out_frame);
|
||||
if (out_frame) {
|
||||
mpp_frame_deinit(&out_frame);
|
||||
}
|
||||
mpp_buf_slot_clr_flag(pApi->frame_slots, frame_slot_idx, SLOT_QUEUE_USE);
|
||||
}
|
||||
|
||||
//FPRINT(g_debug_file1, "+++++++ all test return +++++++ \n");
|
||||
ret = MPP_OK;
|
||||
__FAILED:
|
||||
decoder_deinit(pApi);
|
||||
h264d_free_frame_buffer(pIn);
|
||||
h264d_write_fpga_data(pIn); //!< for fpga debug
|
||||
//h264d_write_fpga_data(pIn); //!< for fpga debug
|
||||
h264d_close_files(pIn);
|
||||
MPP_FREE(pIn);
|
||||
MPP_FREE(pApi);
|
||||
|
Reference in New Issue
Block a user