From 9287e7813195264e38ee1a61716ff3ce9ecbcc11 Mon Sep 17 00:00:00 2001 From: ChenSiyong Date: Tue, 22 Dec 2015 02:00:33 +0000 Subject: [PATCH] [mppdec] add a notify call back interface for parser [h265d]: notify eos to mpp_dec when no slot frame can used git-svn-id: https://10.10.10.66:8443/svn/MediaProcessPlatform/trunk/mpp@520 6e48237b-75ef-9749-8fc9-41990f28c85a --- mpp/codec/dec/h265/h265d_parser.c | 10 ++++++++-- mpp/codec/dec/h265/h265d_parser.h | 1 + mpp/codec/inc/mpp_dec.h | 2 ++ mpp/codec/inc/parser_api.h | 1 + mpp/codec/mpp_dec.cpp | 18 ++++++++++++++++-- mpp/hal/inc/hal_task.h | 6 ++++++ mpp/hal/inc/mpp_hal.h | 7 ++----- mpp/hal/rkdec/h265d/hal_h265d_reg.c | 4 ++-- mpp/mpp.cpp | 2 +- 9 files changed, 39 insertions(+), 12 deletions(-) diff --git a/mpp/codec/dec/h265/h265d_parser.c b/mpp/codec/dec/h265/h265d_parser.c index f66444ca..49b37c73 100644 --- a/mpp/codec/dec/h265/h265d_parser.c +++ b/mpp/codec/dec/h265/h265d_parser.c @@ -1920,6 +1920,7 @@ MPP_RET h265d_init(void *ctx, ParserCfg *parser_cfg) s->slots = parser_cfg->frame_slots; s->packet_slots = parser_cfg->packet_slots; + s->notify_cb = parser_cfg->notify_cb; if (h265dctx->extradata_size > 0 && h265dctx->extradata) { ret = hevc_parser_extradata(s); @@ -1955,8 +1956,13 @@ MPP_RET h265d_flush(void *ctx) ret = mpp_hevc_output_frame(ctx, 1); } while (ret); frame = &s->DPB[s->output_frame_idx]; - - mpp_buf_slot_set_prop(s->slots, frame->slot_index, SLOT_EOS, &eos); + if(frame->slot_index < 0xff){ + mpp_buf_slot_set_prop(s->slots, frame->slot_index, SLOT_EOS, &eos); + }else{ + if(s->notify_cb.callBack != NULL){ + s->notify_cb.callBack(s->notify_cb.opaque,NULL); + } + } return MPP_OK; } diff --git a/mpp/codec/dec/h265/h265d_parser.h b/mpp/codec/dec/h265/h265d_parser.h index 5d4eba89..6b69646f 100644 --- a/mpp/codec/dec/h265/h265d_parser.h +++ b/mpp/codec/dec/h265/h265d_parser.h @@ -697,6 +697,7 @@ typedef struct HEVCContext { RK_S64 pts; RK_U8 has_get_eos; RK_U8 miss_ref_flag; + IOInterruptCB notify_cb; } HEVCContext; RK_S32 mpp_hevc_decode_short_term_rps(HEVCContext *s, ShortTermRPS *rps, diff --git a/mpp/codec/inc/mpp_dec.h b/mpp/codec/inc/mpp_dec.h index 7b1fb7de..2eeee8d1 100644 --- a/mpp/codec/inc/mpp_dec.h +++ b/mpp/codec/inc/mpp_dec.h @@ -38,6 +38,7 @@ struct MppDec_t { // dec parser thread runtime resource context MppPacket mpp_pkt_in; RK_U32 fast_mode; + void *mpp; }; @@ -60,6 +61,7 @@ MPP_RET mpp_dec_deinit(MppDec *dec); MPP_RET mpp_dec_reset(MppDec *dec); MPP_RET mpp_dec_flush(MppDec *dec); MPP_RET mpp_dec_control(MppDec *dec, MpiCmd cmd, void *param); +MPP_RET mpp_dec_notify(void *ctx, void *info); #ifdef __cplusplus } diff --git a/mpp/codec/inc/parser_api.h b/mpp/codec/inc/parser_api.h index 95c01fbd..fe8ed868 100644 --- a/mpp/codec/inc/parser_api.h +++ b/mpp/codec/inc/parser_api.h @@ -37,6 +37,7 @@ typedef struct DecParserInitCfg_t { // output RK_S32 task_count; RK_S32 need_split; + IOInterruptCB notify_cb; } ParserCfg; diff --git a/mpp/codec/mpp_dec.cpp b/mpp/codec/mpp_dec.cpp index cbeda1c4..53a6fef7 100644 --- a/mpp/codec/mpp_dec.cpp +++ b/mpp/codec/mpp_dec.cpp @@ -704,7 +704,7 @@ MPP_RET mpp_dec_init(MppDec *dec, MppCodingType coding) MppHal hal = NULL; MppDec *p = dec; RK_S32 task_count = 2; - HalIOInterruptCB cb = {NULL, NULL}; + IOInterruptCB cb = {NULL, NULL}; if (dec->fast_mode) { task_count = 3; } @@ -727,13 +727,15 @@ MPP_RET mpp_dec_init(MppDec *dec, MppCodingType coding) } mpp_buf_slot_setup(packet_slots, task_count); - + cb.callBack = mpp_dec_notify; + cb.opaque = dec; ParserCfg parser_cfg = { coding, frame_slots, packet_slots, task_count, 0, + cb, }; ret = parser_init(&parser, &parser_cfg); @@ -834,6 +836,18 @@ MPP_RET mpp_dec_flush(MppDec *dec) return MPP_OK; } +MPP_RET mpp_dec_notify(void *ctx, void *info) +{ + MppDec *dec = (MppDec *)ctx; + MppFrame info_frame = NULL; + mpp_frame_init(&info_frame); + mpp_assert(NULL == mpp_frame_get_buffer(info_frame)); + mpp_frame_set_eos(info_frame, 1); + mpp_put_frame((Mpp*)dec->mpp, info_frame); + (void)info; + return MPP_OK; +} + MPP_RET mpp_dec_control(MppDec *dec, MpiCmd cmd, void *param) { if (NULL == dec) { diff --git a/mpp/hal/inc/hal_task.h b/mpp/hal/inc/hal_task.h index 433ea92b..cbb3693b 100644 --- a/mpp/hal/inc/hal_task.h +++ b/mpp/hal/inc/hal_task.h @@ -31,6 +31,12 @@ typedef enum MppTaskStatus_e { TASK_BUTT, } MppTaskStatus; +typedef struct IOInterruptCB { + MPP_RET (*callBack)(void*, void*); + void *opaque; +} IOInterruptCB; + + /* * modified by parser * diff --git a/mpp/hal/inc/mpp_hal.h b/mpp/hal/inc/mpp_hal.h index 758179e0..1d423edb 100644 --- a/mpp/hal/inc/mpp_hal.h +++ b/mpp/hal/inc/mpp_hal.h @@ -37,10 +37,7 @@ typedef enum MppHalHardType_e { typedef void* MppHalCtx; -typedef struct HalIOInterruptCB { - MPP_RET (*callBack)(void*, void*); - void *opaque; -} HalIOInterruptCB; + typedef struct MppHalCfg_t { // input MppCtxType type; @@ -54,7 +51,7 @@ typedef struct MppHalCfg_t { HalTaskGroup tasks; RK_S32 task_count; RK_U32 fast_mode; - HalIOInterruptCB hal_int_cb; + IOInterruptCB hal_int_cb; } MppHalCfg; typedef struct MppHalApi_t { diff --git a/mpp/hal/rkdec/h265d/hal_h265d_reg.c b/mpp/hal/rkdec/h265d/hal_h265d_reg.c index d701f1d3..8b1adf84 100644 --- a/mpp/hal/rkdec/h265d/hal_h265d_reg.c +++ b/mpp/hal/rkdec/h265d/hal_h265d_reg.c @@ -68,7 +68,7 @@ typedef struct h265d_reg_context { void* hw_regs; h265d_reg_buf_t g_buf[MAX_GEN_REG]; RK_U32 fast_mode; - HalIOInterruptCB int_cb; + IOInterruptCB int_cb; } h265d_reg_context_t; typedef struct ScalingList { @@ -1392,10 +1392,10 @@ MPP_RET hal_h265d_gen_regs(void *hal, HalTaskInfo *syn) H265d_REGS_t *hw_regs; RK_S32 ret = MPP_SUCCESS; MppBuffer streambuf = NULL; - RK_S32 valid_ref = -1; RK_S32 aglin_offset = 0; #ifdef ANDROID + RK_S32 valid_ref = -1; MppBuffer framebuf = NULL; #endif diff --git a/mpp/mpp.cpp b/mpp/mpp.cpp index ae1246e8..b7518c41 100644 --- a/mpp/mpp.cpp +++ b/mpp/mpp.cpp @@ -80,7 +80,7 @@ MPP_RET Mpp::init(MppCtxType type, MppCodingType coding) if (MPP_VIDEO_CodingHEVC == coding) { mDec->fast_mode = mFastMode; } - + mDec->mpp = this; mpp_dec_init(mDec, coding); mThreadCodec = new MppThread(mpp_dec_parser_thread, this);