[mpp_dec]: add hal callback to parser

[h265d]:fix h265 stream eos cause play end 

git-svn-id: https://10.10.10.66:8443/svn/MediaProcessPlatform/trunk/mpp@499 6e48237b-75ef-9749-8fc9-41990f28c85a
This commit is contained in:
ChenSiyong
2015-12-02 23:31:17 +00:00
parent 93248127ea
commit ba16ca1559
16 changed files with 112 additions and 13 deletions

View File

@@ -288,6 +288,12 @@ MPP_RET dummy_dec_parse(void *dec, HalDecTask *task)
return MPP_OK; return MPP_OK;
} }
MPP_RET dummy_dec_callback(void *dec, void *err_info)
{
(void)dec;
(void)err_info;
return MPP_OK;
}
const ParserApi dummy_dec_parser = { const ParserApi dummy_dec_parser = {
"dummy_dec_parser", "dummy_dec_parser",
MPP_VIDEO_CodingUnused, MPP_VIDEO_CodingUnused,
@@ -300,5 +306,6 @@ const ParserApi dummy_dec_parser = {
dummy_dec_reset, dummy_dec_reset,
dummy_dec_flush, dummy_dec_flush,
dummy_dec_control, dummy_dec_control,
dummy_dec_callback,
}; };

View File

@@ -783,6 +783,18 @@ __FAILED:
return ret; return ret;
} }
/*!
***********************************************************************
* \brief
* callback
***********************************************************************
*/
MPP_RET h264d_callback(void *decoder, void *err_info)
{
(void) decoder;
(void) err_info;
return MPP_OK;
}
/*! /*!
*********************************************************************** ***********************************************************************
* \brief * \brief
@@ -802,5 +814,6 @@ const ParserApi api_h264d_parser = {
h264d_reset, h264d_reset,
h264d_flush, h264d_flush,
h264d_control, h264d_control,
h264d_callback,
}; };

View File

@@ -38,7 +38,9 @@
#define START_CODE 0x000001 ///< start_code_prefix_one_3bytes #define START_CODE 0x000001 ///< start_code_prefix_one_3bytes
RK_U32 h265d_debug; RK_U32 h265d_debug;
//FILE *fp = NULL; #ifdef dump
FILE *fp = NULL;
#endif
//static RK_U32 start_write = 0, value = 0; //static RK_U32 start_write = 0, value = 0;
/** /**
@@ -180,6 +182,8 @@ RK_S32 h265d_split_init(void **sc)
return MPP_ERR_NOMEM; return MPP_ERR_NOMEM;
} }
} }
s->buffer = mpp_malloc(RK_U8, MAX_FRAME_SIZE);
s->buffer_size = MAX_FRAME_SIZE;
s->fetch_timestamp = 1; s->fetch_timestamp = 1;
return MPP_OK; return MPP_OK;
} }
@@ -273,6 +277,9 @@ RK_S32 h265d_split_reset(void *sc)
RK_U8 *buf = NULL; RK_U8 *buf = NULL;
RK_U32 size = 0; RK_U32 size = 0;
SplitContext_t *s = (SplitContext_t*)sc; SplitContext_t *s = (SplitContext_t*)sc;
if (sc == NULL) {
return MPP_OK;
}
buf = s->buffer; buf = s->buffer;
size = s->buffer_size; size = s->buffer_size;
memset(s, 0, sizeof(SplitContext_t)); memset(s, 0, sizeof(SplitContext_t));
@@ -1521,9 +1528,9 @@ static RK_S32 split_nal_units(HEVCContext *s, RK_U8 *buf, RK_U32 length)
} }
if (s->nal_unit_type == NAL_EOB_NUT || /* if (s->nal_unit_type == NAL_EOB_NUT ||
s->nal_unit_type == NAL_EOS_NUT) s->nal_unit_type == NAL_EOS_NUT)
s->eos = 1; s->eos = 1;*/
buf += consumed; buf += consumed;
length -= consumed; length -= consumed;
@@ -1631,7 +1638,10 @@ MPP_RET h265d_prepare(void *ctx, MppPacket pkt, HalDecTask *task)
RK_S32 length = 0; RK_S32 length = 0;
//task->valid = 0; //task->valid = 0;
s->eos = sc->eos = mpp_packet_get_eos(pkt); s->eos = mpp_packet_get_eos(pkt);
if (sc != NULL) {
sc->eos = s->eos;
}
buf = (RK_U8 *)mpp_packet_get_pos(pkt); buf = (RK_U8 *)mpp_packet_get_pos(pkt);
pts = mpp_packet_get_pts(pkt); pts = mpp_packet_get_pts(pkt);
dts = mpp_packet_get_dts(pkt); dts = mpp_packet_get_dts(pkt);
@@ -1680,6 +1690,11 @@ MPP_RET h265d_prepare(void *ctx, MppPacket pkt, HalDecTask *task)
h265d_flush(ctx); h265d_flush(ctx);
} }
} }
#ifdef dump
if (s->nb_frame < 10 && fp != NULL) {
fwrite(buf, 1, length, fp);
}
#endif
ret = (MPP_RET)split_nal_units(s, buf, length); ret = (MPP_RET)split_nal_units(s, buf, length);
if (MPP_OK == ret) { if (MPP_OK == ret) {
@@ -1862,7 +1877,7 @@ MPP_RET h265d_init(void *ctx, ParserCfg *parser_cfg)
h265dctx->priv_data = s; h265dctx->priv_data = s;
} }
h265dctx->need_split = 1; h265dctx->need_split = parser_cfg->need_split;
if (sc == NULL && h265dctx->need_split) { if (sc == NULL && h265dctx->need_split) {
h265d_split_init((void**)&sc); h265d_split_init((void**)&sc);
@@ -1906,7 +1921,9 @@ MPP_RET h265d_init(void *ctx, ParserCfg *parser_cfg)
if (MPP_OK != mpp_packet_init(&s->input_packet, (void*)buf, size)) { if (MPP_OK != mpp_packet_init(&s->input_packet, (void*)buf, size)) {
return MPP_ERR_NOMEM; return MPP_ERR_NOMEM;
} }
// fp = fopen("dump1.bin", "wb+"); #ifdef dump
fp = fopen("/data/dump1.bin", "wb+");
#endif
return 0; return 0;
} }
@@ -1949,6 +1966,17 @@ MPP_RET h265d_control(void *ctx, RK_S32 cmd, void *param)
return MPP_OK; return MPP_OK;
} }
MPP_RET h265d_callback(void *ctx, void *err_info)
{
(void) err_info;
H265dContext_t *h265dctx = (H265dContext_t *)ctx;
HEVCContext *s = (HEVCContext *)h265dctx->priv_data;
s->max_ra = INT_MAX;
return MPP_OK;
}
const ParserApi api_h265d_parser = { const ParserApi api_h265d_parser = {
"h265d_parse", "h265d_parse",
@@ -1962,6 +1990,7 @@ const ParserApi api_h265d_parser = {
h265d_reset, h265d_reset,
h265d_flush, h265d_flush,
h265d_control, h265d_control,
h265d_callback,
}; };

View File

@@ -367,6 +367,7 @@ RK_S32 hevc_parser_test(ParserDemoCmdContext_t *cmd)
#endif #endif
parser_cfg.frame_slots = slots; parser_cfg.frame_slots = slots;
parser_cfg.packet_slots = packet_slots; parser_cfg.packet_slots = packet_slots;
parser_cfg.need_split = 1;
hal_cfg.frame_slots = slots; hal_cfg.frame_slots = slots;
hal_cfg.packet_slots = packet_slots; hal_cfg.packet_slots = packet_slots;
h265d_init(mpp_codex_ctx, &parser_cfg); h265d_init(mpp_codex_ctx, &parser_cfg);

View File

@@ -138,6 +138,21 @@ MPP_RET vp9d_parse(void *decoder, HalDecTask *in_task)
return ret = MPP_OK; return ret = MPP_OK;
} }
/*!
***********************************************************************
* \brief
* callback
***********************************************************************
*/
MPP_RET vp9d_callback(void *decoder, void *err_info)
{
MPP_RET ret = MPP_ERR_UNKNOW;
(void)decoder;
(void)err_info;
return ret = MPP_OK;
}
/*! /*!
*********************************************************************** ***********************************************************************
* \brief * \brief
@@ -157,5 +172,6 @@ const ParserApi api_vp9d_parser = {
vp9d_reset, vp9d_reset,
vp9d_flush, vp9d_flush,
vp9d_control, vp9d_control,
vp9d_callback,
}; };

View File

@@ -32,6 +32,7 @@ MPP_RET dummy_dec_flush (void *dec);
MPP_RET dummy_dec_control(void *dec, RK_S32 cmd_type, void *param); MPP_RET dummy_dec_control(void *dec, RK_S32 cmd_type, void *param);
MPP_RET dummy_dec_prepare(void *dec, MppPacket pkt, HalDecTask *task); MPP_RET dummy_dec_prepare(void *dec, MppPacket pkt, HalDecTask *task);
MPP_RET dummy_dec_parse (void *dec, HalDecTask *task); MPP_RET dummy_dec_parse (void *dec, HalDecTask *task);
MPP_RET dummy_dec_callback(void *dec, void *err_info);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@@ -42,6 +42,7 @@ MPP_RET h264d_flush (void *decoder);
MPP_RET h264d_control(void *decoder, RK_S32 cmd_type, void *param); MPP_RET h264d_control(void *decoder, RK_S32 cmd_type, void *param);
MPP_RET h264d_prepare(void *decoder, MppPacket pkt, HalDecTask *task); MPP_RET h264d_prepare(void *decoder, MppPacket pkt, HalDecTask *task);
MPP_RET h264d_parse (void *decoder, HalDecTask *task); MPP_RET h264d_parse (void *decoder, HalDecTask *task);
MPP_RET h264d_callback(void *decoder, void *err_info);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@@ -31,6 +31,7 @@ MPP_RET h265d_deinit(void *ctx);
MPP_RET h265d_flush(void *ctx); MPP_RET h265d_flush(void *ctx);
MPP_RET h265d_reset(void *ctx); MPP_RET h265d_reset(void *ctx);
MPP_RET h265d_control(void *ctx, RK_S32 cmd, void *param); MPP_RET h265d_control(void *ctx, RK_S32 cmd, void *param);
MPP_RET h265d_callback(void *ctx, void *err_info);
RK_S32 mpp_hevc_split_frame(void *sc, RK_S32 mpp_hevc_split_frame(void *sc,
const RK_U8 **poutbuf, RK_S32 *poutbuf_size, const RK_U8 **poutbuf, RK_S32 *poutbuf_size,
const RK_U8 *buf, RK_S32 buf_size); const RK_U8 *buf, RK_S32 buf_size);

View File

@@ -34,6 +34,7 @@ MPP_RET parser_parse(Parser prs, HalDecTask *task);
MPP_RET parser_reset(Parser prs); MPP_RET parser_reset(Parser prs);
MPP_RET parser_flush(Parser prs); MPP_RET parser_flush(Parser prs);
MPP_RET parser_control(Parser prs, RK_S32 cmd, void *para); MPP_RET parser_control(Parser prs, RK_S32 cmd, void *para);
MPP_RET hal_callback(void* prs, void *err_info);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@@ -36,6 +36,7 @@ typedef struct DecParserInitCfg_t {
// output // output
RK_S32 task_count; RK_S32 task_count;
RK_S32 need_split;
} ParserCfg; } ParserCfg;
@@ -70,6 +71,7 @@ typedef struct ParserApi_t {
MPP_RET (*reset)(void *ctx); MPP_RET (*reset)(void *ctx);
MPP_RET (*flush)(void *ctx); MPP_RET (*flush)(void *ctx);
MPP_RET (*control)(void *ctx, RK_S32 cmd, void *param); MPP_RET (*control)(void *ctx, RK_S32 cmd, void *param);
MPP_RET (*callback)(void *ctx, void *err_info);
} ParserApi; } ParserApi;

View File

@@ -34,6 +34,7 @@ MPP_RET vp9d_flush (void *decoder);
MPP_RET vp9d_control(void *decoder, RK_S32 cmd_type, void *param); MPP_RET vp9d_control(void *decoder, RK_S32 cmd_type, void *param);
MPP_RET vp9d_prepare(void *decoder, MppPacket pkt, HalDecTask *task); MPP_RET vp9d_prepare(void *decoder, MppPacket pkt, HalDecTask *task);
MPP_RET vp9d_parse (void *decoder, HalDecTask *task); MPP_RET vp9d_parse (void *decoder, HalDecTask *task);
MPP_RET vp9d_callback(void *decoder, void *err_info);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@@ -225,11 +225,6 @@ static MPP_RET try_proc_dec_task(Mpp *mpp, DecTask *task)
size_t stream_size = 0; size_t stream_size = 0;
HalDecTask *task_dec = &task->info.dec; HalDecTask *task_dec = &task->info.dec;
if (mpp->mFrameGroup) {
task->wait.dec_pic_buf = (mpp_buffer_group_unused(mpp->mFrameGroup) < 1);
if (task->wait.dec_pic_buf)
return MPP_NOK;
}
/* /*
* 1. get task handle from hal for parsing one frame * 1. get task handle from hal for parsing one frame
@@ -363,6 +358,11 @@ static MPP_RET try_proc_dec_task(Mpp *mpp, DecTask *task)
return MPP_NOK; return MPP_NOK;
} }
} }
if (mpp->mFrameGroup) {
task->wait.dec_pic_buf = (mpp_buffer_group_unused(mpp->mFrameGroup) < 1);
if (task->wait.dec_pic_buf)
return MPP_NOK;
}
if (task_dec->flags.eos && task_dec->valid == 0) { if (task_dec->flags.eos && task_dec->valid == 0) {
RK_S32 index; RK_S32 index;
@@ -708,6 +708,7 @@ MPP_RET mpp_dec_init(MppDec **dec, MppCodingType coding)
frame_slots, frame_slots,
packet_slots, packet_slots,
2, 2,
0,
}; };
ret = parser_init(&parser, &parser_cfg); ret = parser_init(&parser, &parser_cfg);
@@ -715,7 +716,7 @@ MPP_RET mpp_dec_init(MppDec **dec, MppCodingType coding)
mpp_err_f("could not init parser\n"); mpp_err_f("could not init parser\n");
break; break;
} }
HalIOInterruptCB cb = {.callBack = hal_callback, .opaque = parser};
// then init hal with task count from parser // then init hal with task count from parser
MppHalCfg hal_cfg = { MppHalCfg hal_cfg = {
MPP_CTX_DEC, MPP_CTX_DEC,
@@ -726,6 +727,7 @@ MPP_RET mpp_dec_init(MppDec **dec, MppCodingType coding)
packet_slots, packet_slots,
NULL, NULL,
parser_cfg.task_count, parser_cfg.task_count,
cb,
}; };
ret = mpp_hal_init(&hal, &hal_cfg); ret = mpp_hal_init(&hal, &hal_cfg);

View File

@@ -131,6 +131,17 @@ MPP_RET parser_parse(Parser prs, HalDecTask *task)
return p->api->parse(p->ctx, task); return p->api->parse(p->ctx, task);
} }
MPP_RET hal_callback(void *prs, void *err_info)
{
if (NULL == prs) {
mpp_err_f("found NULL input\n");
return MPP_ERR_NULL_PTR;
}
ParserImpl *p = (ParserImpl *)prs;
if (!p->api->callback)
return MPP_OK;
return p->api->callback(p->ctx, err_info);
}
MPP_RET parser_reset(Parser prs) MPP_RET parser_reset(Parser prs)
{ {
if (NULL == prs) { if (NULL == prs) {

View File

@@ -37,6 +37,10 @@ typedef enum MppHalHardType_e {
typedef void* MppHalCtx; typedef void* MppHalCtx;
typedef struct HalIOInterruptCB {
MPP_RET (*callBack)(void*, void*);
void *opaque;
} HalIOInterruptCB;
typedef struct MppHalCfg_t { typedef struct MppHalCfg_t {
// input // input
MppCtxType type; MppCtxType type;
@@ -49,6 +53,7 @@ typedef struct MppHalCfg_t {
// output // output
HalTaskGroup tasks; HalTaskGroup tasks;
RK_S32 task_count; RK_S32 task_count;
HalIOInterruptCB hal_int_cb;
} MppHalCfg; } MppHalCfg;
typedef struct MppHalApi_t { typedef struct MppHalApi_t {

View File

@@ -58,6 +58,7 @@ typedef struct h265d_reg_context {
MppBuffer pps_data; MppBuffer pps_data;
MppBuffer rps_data; MppBuffer rps_data;
void* hw_regs; void* hw_regs;
HalIOInterruptCB int_cb;
} h265d_reg_context_t; } h265d_reg_context_t;
typedef struct ScalingList { typedef struct ScalingList {
@@ -267,6 +268,7 @@ MPP_RET hal_h265d_init(void *hal, MppHalCfg *cfg)
} }
reg_cxt->slots = cfg->frame_slots; reg_cxt->slots = cfg->frame_slots;
reg_cxt->int_cb = cfg->hal_int_cb;
mpp_slots_set_prop(reg_cxt->slots, SLOTS_HOR_ALIGN, hevc_ver_align_256_odd); mpp_slots_set_prop(reg_cxt->slots, SLOTS_HOR_ALIGN, hevc_ver_align_256_odd);
mpp_slots_set_prop(reg_cxt->slots, SLOTS_VER_ALIGN, hevc_ver_align_8); mpp_slots_set_prop(reg_cxt->slots, SLOTS_VER_ALIGN, hevc_ver_align_8);
@@ -1455,10 +1457,15 @@ MPP_RET hal_h265d_wait(void *hal, HalTaskInfo *task)
#ifdef ANDROID #ifdef ANDROID
h265d_reg_context_t *reg_cxt = (h265d_reg_context_t *)hal; h265d_reg_context_t *reg_cxt = (h265d_reg_context_t *)hal;
RK_U8* p = (RK_U8*)reg_cxt->hw_regs; RK_U8* p = (RK_U8*)reg_cxt->hw_regs;
H265d_REGS_t *hw_regs = ( H265d_REGS_t *)reg_cxt->hw_regs;
RK_S32 i; RK_S32 i;
VPU_CMD_TYPE cmd; VPU_CMD_TYPE cmd;
RK_S32 len; RK_S32 len;
ret = VPUClientWaitResult(reg_cxt->vpu_socket, (RK_U32*)reg_cxt->hw_regs, 68, &cmd, &len); ret = VPUClientWaitResult(reg_cxt->vpu_socket, (RK_U32*)reg_cxt->hw_regs, 68, &cmd, &len);
if ((hw_regs->sw_interrupt.sw_dec_error_sta ||
hw_regs->sw_interrupt.sw_dec_empty_sta) && reg_cxt->int_cb.callBack) {
reg_cxt->int_cb.callBack(reg_cxt->int_cb.opaque, NULL);
}
for (i = 0; i < 68; i++) { for (i = 0; i < 68; i++) {
if (i == 1) { if (i == 1) {
h265h_dbg(H265H_DBG_REG, "RK_HEVC_DEC: regs[%02d]=%08X\n", i, *((RK_U32*)p)); h265h_dbg(H265H_DBG_REG, "RK_HEVC_DEC: regs[%02d]=%08X\n", i, *((RK_U32*)p));

View File

@@ -190,6 +190,7 @@ MPP_RET Mpp::get_frame(MppFrame *frame)
mThreadCodec->signal(); mThreadCodec->signal();
if (mOutputBlock) if (mOutputBlock)
mFrames->wait(); mFrames->wait();
usleep(1000);
} }
if (mFrames->list_size()) { if (mFrames->list_size()) {