[vpu_api] add VPU_API_GET_VPUMEM_USED_COUNT

[h264d]  remove dpb_info_old; check_dpb,and add h264d_reset
[mpp_buf_slot]  add get_used_slot_count

git-svn-id: https://10.10.10.66:8443/svn/MediaProcessPlatform/trunk/mpp@600 6e48237b-75ef-9749-8fc9-41990f28c85a
This commit is contained in:
DingWei
2016-04-05 03:10:03 +00:00
parent 653a6b5aa4
commit ecf49af775
18 changed files with 117 additions and 71 deletions

View File

@@ -165,7 +165,7 @@ void mpp_frame_set_ver_stride(MppFrame frame, RK_U32 ver_stride);
RK_U32 mpp_frame_get_mode(const MppFrame frame); RK_U32 mpp_frame_get_mode(const MppFrame frame);
void mpp_frame_set_mode(MppFrame frame, RK_U32 mode); void mpp_frame_set_mode(MppFrame frame, RK_U32 mode);
RK_U32 mpp_frame_get_discard(const MppFrame frame); RK_U32 mpp_frame_get_discard(const MppFrame frame);
void mpp_frame_set_discard(MppFrame frame, RK_U32 display); void mpp_frame_set_discard(MppFrame frame, RK_U32 discard);
RK_U32 mpp_frame_get_viewid(const MppFrame frame); RK_U32 mpp_frame_get_viewid(const MppFrame frame);
void mpp_frame_set_viewid(MppFrame frame, RK_U32 viewid); void mpp_frame_set_viewid(MppFrame frame, RK_U32 viewid);
RK_U32 mpp_frame_get_poc(const MppFrame frame); RK_U32 mpp_frame_get_poc(const MppFrame frame);

View File

@@ -73,6 +73,7 @@ typedef enum {
MPP_CODEC_SET_INFO_CHANGE_READY, MPP_CODEC_SET_INFO_CHANGE_READY,
MPP_CODEC_SET_FRAME_INFO, MPP_CODEC_SET_FRAME_INFO,
MPP_CODEC_GET_FRAME_INFO, MPP_CODEC_GET_FRAME_INFO,
MPP_CODEC_GET_VPUMEM_USED_COUNT,
MPP_DEC_CMD_BASE = 0x40000, MPP_DEC_CMD_BASE = 0x40000,
MPP_DEC_SET_EXT_BUF_GROUP, /* IMPORTANT: set external buffer group to mpp decoder */ MPP_DEC_SET_EXT_BUF_GROUP, /* IMPORTANT: set external buffer group to mpp decoder */

View File

@@ -57,6 +57,7 @@ typedef enum VPU_API_CMD {
VPU_API_SET_INFO_CHANGE, VPU_API_SET_INFO_CHANGE,
VPU_API_USE_FAST_MODE, VPU_API_USE_FAST_MODE,
VPU_API_DEC_GET_STREAM_COUNT, VPU_API_DEC_GET_STREAM_COUNT,
VPU_API_GET_VPUMEM_USED_COUNT,
} VPU_API_CMD; } VPU_API_CMD;
typedef struct { typedef struct {

View File

@@ -15,6 +15,18 @@ add_subdirectory(dec)
add_subdirectory(enc) add_subdirectory(enc)
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/dec/avs_impl/")
add_subdirectory(dec/avs_impl)
target_link_libraries(mpp_codec
codec_h264d
codec_vp9d
codec_h265d
codec_avsd
codec_avsd_impl
codec_dummy_enc
codec_dummy_dec
mpp)
else()
target_link_libraries(mpp_codec target_link_libraries(mpp_codec
codec_h264d codec_h264d
codec_vp9d codec_vp9d
@@ -23,4 +35,5 @@ target_link_libraries(mpp_codec
codec_dummy_enc codec_dummy_enc
codec_dummy_dec codec_dummy_dec
mpp) mpp)
endif()

View File

@@ -8,10 +8,6 @@ add_subdirectory(h265)
add_subdirectory(vp9) add_subdirectory(vp9)
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/avs_impl/")
add_subdirectory(avs_impl)
endif()
add_subdirectory(avs) add_subdirectory(avs)

View File

@@ -25,11 +25,7 @@ add_library(codec_avsd STATIC
${AVSD_HDR} ${AVSD_HDR}
${AVSD_SRC} ${AVSD_SRC}
) )
if(EXISTS codec_avsd_impl)
target_link_libraries(codec_avsd codec_avsd codec_avsd_impl)
else()
target_link_libraries(codec_avsd mpp)
endif()
target_link_libraries(codec_avsd mpp)
set_target_properties(codec_avsd PROPERTIES FOLDER "mpp/codec") set_target_properties(codec_avsd PROPERTIES FOLDER "mpp/codec")

View File

@@ -350,8 +350,6 @@ static MPP_RET init_dec_ctx(H264_DecCtx_t *p_Dec)
MEM_CHECK(ret, p_Dec->mem); MEM_CHECK(ret, p_Dec->mem);
p_Dec->dpb_mark = p_Dec->mem->dpb_mark; //!< for write out, MAX_DPB_SIZE 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_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_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[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] p_Dec->refpic_info_b[1] = p_Dec->mem->refpic_info_b[1]; //!< [2][32]
@@ -405,8 +403,6 @@ static void flush_dpb_buf_slot(H264_DecCtx_t *p_Dec)
} }
} }
/*! /*!
*********************************************************************** ***********************************************************************
* \brief * \brief
@@ -548,11 +544,7 @@ MPP_RET h264d_reset(void *decoder)
p_Dec->dxva_ctx->strm_offset = 0; p_Dec->dxva_ctx->strm_offset = 0;
p_Dec->dxva_ctx->slice_count = 0; p_Dec->dxva_ctx->slice_count = 0;
memset(p_Dec->dpb_old[0], 0, MAX_DPB_SIZE * sizeof(H264_DpbInfo_t)); FunctionOut(p_Dec->logctx.parr[RUN_PARSE]);
memset(p_Dec->dpb_old[1], 0, MAX_DPB_SIZE * sizeof(H264_DpbInfo_t));
FunctionOut(p_Dec->logctx.parr[RUN_PARSE]);
__RETURN: __RETURN:
return ret = MPP_OK; return ret = MPP_OK;
__FAILED: __FAILED:
@@ -773,7 +765,7 @@ MPP_RET h264d_callback(void *decoder, void *errinfo)
RK_U32 *p_regs = NULL; RK_U32 *p_regs = NULL;
RK_U32 out_slot_idx = 0; RK_U32 out_slot_idx = 0;
RK_U32 dpb_err_flag = 0; RK_U32 dpb_err_flag = 0;
RK_U32 used_for_ref_flag = 0; RK_U32 ref_flag = 0;
H264_DecCtx_t *p_Dec = (H264_DecCtx_t *)decoder; H264_DecCtx_t *p_Dec = (H264_DecCtx_t *)decoder;
INP_CHECK(ret, !decoder); INP_CHECK(ret, !decoder);
@@ -782,16 +774,16 @@ MPP_RET h264d_callback(void *decoder, void *errinfo)
p_regs = (RK_U32*)errinfo; p_regs = (RK_U32*)errinfo;
out_slot_idx = p_regs[78]; out_slot_idx = p_regs[78];
dpb_err_flag = p_regs[79]; dpb_err_flag = p_regs[79];
used_for_ref_flag = p_regs[80]; ref_flag = p_regs[80];
mpp_buf_slot_get_prop(p_Dec->frame_slots, out_slot_idx, SLOT_FRAME_PTR, &mframe); mpp_buf_slot_get_prop(p_Dec->frame_slots, out_slot_idx, SLOT_FRAME_PTR, &mframe);
if (used_for_ref_flag) { if (ref_flag) {
mpp_frame_set_errinfo(mframe, VPU_FRAME_ERR_UNKNOW); mpp_frame_set_errinfo(mframe, VPU_FRAME_ERR_UNKNOW);
} else { } else {
mpp_frame_set_discard(mframe, VPU_FRAME_ERR_UNKNOW); mpp_frame_set_discard(mframe, VPU_FRAME_ERR_UNKNOW);
} }
H264D_DBG(H264D_DBG_CALLBACK, "g_frame_no=%d, out_slot_idx=%d, swreg[01]=%08x, swreg[45]=%08x, dpb_err=%d, used_for_ref=%d", H264D_DBG(H264D_DBG_CALLBACK, "[CALLBACK] g_frame_no=%d, out_slot_idx=%d, swreg[01]=%08x, swreg[45]=%08x, dpb_err=%d, ref_flag=%d, fd=0x%x",
p_Dec->p_Vid->g_framecnt, out_slot_idx, p_regs[1], p_regs[45], dpb_err_flag, used_for_ref_flag); p_Dec->p_Vid->g_framecnt, out_slot_idx, p_regs[1], p_regs[45], dpb_err_flag, ref_flag, mpp_buffer_get_fd(mpp_frame_get_buffer(mframe)));
__RETURN: __RETURN:
FunctionOut(p_Dec->logctx.parr[RUN_PARSE]); FunctionOut(p_Dec->logctx.parr[RUN_PARSE]);

View File

@@ -918,8 +918,10 @@ static void write_picture(H264_StorePic_t *p, H264dVideoCtx_t *p_Vid)
H264_DpbMark_t *p_mark = NULL; H264_DpbMark_t *p_mark = NULL;
p_mark = p->mem_mark; p_mark = p->mem_mark;
H264D_DBG(H264D_DBG_DPB_FREE, "[DPB_free] write_picture, type=%d, structure=%d, poc=%d, out_flag=%d", H264D_DBG(H264D_DBG_DPB_FREE, "[write_picture] type=%d", p->mem_malloc_type);
p->mem_malloc_type, p->structure, p->poc, p_mark->out_flag); H264D_DBG(H264D_DBG_DPB_FREE, "[write_picture] poc=%d", p->poc);
H264D_DBG(H264D_DBG_DPB_FREE, "[write_picture] p_mark=%p", p_mark);
H264D_DBG(H264D_DBG_DPB_FREE, "[write_picture] In, out_flag=%d", p_mark->out_flag);
if ((p->mem_malloc_type == Mem_Malloc if ((p->mem_malloc_type == Mem_Malloc
|| p->mem_malloc_type == Mem_TopOnly || p->mem_malloc_type == Mem_TopOnly
|| p->mem_malloc_type == Mem_BotOnly) || p->mem_malloc_type == Mem_BotOnly)
@@ -969,8 +971,7 @@ static void write_picture(H264_StorePic_t *p, H264dVideoCtx_t *p_Vid)
H264D_DBG(H264D_DBG_DPB_DISPLAY, "[DPB_dispaly] layer_id=%d, pic_num=%d, poc=%d, last_poc=%d, slice_type=%d(idr=%d), slot_idx=%d(%p), pts=%lld, g_framecnt=%d \n", H264D_DBG(H264D_DBG_DPB_DISPLAY, "[DPB_dispaly] layer_id=%d, pic_num=%d, poc=%d, last_poc=%d, slice_type=%d(idr=%d), slot_idx=%d(%p), pts=%lld, g_framecnt=%d \n",
p->layer_id, p->pic_num, p->poc, p_Vid->last_outputpoc[p->layer_id], p->slice_type, p->idr_flag, p_mark->slot_idx, mbuffer, mpp_frame_get_pts(mframe), p_Vid->g_framecnt); p->layer_id, p->pic_num, p->poc, p_Vid->last_outputpoc[p->layer_id], p->slice_type, p->idr_flag, p_mark->slot_idx, mbuffer, mpp_frame_get_pts(mframe), p_Vid->g_framecnt);
} }
H264D_DBG(H264D_DBG_DPB_FREE, "[DPB_free] after, out_flag=%d", p_mark->out_flag); H264D_DBG(H264D_DBG_DPB_FREE, "[write_picture] Out, out_flag=%d", p_mark->out_flag);
} }
} }
@@ -1685,7 +1686,7 @@ void free_storable_picture(H264_DecCtx_t *p_Dec, H264_StorePic_t *p)
} }
if (p->mem_malloc_type == Mem_BotOnly) { if (p->mem_malloc_type == Mem_BotOnly) {
free_dpb_mark(p_Dec, p->mem_mark, BOTTOM_FIELD); free_dpb_mark(p_Dec, p->mem_mark, BOTTOM_FIELD);
} }
MPP_FREE(p); MPP_FREE(p);
} }
} }

View File

@@ -1065,7 +1065,7 @@ typedef struct h264_dec_ctx_t {
struct h264d_mem_t *mem; struct h264d_mem_t *mem;
struct h264_dpb_mark_t *dpb_mark; //!< for write out, MAX_DPB_SIZE 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_info; //!< 16
struct h264_dpb_info_t *dpb_old[2]; //!< 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_p; //!< 32
struct h264_refpic_info_t *refpic_info_b[2]; //!< [2][32] struct h264_refpic_info_t *refpic_info_b[2]; //!< [2][32]
struct h264d_dxva_ctx_t *dxva_ctx; struct h264d_dxva_ctx_t *dxva_ctx;

View File

@@ -417,10 +417,6 @@ static void dpb_mark_malloc(H264dVideoCtx_t *p_Vid, H264_StorePic_t *dec_pic)
mpp_buf_slot_set_prop(p_Dec->frame_slots, cur_mark->slot_idx, SLOT_FRAME, mframe); mpp_buf_slot_set_prop(p_Dec->frame_slots, cur_mark->slot_idx, SLOT_FRAME, mframe);
mpp_frame_deinit(&mframe); mpp_frame_deinit(&mframe);
mpp_buf_slot_get_prop(p_Dec->frame_slots, cur_mark->slot_idx, SLOT_FRAME_PTR, &cur_mark->mframe); mpp_buf_slot_get_prop(p_Dec->frame_slots, cur_mark->slot_idx, SLOT_FRAME_PTR, &cur_mark->mframe);
}
{
MppBuffer mbuffer = NULL;
mpp_buf_slot_get_prop(p_Dec->frame_slots, cur_mark->slot_idx, SLOT_BUFFER, &mbuffer);
H264D_DBG(H264D_DBG_DPB_MALLIC, "[DPB_malloc] g_framecnt=%d, mark_idx=%d, slot_idx=%d, slice_type=%d, lay_id=%d, pts=%lld \n", H264D_DBG(H264D_DBG_DPB_MALLIC, "[DPB_malloc] g_framecnt=%d, mark_idx=%d, slot_idx=%d, slice_type=%d, lay_id=%d, pts=%lld \n",
p_Vid->g_framecnt, cur_mark->mark_idx, cur_mark->slot_idx, dec_pic->slice_type, layer_id, p_Vid->p_Inp->in_pts); p_Vid->g_framecnt, cur_mark->mark_idx, cur_mark->slot_idx, dec_pic->slice_type, layer_id, p_Vid->p_Inp->in_pts);
} }
@@ -1517,14 +1513,14 @@ static MPP_RET prepare_init_dpb_info(H264_SLICE_t *currSlice)
H264_DpbBuf_t *p_Dpb = currSlice->p_Dpb; H264_DpbBuf_t *p_Dpb = currSlice->p_Dpb;
H264_DecCtx_t *p_Dec = currSlice->p_Dec; H264_DecCtx_t *p_Dec = currSlice->p_Dec;
memset(p_Dec->dpb_info, 0, MAX_DPB_SIZE * sizeof(H264_DpbInfo_t)); //!< reset parameters
memset(&p_Dec->in_task->refer, -1, sizeof(p_Dec->in_task->refer)); for (i = 0; i < MAX_DPB_SIZE; i++) {
reset_dpb_info(&p_Dec->dpb_info[i]);
}
if (currSlice->idr_flag && (currSlice->layer_id == 0)) { // idr_flag==1 && layer_id==0 if (currSlice->idr_flag && (currSlice->layer_id == 0)) { // 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; goto __RETURN;
} }
//!<---- reference //!< reference
#if 1 #if 1
for (i = 0, j = 0; j < p_Dpb->ref_frames_in_buffer; i++, j++) { for (i = 0, j = 0; j < p_Dpb->ref_frames_in_buffer; i++, j++) {
if (p_Dpb->fs_ref[j]->is_used == 3) { if (p_Dpb->fs_ref[j]->is_used == 3) {
@@ -1699,11 +1695,6 @@ static MPP_RET prepare_init_dpb_info(H264_SLICE_t *currSlice)
p_Dec->dpb_info[i].is_used = p_Dpb->fs_ilref[j]->is_used; p_Dec->dpb_info[i].is_used = p_Dpb->fs_ilref[j]->is_used;
} }
#endif #endif
//!< reset left parameters
for (; i < MAX_DPB_SIZE; i++) {
reset_dpb_info(&p_Dec->dpb_info[i]);
}
//adjust_input(currSlice);
__RETURN: __RETURN:
return MPP_OK; return MPP_OK;
} }
@@ -1847,10 +1838,12 @@ static MPP_RET check_refer_dpb_buf_slots(H264_SLICE_t *currSlice)
{ {
RK_U32 i = 0; RK_U32 i = 0;
RK_S32 slot_idx = 0; RK_S32 slot_idx = 0;
RK_U32 dpb_used = 0;
H264_DecCtx_t *p_Dec = NULL; H264_DecCtx_t *p_Dec = NULL;
H264_DpbMark_t *p_mark = NULL; H264_DpbMark_t *p_mark = NULL;
p_Dec = currSlice->p_Dec; p_Dec = currSlice->p_Dec;
memset(&p_Dec->in_task->refer, -1, sizeof(p_Dec->in_task->refer));
//!< set buf slot flag //!< set buf slot flag
for (i = 0; i < MAX_DPB_SIZE; i++) { for (i = 0; i < MAX_DPB_SIZE; i++) {
if ((NULL != p_Dec->dpb_info[i].refpic) && (p_Dec->dpb_info[i].slot_index >= 0)) { if ((NULL != p_Dec->dpb_info[i].refpic) && (p_Dec->dpb_info[i].slot_index >= 0)) {
@@ -1860,25 +1853,33 @@ static MPP_RET check_refer_dpb_buf_slots(H264_SLICE_t *currSlice)
} }
} }
//!< dpb info //!< dpb info
slot_idx = currSlice->p_Vid->dec_pic->mem_mark->slot_idx; H264D_DBG(H264D_DBG_DPB_INFO, "[DPB_INFO] cur_slot_idx=%d", p_Dec->in_task->output);
ASSERT(slot_idx >= 0); for (i = 0; i < MAX_DPB_SIZE; i++) {
H264D_DBG(H264D_DBG_DPB_INFO, "---- DPB INFO ----"); slot_idx = p_Dec->in_task->refer[i];
H264D_DBG(H264D_DBG_DPB_INFO, "cur_slot_idx=%d", slot_idx); if (slot_idx >= 0) {
for (i = 0; i < MAX_DPB_SIZE; i++) { H264D_DBG(H264D_DBG_DPB_INFO, "[DPB_INFO] ref_slot_idx[%d]=%d", i, slot_idx);
slot_idx = p_Dec->dpb_info[i].slot_index; }
if (slot_idx >= 0) { }
H264D_DBG(H264D_DBG_DPB_INFO, "i=%d, ref_slot_idx=%d", i, slot_idx);
}
}
//!< mark info //!< mark info
H264D_DBG(H264D_DBG_DPB_INFO, "---- MARK INFO ----");
for (i = 0; i < MAX_MARK_SIZE; i++) { for (i = 0; i < MAX_MARK_SIZE; i++) {
RK_S32 fd = 0;
p_mark = &p_Dec->dpb_mark[i]; p_mark = &p_Dec->dpb_mark[i];
if (p_mark->out_flag && (p_mark->slot_idx >= 0)) { if (p_mark->out_flag && (p_mark->slot_idx >= 0)) {
H264D_DBG(H264D_DBG_SLOT_FLUSH, "[DPB_BUF_FLUSH] slot_idx=%d, top_used=%d, bot_used=%d", dpb_used++;
p_mark->slot_idx, p_mark->top_used, p_mark->bot_used); if (p_mark->slot_idx != p_Dec->in_task->output) {
fd = mpp_buffer_get_fd(mpp_frame_get_buffer(p_mark->mframe));
} else {
fd = 0xFF;
}
H264D_DBG(H264D_DBG_SLOT_FLUSH, "[DPB_MARK_INFO] slot_idx=%d, top_used=%d, bot_used=%d, fd=0x%02x",
p_mark->slot_idx, p_mark->top_used, p_mark->bot_used, fd);
} }
} }
if (dpb_used > currSlice->p_Dpb->size + 2) {
h264d_reset((void *)p_Dec);
return MPP_NOK;
}
return MPP_OK; return MPP_OK;
} }
@@ -1939,7 +1940,7 @@ MPP_RET init_picture(H264_SLICE_t *currSlice)
prepare_init_dpb_info(currSlice); prepare_init_dpb_info(currSlice);
prepare_init_ref_info(currSlice); prepare_init_ref_info(currSlice);
check_refer_dpb_buf_slots(currSlice); FUN_CHECK(ret = check_refer_dpb_buf_slots(currSlice));
check_refer_picture_lists(currSlice); check_refer_picture_lists(currSlice);
prepare_init_scanlist(currSlice); prepare_init_scanlist(currSlice);

View File

@@ -129,7 +129,7 @@ MPP_RET mpp_buf_slot_setup(MppBufSlots slots, RK_S32 count);
RK_U32 mpp_buf_slot_is_changed(MppBufSlots slots); RK_U32 mpp_buf_slot_is_changed(MppBufSlots slots);
MPP_RET mpp_buf_slot_ready(MppBufSlots slots); MPP_RET mpp_buf_slot_ready(MppBufSlots slots);
size_t mpp_buf_slot_get_size(MppBufSlots slots); size_t mpp_buf_slot_get_size(MppBufSlots slots);
RK_S32 mpp_buf_slot_get_used_size(MppBufSlots slots);
/* /*
* called by parser * called by parser
* *

View File

@@ -34,6 +34,7 @@
#define BUF_SLOT_DBG_OPS_RUNTIME (0x00000010) #define BUF_SLOT_DBG_OPS_RUNTIME (0x00000010)
#define BUF_SLOT_DBG_BUFFER (0x00000100) #define BUF_SLOT_DBG_BUFFER (0x00000100)
#define BUF_SLOT_DBG_FRAME (0x00000200) #define BUF_SLOT_DBG_FRAME (0x00000200)
#define BUF_SLOT_DBG_BUF_UESD (0x00000400)
#define BUF_SLOT_DBG_OPS_HISTORY (0x10000000) #define BUF_SLOT_DBG_OPS_HISTORY (0x10000000)
#define buf_slot_dbg(flag, fmt, ...) _mpp_dbg(buf_slot_debug, flag, fmt, ## __VA_ARGS__) #define buf_slot_dbg(flag, fmt, ...) _mpp_dbg(buf_slot_debug, flag, fmt, ## __VA_ARGS__)
@@ -628,6 +629,26 @@ size_t mpp_buf_slot_get_size(MppBufSlots slots)
return impl->buf_size; return impl->buf_size;
} }
RK_S32 mpp_buf_slot_get_used_size(MppBufSlots slots)
{
if (NULL == slots) {
mpp_err_f("found NULL input\n");
return 0;
}
MppBufSlotsImpl *impl = (MppBufSlotsImpl *)slots;
AutoMutex auto_lock(impl->lock);
RK_S32 i;
RK_S32 used_size = 0;
MppBufSlotEntry *slot = impl->slots;
for (i = 0; i < impl->buf_count; i++, slot++) {
if (slot->status.on_used) {
buf_slot_dbg(BUF_SLOT_DBG_BUF_UESD, "[BUF_USED] buf_fd=%08x", mpp_buffer_get_fd(slot->buffer));
used_size++;
}
}
return used_size;
}
MPP_RET mpp_buf_slot_get_unused(MppBufSlots slots, RK_S32 *index) MPP_RET mpp_buf_slot_get_unused(MppBufSlots slots, RK_S32 *index)
{ {
if (NULL == slots || NULL == index) { if (NULL == slots || NULL == index) {
@@ -936,7 +957,6 @@ MPP_RET mpp_slots_get_prop(MppBufSlots slots, SlotsPropType type, void *val)
ret = MPP_NOK; ret = MPP_NOK;
} break; } break;
} }
if (MPP_OK == ret) { if (MPP_OK == ret) {
if (SLOTS_FRAME_INFO != type) if (SLOTS_FRAME_INFO != type)
*(RK_U32 *)val = value; *(RK_U32 *)val = value;

View File

@@ -864,6 +864,10 @@ MPP_RET mpp_dec_control(MppDec *dec, MpiCmd cmd, void *param)
mpp_slots_set_prop(dec->frame_slots, SLOTS_FRAME_INFO, frame); mpp_slots_set_prop(dec->frame_slots, SLOTS_FRAME_INFO, frame);
mpp_frame_deinit(&frame); mpp_frame_deinit(&frame);
} break; } break;
case MPP_CODEC_GET_VPUMEM_USED_COUNT: {
RK_S32 *p = (RK_S32 *)param;
*p = mpp_buf_slot_get_used_size(dec->frame_slots);
} break;
default : { default : {
} break; } break;
} }

View File

@@ -50,7 +50,7 @@
//!< hal marco //!< hal marco
#define H264D_DBG_GEN_REGS (0x01000000) #define H264D_DBG_GEN_REGS (0x01000000)
#define H264D_DBG_RET_REGS (0x02000000) #define H264D_DBG_RET_REGS (0x02000000)
#define H264D_DBG_DECOUT_INFO (0x04000000)
extern RK_U32 rkv_h264d_parse_debug; extern RK_U32 rkv_h264d_parse_debug;

View File

@@ -384,6 +384,8 @@ MPP_RET rkv_h264d_start(void *hal, HalTaskInfo *task)
rkv_h264d_hal_dump(p_hal, H264D_DBG_GEN_REGS); rkv_h264d_hal_dump(p_hal, H264D_DBG_GEN_REGS);
} }
} }
//!< current buffer slot fd
H264D_DBG(H264D_DBG_DECOUT_INFO, "[DECOUT_INFO] decout_fd=0x%02x", p_regs[7]);
#ifdef ANDROID #ifdef ANDROID
if (VPUClientSendReg(p_hal->vpu_socket, (RK_U32 *)p_regs, DEC_RKV_REGISTERS)) { if (VPUClientSendReg(p_hal->vpu_socket, (RK_U32 *)p_regs, DEC_RKV_REGISTERS)) {
ret = MPP_ERR_VPUHW; ret = MPP_ERR_VPUHW;

View File

@@ -146,10 +146,10 @@ RK_S32 VpuApi:: decode_getoutframe(DecoderOut_t *aDecOut)
return VPU_API_EOS_STREAM_REACHED; return VPU_API_EOS_STREAM_REACHED;
} }
if (MPP_OK == mpi->decode_get_frame(mpp_ctx, &mframe)) { if (MPP_OK == mpi->decode_get_frame(mpp_ctx, &mframe)) {
MppBuffer buf; MppBuffer buf = NULL;
RK_U64 pts; RK_U64 pts = 0;
RK_U32 fd; RK_U32 fd = 0;
void* ptr; void* ptr = NULL;
aDecOut->size = sizeof(VPU_FRAME); aDecOut->size = sizeof(VPU_FRAME);
vframe->DisplayWidth = mpp_frame_get_width(mframe); vframe->DisplayWidth = mpp_frame_get_width(mframe);
vframe->DisplayHeight = mpp_frame_get_height(mframe); vframe->DisplayHeight = mpp_frame_get_height(mframe);
@@ -158,10 +158,6 @@ RK_S32 VpuApi:: decode_getoutframe(DecoderOut_t *aDecOut)
vframe->ErrorInfo = mpp_frame_get_errinfo(mframe) | mpp_frame_get_discard(mframe); vframe->ErrorInfo = mpp_frame_get_errinfo(mframe) | mpp_frame_get_discard(mframe);
pts = mpp_frame_get_pts(mframe); pts = mpp_frame_get_pts(mframe);
aDecOut->timeUs = pts; aDecOut->timeUs = pts;
if (vpu_api_debug & VPU_API_DBG_OUTPUT) {
mpp_log("get one frame timeUs %lld, poc=%d, errinfo=%d, discard=%d, eos=%d", aDecOut->timeUs,
mpp_frame_get_poc(mframe), mpp_frame_get_errinfo(mframe), mpp_frame_get_discard(mframe), mpp_frame_get_eos(mframe));
}
vframe->ShowTime.TimeHigh = (RK_U32)(pts >> 32); vframe->ShowTime.TimeHigh = (RK_U32)(pts >> 32);
vframe->ShowTime.TimeLow = (RK_U32)pts; vframe->ShowTime.TimeLow = (RK_U32)pts;
buf = mpp_frame_get_buffer(mframe); buf = mpp_frame_get_buffer(mframe);
@@ -205,6 +201,10 @@ RK_S32 VpuApi:: decode_getoutframe(DecoderOut_t *aDecOut)
vframe->vpumem.size = vframe->FrameWidth * vframe->FrameHeight * 3 / 2; vframe->vpumem.size = vframe->FrameWidth * vframe->FrameHeight * 3 / 2;
vframe->vpumem.offset = (RK_U32*)buf; vframe->vpumem.offset = (RK_U32*)buf;
} }
if (vpu_api_debug & VPU_API_DBG_OUTPUT) {
mpp_log("get one frame timeUs %lld, fd=0x%x, poc=%d, errinfo=%d, discard=%d, eos=%d", aDecOut->timeUs, fd,
mpp_frame_get_poc(mframe), mpp_frame_get_errinfo(mframe), mpp_frame_get_discard(mframe), mpp_frame_get_eos(mframe));
}
if (mpp_frame_get_eos(mframe)) { if (mpp_frame_get_eos(mframe)) {
set_eos = 1; set_eos = 1;
if (buf == NULL) { if (buf == NULL) {
@@ -310,6 +310,10 @@ RK_S32 VpuApi::control(VpuCodecContext *ctx, VPU_API_CMD cmd, void *param)
mpicmd = MPP_DEC_GET_STREAM_COUNT; mpicmd = MPP_DEC_GET_STREAM_COUNT;
break; break;
} }
case VPU_API_GET_VPUMEM_USED_COUNT:{
mpicmd = MPP_CODEC_GET_VPUMEM_USED_COUNT;
break;
}
default: { default: {
break; break;
} }

View File

@@ -305,6 +305,15 @@ MPP_RET Mpp::control(MpiCmd cmd, MppParam param)
*((RK_S32 *)param) = mPackets->list_size(); *((RK_S32 *)param) = mPackets->list_size();
break; break;
} }
case MPP_CODEC_GET_VPUMEM_USED_COUNT: {
AutoMutex autoLock(mPackets->mutex());
if (mType == MPP_CTX_DEC) {
mpp_dec_control(mDec, cmd, param);
}
break;
}
default : { default : {
} break; } break;
} }

View File

@@ -105,8 +105,6 @@ __FAILED:
return ret; return ret;
} }
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
MPP_RET ret = MPP_ERR_UNKNOW; MPP_RET ret = MPP_ERR_UNKNOW;
@@ -145,4 +143,12 @@ __FAILED:
return ret; return ret;
} }
#else
int main(int argc, char **argv)
{
return avsd_test_main(argc, argv);
}
#endif #endif