mirror of
https://github.com/nyanmisaka/mpp.git
synced 2025-10-06 01:26:49 +08:00
[mpp_dec]: Add MppDecCfg ctrl process to mpp_dec
Change-Id: I767e7b248922904d61aa19afd657a5543a2b9995 Signed-off-by: Herman Chen <herman.chen@rock-chips.com>
This commit is contained in:
@@ -40,6 +40,7 @@
|
||||
/* decoder control command */
|
||||
#define CMD_DEC_CFG_ALL (0x00000000)
|
||||
#define CMD_DEC_QUERY (0x00000100)
|
||||
#define CMD_DEC_CFG (0x00000200)
|
||||
|
||||
/* encoder control command */
|
||||
#define CMD_ENC_CFG_ALL (0x00000000)
|
||||
@@ -94,6 +95,10 @@ typedef enum {
|
||||
/* query decoder runtime information for decode stage */
|
||||
MPP_DEC_QUERY, /* set and get MppDecQueryCfg structure */
|
||||
|
||||
CMD_DEC_CMD_CFG = CMD_MODULE_CODEC | CMD_CTX_ID_DEC | CMD_DEC_CFG,
|
||||
MPP_DEC_SET_CFG, /* set MppDecCfg structure */
|
||||
MPP_DEC_GET_CFG, /* get MppDecCfg structure */
|
||||
|
||||
MPP_DEC_CMD_END,
|
||||
|
||||
MPP_ENC_CMD_BASE = CMD_MODULE_CODEC | CMD_CTX_ID_ENC,
|
||||
|
@@ -79,7 +79,7 @@ MPP_RET dummy_dec_init(void *dec, ParserCfg *cfg)
|
||||
p = (DummyDec *)dec;
|
||||
p->frame_slots = cfg->frame_slots;
|
||||
p->packet_slots = cfg->packet_slots;
|
||||
p->task_count = cfg->task_count = 2;
|
||||
p->task_count = 2;
|
||||
p->stream = stream;
|
||||
p->stream_size = stream_size;
|
||||
p->task_pkt = task_pkt;
|
||||
|
@@ -32,7 +32,8 @@ typedef struct {
|
||||
// parameter interact with mpp_dec
|
||||
MppBufSlots frame_slots;
|
||||
MppBufSlots packet_slots;
|
||||
RK_S32 task_count;
|
||||
MppDecCfgSet *cfg;
|
||||
|
||||
RK_U8 *stream;
|
||||
size_t stream_size;
|
||||
MppPacket task_pkt;
|
||||
@@ -42,7 +43,6 @@ typedef struct {
|
||||
// runtime parameter
|
||||
RK_U32 need_split;
|
||||
RK_U32 frame_count;
|
||||
RK_U32 internal_pts;
|
||||
|
||||
// parser context
|
||||
H263dParser parser;
|
||||
@@ -88,9 +88,8 @@ MPP_RET h263d_init(void *dec, ParserCfg *cfg)
|
||||
p = (H263dCtx *)dec;
|
||||
p->frame_slots = cfg->frame_slots;
|
||||
p->packet_slots = cfg->packet_slots;
|
||||
p->task_count = cfg->task_count = 2;
|
||||
p->need_split = cfg->need_split;
|
||||
p->internal_pts = cfg->internal_pts;
|
||||
p->cfg = cfg->cfg;
|
||||
p->need_split = p->cfg->base.split_parse;
|
||||
p->stream = stream;
|
||||
p->stream_size = stream_size;
|
||||
p->task_pkt = task_pkt;
|
||||
|
@@ -51,7 +51,6 @@ static MPP_RET init_input_ctx(H264dInputCtx_t *p_Inp, ParserCfg *init)
|
||||
|
||||
INP_CHECK(ret, !p_Inp && !init);
|
||||
|
||||
p_Inp->init = *init;
|
||||
mpp_env_get_u32("rkv_h264d_mvc_disable", &p_Inp->mvc_disable, 1);
|
||||
open_stream_file(p_Inp, "/sdcard");
|
||||
if (rkv_h264d_parse_debug & H264D_DBG_WRITE_ES_EN) {
|
||||
@@ -315,6 +314,7 @@ MPP_RET h264d_init(void *decoder, ParserCfg *init)
|
||||
//!< get init frame_slots and packet_slots
|
||||
p_Dec->frame_slots = init->frame_slots;
|
||||
p_Dec->packet_slots = init->packet_slots;
|
||||
p_Dec->cfg = init->cfg;
|
||||
//!< malloc decoder buffer
|
||||
p_Dec->p_Inp = mpp_calloc(H264dInputCtx_t, 1);
|
||||
p_Dec->p_Cur = mpp_calloc(H264dCurCtx_t, 1);
|
||||
@@ -335,7 +335,7 @@ MPP_RET h264d_init(void *decoder, ParserCfg *init)
|
||||
FUN_CHECK(ret = init_cur_ctx(p_Dec->p_Cur));
|
||||
FUN_CHECK(ret = init_vid_ctx(p_Dec->p_Vid));
|
||||
FUN_CHECK(ret = init_dec_ctx(p_Dec));
|
||||
p_Dec->immediate_out = init->immediate_out;
|
||||
p_Dec->immediate_out = p_Dec->cfg->base.fast_out;
|
||||
__RETURN:
|
||||
return ret = MPP_OK;
|
||||
__FAILED:
|
||||
@@ -469,23 +469,10 @@ __FAILED:
|
||||
*/
|
||||
MPP_RET h264d_control(void *decoder, MpiCmd cmd_type, void *param)
|
||||
{
|
||||
MPP_RET ret = MPP_ERR_UNKNOW;
|
||||
H264_DecCtx_t *dec = (H264_DecCtx_t *)decoder;
|
||||
|
||||
INP_CHECK(ret, !decoder);
|
||||
switch (cmd_type) {
|
||||
case MPP_DEC_SET_DISABLE_ERROR: {
|
||||
dec->disable_error = *((RK_U32 *)param);
|
||||
} break;
|
||||
case MPP_DEC_SET_IMMEDIATE_OUT: {
|
||||
dec->immediate_out = *((RK_U32 *)param);
|
||||
} break;
|
||||
default : {
|
||||
} break;
|
||||
}
|
||||
|
||||
__RETURN:
|
||||
return ret = MPP_OK;
|
||||
(void) decoder;
|
||||
(void) cmd_type;
|
||||
(void) param;
|
||||
return MPP_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -554,7 +541,7 @@ MPP_RET h264d_prepare(void *decoder, MppPacket pkt, HalDecTask *task)
|
||||
} else {
|
||||
fwrite_stream_to_file(p_Inp, p_Inp->in_buf, (RK_U32)p_Inp->in_length);
|
||||
do {
|
||||
if (p_Inp->init.need_split) {
|
||||
if (p_Dec->cfg->base.split_parse) {
|
||||
ret = parse_prepare(p_Inp, p_Dec->p_Cur);
|
||||
} else {
|
||||
ret = parse_prepare_fast(p_Inp, p_Dec->p_Cur);
|
||||
@@ -621,7 +608,7 @@ MPP_RET h264d_parse(void *decoder, HalDecTask *in_task)
|
||||
in_task->syntax.number = p_Dec->dxva_ctx->syn.num;
|
||||
in_task->syntax.data = (void *)p_Dec->dxva_ctx->syn.buf;
|
||||
in_task->flags.used_for_ref = p_err->used_ref_flag;
|
||||
in_task->flags.ref_err |= (!p_Dec->disable_error
|
||||
in_task->flags.ref_err |= (!p_Dec->cfg->base.disable_error
|
||||
&& (p_err->dpb_err_flag | p_err->cur_err_flag)) ? 1 : 0;
|
||||
}
|
||||
|
||||
|
@@ -1261,7 +1261,7 @@ static MPP_RET scan_dpb_output(H264_DpbBuf_t *p_Dpb, H264_StorePic_t *p)
|
||||
p_Dpb->poc_interval = 1;
|
||||
}
|
||||
|
||||
if (p_Dpb->p_Vid->p_Dec->immediate_out ||
|
||||
if (p_Dpb->p_Vid->p_Dec->cfg->base.fast_out ||
|
||||
(p_err->i_slice_no < 2 && p_Dpb->last_output_poc == INT_MIN)) {
|
||||
FUN_CHECK(ret = write_stored_frame(p_Dpb->p_Vid, p_Dpb, fs));
|
||||
} else {
|
||||
|
@@ -881,7 +881,7 @@ typedef struct h264d_input_ctx_t {
|
||||
struct h264d_cur_ctx_t *p_Cur; //!< current parameters, use in read nalu
|
||||
struct h264d_video_ctx_t *p_Vid; //!< parameters for video decoder
|
||||
enum mpp_decmtd_type dec_mtd;
|
||||
ParserCfg init;
|
||||
|
||||
//!< input data
|
||||
RK_U8 *in_buf;
|
||||
size_t in_length;
|
||||
@@ -1125,6 +1125,7 @@ typedef struct h264_dec_ctx_t {
|
||||
//!< add
|
||||
MppBufSlots frame_slots; //!< corresponding to dpb_mark
|
||||
MppBufSlots packet_slots;
|
||||
MppDecCfgSet *cfg;
|
||||
|
||||
MppPacket task_pkt;
|
||||
|
||||
@@ -1132,7 +1133,6 @@ typedef struct h264_dec_ctx_t {
|
||||
RK_U32 task_eos;
|
||||
HalDecTask *in_task;
|
||||
RK_S32 last_frame_slot_idx;
|
||||
RK_U32 disable_error;
|
||||
RK_U32 immediate_out;
|
||||
struct h264_err_ctx_t errctx;
|
||||
} H264_DecCtx_t;
|
||||
|
@@ -25,10 +25,11 @@
|
||||
* 2015.7.15 : Create
|
||||
*/
|
||||
|
||||
#ifndef __MPP_CODEC_H__
|
||||
#define __MPP_CODEC_H__
|
||||
#ifndef __H265D_CODEC_H__
|
||||
#define __H265D_CODEC_H__
|
||||
|
||||
#include "mpp_frame.h"
|
||||
#include "mpp_dec_cfg.h"
|
||||
|
||||
typedef struct MppRational {
|
||||
RK_S32 num; ///< numerator
|
||||
@@ -137,8 +138,7 @@ typedef struct H265dContext {
|
||||
|
||||
void *compare_info;
|
||||
|
||||
RK_U32 need_split;
|
||||
RK_U32 disable_error;
|
||||
MppDecCfgSet *cfg;
|
||||
} H265dContext_t;
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -151,4 +151,4 @@ RK_S32 h265d_syntax_fill_slice(void *ctx, RK_S32 input_index);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __MPP_CODEC_H__ */
|
||||
#endif /* __H265D_CODEC_H__ */
|
||||
|
@@ -1203,7 +1203,7 @@ static RK_S32 hevc_frame_start(HEVCContext *s)
|
||||
if (ret < 0)
|
||||
goto fail;
|
||||
|
||||
if (!s->h265dctx->disable_error && s->miss_ref_flag) {
|
||||
if (!s->h265dctx->cfg->base.disable_error && s->miss_ref_flag) {
|
||||
if (!IS_IRAP(s)) {
|
||||
mpp_frame_set_errinfo(s->frame, MPP_FRAME_ERR_UNKNOW);
|
||||
s->ref->error_flag = 1;
|
||||
@@ -1336,7 +1336,7 @@ static RK_S32 parser_nal_unit(HEVCContext *s, const RK_U8 *nal, int length)
|
||||
s->poc <= s->max_ra) {
|
||||
s->is_decoded = 0;
|
||||
break;
|
||||
} else if (!s->h265dctx->disable_error &&
|
||||
} else if (!s->h265dctx->cfg->base.disable_error &&
|
||||
(s->poc < s->max_ra) && !IS_IRAP(s)) { //when seek to I slice skip the stream small then I slic poc
|
||||
s->is_decoded = 0;
|
||||
break;
|
||||
@@ -1741,8 +1741,7 @@ MPP_RET h265d_prepare(void *ctx, MppPacket pkt, HalDecTask *task)
|
||||
}
|
||||
}
|
||||
|
||||
if (h265dctx->need_split && !s->is_nalff) {
|
||||
|
||||
if (h265dctx->cfg->base.split_parse && !s->is_nalff) {
|
||||
RK_S32 consume = 0;
|
||||
RK_U8 *split_out_buf = NULL;
|
||||
RK_S32 split_size = 0;
|
||||
@@ -1952,9 +1951,9 @@ MPP_RET h265d_init(void *ctx, ParserCfg *parser_cfg)
|
||||
h265dctx->priv_data = s;
|
||||
}
|
||||
|
||||
h265dctx->need_split = parser_cfg->need_split;
|
||||
h265dctx->cfg = parser_cfg->cfg;
|
||||
|
||||
if (sc == NULL && h265dctx->need_split) {
|
||||
if (sc == NULL && h265dctx->cfg->base.split_parse) {
|
||||
h265d_split_init((void**)&sc);
|
||||
if (sc == NULL) {
|
||||
mpp_err("split contxt malloc fail");
|
||||
@@ -2029,16 +2028,9 @@ MPP_RET h265d_reset(void *ctx)
|
||||
|
||||
MPP_RET h265d_control(void *ctx, MpiCmd cmd, void *param)
|
||||
{
|
||||
H265dContext_t *h265dctx = (H265dContext_t *)ctx;
|
||||
|
||||
switch (cmd) {
|
||||
case MPP_DEC_SET_DISABLE_ERROR: {
|
||||
h265dctx->disable_error = *((RK_U32 *)param);
|
||||
}
|
||||
default : {
|
||||
} break;
|
||||
}
|
||||
|
||||
(void) ctx;
|
||||
(void) cmd;
|
||||
(void) param;
|
||||
return MPP_OK;
|
||||
}
|
||||
|
||||
@@ -2047,7 +2039,7 @@ MPP_RET h265d_callback(void *ctx, void *err_info)
|
||||
H265dContext_t *h265dctx = (H265dContext_t *)ctx;
|
||||
HalDecTask *task_dec = (HalDecTask *)err_info;
|
||||
|
||||
if (!h265dctx->disable_error) {
|
||||
if (!h265dctx->cfg->base.disable_error) {
|
||||
HEVCContext *s = (HEVCContext *)h265dctx->priv_data;
|
||||
MppFrame frame = NULL;
|
||||
RK_U32 i = 0;
|
||||
|
@@ -197,7 +197,7 @@ static MPP_RET m2vd_parser_init_ctx(M2VDParserContext *ctx, ParserCfg *cfg)
|
||||
ctx->mExtraHeaderDecFlag = 0;
|
||||
ctx->max_stream_size = M2VD_BUF_SIZE_BITMEM;
|
||||
ctx->ref_frame_cnt = 0;
|
||||
ctx->need_split = cfg->need_split;
|
||||
ctx->need_split = cfg->cfg->base.split_parse;
|
||||
ctx->left_length = 0;
|
||||
ctx->vop_header_found = 0;
|
||||
|
||||
|
@@ -89,9 +89,9 @@ static MPP_RET mpg4d_init(void *dec, ParserCfg *cfg)
|
||||
p = (Mpg4dCtx *)dec;
|
||||
p->frame_slots = cfg->frame_slots;
|
||||
p->packet_slots = cfg->packet_slots;
|
||||
p->task_count = cfg->task_count = 2;
|
||||
p->task_count = 2;
|
||||
p->need_split = 1;//cfg->need_split;
|
||||
p->internal_pts = cfg->internal_pts;
|
||||
p->internal_pts = cfg->cfg->base.internal_pts;
|
||||
p->stream = stream;
|
||||
p->stream_size = stream_size;
|
||||
p->task_pkt = task_pkt;
|
||||
|
@@ -20,23 +20,22 @@
|
||||
#include "rk_type.h"
|
||||
#include "mpp_err.h"
|
||||
#include "rk_mpi_cmd.h"
|
||||
#include "mpp_dec_cfg.h"
|
||||
|
||||
typedef void* MppDec;
|
||||
|
||||
typedef struct {
|
||||
MppCodingType coding;
|
||||
RK_U32 fast_mode;
|
||||
RK_U32 need_split;
|
||||
RK_U32 internal_pts;
|
||||
RK_U32 immedaite_out;
|
||||
void *mpp;
|
||||
} MppDecCfg;
|
||||
|
||||
MppDecCfgSet *cfg;
|
||||
} MppDecInitCfg;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
MPP_RET mpp_dec_init(MppDec *ctx, MppDecCfg *cfg);
|
||||
MPP_RET mpp_dec_init(MppDec *ctx, MppDecInitCfg *cfg);
|
||||
MPP_RET mpp_dec_deinit(MppDec ctx);
|
||||
|
||||
MPP_RET mpp_dec_start(MppDec ctx);
|
||||
@@ -47,6 +46,10 @@ MPP_RET mpp_dec_flush(MppDec ctx);
|
||||
MPP_RET mpp_dec_control(MppDec ctx, MpiCmd cmd, void *param);
|
||||
MPP_RET mpp_dec_notify(MppDec ctx, RK_U32 flag);
|
||||
|
||||
/* update init cfg before init */
|
||||
MPP_RET mpp_dec_set_cfg_by_cmd(MppDecCfgSet *set, MpiCmd cmd, void *param);
|
||||
MPP_RET mpp_dec_set_cfg(MppDecCfgSet *dst, MppDecCfgSet *src);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@@ -20,6 +20,7 @@
|
||||
#include "mpp_time.h"
|
||||
|
||||
#include "mpp.h"
|
||||
#include "mpp_dec_cfg.h"
|
||||
#include "mpp_parser.h"
|
||||
#include "mpp_hal.h"
|
||||
|
||||
@@ -56,6 +57,9 @@ typedef struct MppDecImpl_t {
|
||||
HalTaskGroup tasks;
|
||||
HalTaskGroup vproc_tasks;
|
||||
|
||||
// runtime configure set
|
||||
MppDecCfgSet cfg;
|
||||
|
||||
// status flags
|
||||
RK_U32 parser_work_count;
|
||||
RK_U32 parser_wait_count;
|
||||
@@ -81,11 +85,8 @@ typedef struct MppDecImpl_t {
|
||||
sem_t hal_reset;
|
||||
|
||||
// work mode flags
|
||||
RK_U32 parser_need_split;
|
||||
RK_U32 parser_fast_mode;
|
||||
RK_U32 parser_internal_pts;
|
||||
RK_U32 disable_error;
|
||||
RK_U32 use_preset_time_order;
|
||||
RK_U32 enable_deinterlace;
|
||||
|
||||
// dec parser thread runtime resource context
|
||||
|
@@ -20,6 +20,7 @@
|
||||
#include "rk_mpi_cmd.h"
|
||||
#include "mpp_packet.h"
|
||||
#include "mpp_buf_slot.h"
|
||||
#include "mpp_dec_cfg.h"
|
||||
#include "hal_task.h"
|
||||
|
||||
/*
|
||||
@@ -29,16 +30,10 @@
|
||||
* the reset wait for extension
|
||||
*/
|
||||
typedef struct DecParserInitCfg_t {
|
||||
// input
|
||||
MppCodingType coding;
|
||||
MppBufSlots frame_slots;
|
||||
MppBufSlots packet_slots;
|
||||
|
||||
// output
|
||||
RK_S32 task_count;
|
||||
RK_U32 need_split;
|
||||
RK_U32 immediate_out;
|
||||
RK_U32 internal_pts;
|
||||
MppDecCfgSet *cfg;
|
||||
} ParserCfg;
|
||||
|
||||
|
||||
|
@@ -28,6 +28,7 @@
|
||||
#include "mpp_buffer_impl.h"
|
||||
#include "mpp_packet_impl.h"
|
||||
#include "mpp_frame_impl.h"
|
||||
#include "mpp_dec_cfg_impl.h"
|
||||
|
||||
#include "mpp_dec_vproc.h"
|
||||
|
||||
@@ -234,7 +235,7 @@ static RK_U32 reset_parser_thread(Mpp *mpp, DecTask *task)
|
||||
mpp_buf_slot_clr_flag(frame_slots, index, SLOT_QUEUE_USE);
|
||||
}
|
||||
|
||||
if (dec->use_preset_time_order) {
|
||||
if (dec->cfg.base.sort_pts) {
|
||||
AutoMutex autoLock(mpp->mTimeStamps->mutex());
|
||||
mpp->mTimeStamps->flush();
|
||||
}
|
||||
@@ -323,13 +324,13 @@ static void mpp_dec_put_frame(Mpp *mpp, RK_S32 index, HalDecTaskFlag flags)
|
||||
mpp_assert(index >= 0);
|
||||
mpp_assert(frame);
|
||||
|
||||
if (dec->disable_error) {
|
||||
if (dec->cfg.base.disable_error) {
|
||||
mpp_frame_set_errinfo(frame, 0);
|
||||
mpp_frame_set_discard(frame, 0);
|
||||
}
|
||||
|
||||
if (!change) {
|
||||
if (dec->use_preset_time_order) {
|
||||
if (dec->cfg.base.sort_pts) {
|
||||
MppPacket pkt = NULL;
|
||||
mpp_list *ts = mpp->mTimeStamps;
|
||||
|
||||
@@ -524,7 +525,7 @@ static MPP_RET try_proc_dec_task(Mpp *mpp, DecTask *task)
|
||||
mpp->mPacketGetCount++;
|
||||
dec->dec_in_pkt_count++;
|
||||
|
||||
if (dec->use_preset_time_order) {
|
||||
if (dec->cfg.base.sort_pts) {
|
||||
MppPacket pkt_in = NULL;
|
||||
mpp_list *ts = mpp->mTimeStamps;
|
||||
|
||||
@@ -1254,7 +1255,59 @@ static const char *timing_str[DEC_TIMING_BUTT] = {
|
||||
"hw wait ",
|
||||
};
|
||||
|
||||
MPP_RET mpp_dec_init(MppDec *dec, MppDecCfg *cfg)
|
||||
MPP_RET mpp_dec_set_cfg(MppDecCfgSet *dst, MppDecCfgSet *src)
|
||||
{
|
||||
MppDecBaseCfg *src_base = &src->base;
|
||||
|
||||
if (src_base->change) {
|
||||
MppDecBaseCfg *dst_base = &dst->base;
|
||||
RK_U32 change = src_base->change;
|
||||
|
||||
if (change & MPP_DEC_CFG_CHANGE_OUTPUT_FORMAT)
|
||||
dst_base->out_fmt = src_base->out_fmt;
|
||||
|
||||
if (change & MPP_DEC_CFG_CHANGE_FAST_OUT)
|
||||
dst_base->fast_out = src_base->fast_out;
|
||||
|
||||
if (change & MPP_DEC_CFG_CHANGE_FAST_PARSE)
|
||||
dst_base->fast_parse = src_base->fast_parse;
|
||||
|
||||
if (change & MPP_DEC_CFG_CHANGE_SPLIT_PARSE)
|
||||
dst_base->split_parse = src_base->split_parse;
|
||||
|
||||
if (change & MPP_DEC_CFG_CHANGE_INTERNAL_PTS)
|
||||
dst_base->internal_pts = src_base->internal_pts;
|
||||
|
||||
if (change & MPP_DEC_CFG_CHANGE_SORT_PTS)
|
||||
dst_base->sort_pts = src_base->sort_pts;
|
||||
|
||||
if (change & MPP_DEC_CFG_CHANGE_DISABLE_ERROR)
|
||||
dst_base->disable_error = src_base->disable_error;
|
||||
|
||||
dst_base->change = change;
|
||||
src_base->change = 0;
|
||||
}
|
||||
|
||||
return MPP_OK;
|
||||
}
|
||||
|
||||
MPP_RET mpp_dec_update_cfg(MppDecImpl *p)
|
||||
{
|
||||
MppDecCfgSet *cfg = &p->cfg;
|
||||
MppDecBaseCfg *base = &cfg->base;
|
||||
MppDecStatusCfg *status = &cfg->status;
|
||||
|
||||
p->parser_fast_mode = base->fast_parse;
|
||||
p->enable_deinterlace = base->enable_vproc;
|
||||
p->disable_error = base->disable_error;
|
||||
|
||||
status->hal_task_count = (base->fast_parse) ? 3 : 2;
|
||||
status->vproc_task_count = 0;
|
||||
|
||||
return MPP_OK;
|
||||
}
|
||||
|
||||
MPP_RET mpp_dec_init(MppDec *dec, MppDecInitCfg *cfg)
|
||||
{
|
||||
RK_S32 i;
|
||||
MPP_RET ret;
|
||||
@@ -1263,9 +1316,9 @@ MPP_RET mpp_dec_init(MppDec *dec, MppDecCfg *cfg)
|
||||
MppBufSlots packet_slots = NULL;
|
||||
Parser parser = NULL;
|
||||
MppHal hal = NULL;
|
||||
RK_S32 hal_task_count = 0;
|
||||
MppDecImpl *p = NULL;
|
||||
IOInterruptCB cb = {NULL, NULL};
|
||||
MppDecStatusCfg *status = NULL;
|
||||
|
||||
mpp_env_get_u32("mpp_dec_debug", &mpp_dec_debug, 0);
|
||||
dec_dbg_func("in\n");
|
||||
@@ -1283,8 +1336,14 @@ MPP_RET mpp_dec_init(MppDec *dec, MppDecCfg *cfg)
|
||||
return MPP_ERR_MALLOC;
|
||||
}
|
||||
|
||||
p->mpp = cfg->mpp;
|
||||
coding = cfg->coding;
|
||||
hal_task_count = (cfg->fast_mode) ? (3) : (2);
|
||||
|
||||
mpp_assert(cfg->cfg);
|
||||
mpp_dec_set_cfg(&p->cfg, cfg->cfg);
|
||||
mpp_dec_update_cfg(p);
|
||||
|
||||
status = &p->cfg.status;
|
||||
|
||||
do {
|
||||
ret = mpp_buf_slot_init(&frame_slots);
|
||||
@@ -1299,15 +1358,13 @@ MPP_RET mpp_dec_init(MppDec *dec, MppDecCfg *cfg)
|
||||
break;
|
||||
}
|
||||
|
||||
mpp_buf_slot_setup(packet_slots, hal_task_count);
|
||||
mpp_buf_slot_setup(packet_slots, status->hal_task_count);
|
||||
|
||||
ParserCfg parser_cfg = {
|
||||
coding,
|
||||
frame_slots,
|
||||
packet_slots,
|
||||
hal_task_count,
|
||||
cfg->need_split,
|
||||
cfg->immedaite_out,
|
||||
cfg->internal_pts,
|
||||
&p->cfg,
|
||||
};
|
||||
|
||||
ret = mpp_parser_init(&parser, &parser_cfg);
|
||||
@@ -1323,11 +1380,8 @@ MPP_RET mpp_dec_init(MppDec *dec, MppDecCfg *cfg)
|
||||
coding,
|
||||
frame_slots,
|
||||
packet_slots,
|
||||
&p->cfg,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
parser_cfg.task_count,
|
||||
cfg->fast_mode,
|
||||
cb,
|
||||
};
|
||||
|
||||
@@ -1344,12 +1398,6 @@ MPP_RET mpp_dec_init(MppDec *dec, MppDecCfg *cfg)
|
||||
p->frame_slots = frame_slots;
|
||||
p->packet_slots = packet_slots;
|
||||
|
||||
p->mpp = cfg->mpp;
|
||||
p->parser_need_split = cfg->need_split;
|
||||
p->parser_fast_mode = cfg->fast_mode;
|
||||
p->parser_internal_pts = cfg->internal_pts;
|
||||
p->enable_deinterlace = 1;
|
||||
|
||||
p->statistics_en = (mpp_dec_debug & MPP_DEC_DBG_TIMING) ? 1 : 0;
|
||||
|
||||
for (i = 0; i < DEC_TIMING_BUTT; i++) {
|
||||
@@ -1594,17 +1642,14 @@ MPP_RET mpp_dec_control(MppDec ctx, MpiCmd cmd, void *param)
|
||||
*p = mpp_slots_get_used_count(dec->frame_slots);
|
||||
dec_dbg_func("used count %d\n", *p);
|
||||
} break;
|
||||
case MPP_DEC_SET_DISABLE_ERROR: {
|
||||
dec->disable_error = (param) ? (*((RK_U32 *)param)) : (1);
|
||||
dec_dbg_func("disable error %d\n", dec->disable_error);
|
||||
} break;
|
||||
case MPP_DEC_SET_PRESENT_TIME_ORDER: {
|
||||
dec->use_preset_time_order = (param) ? (*((RK_U32 *)param)) : (1);
|
||||
dec_dbg_func("preset time order %d\n", dec->use_preset_time_order);
|
||||
} break;
|
||||
case MPP_DEC_SET_PRESENT_TIME_ORDER :
|
||||
case MPP_DEC_SET_PARSER_SPLIT_MODE :
|
||||
case MPP_DEC_SET_PARSER_FAST_MODE :
|
||||
case MPP_DEC_SET_IMMEDIATE_OUT :
|
||||
case MPP_DEC_SET_DISABLE_ERROR :
|
||||
case MPP_DEC_SET_ENABLE_DEINTERLACE : {
|
||||
dec->enable_deinterlace = (param) ? (*((RK_U32 *)param)) : (1);
|
||||
dec_dbg_func("enable deinterlace %d\n", dec->enable_deinterlace);
|
||||
ret = mpp_dec_set_cfg_by_cmd(&dec->cfg, cmd, param);
|
||||
dec->cfg.base.change = 0;
|
||||
} break;
|
||||
case MPP_DEC_QUERY: {
|
||||
MppDecQueryCfg *query = (MppDecQueryCfg *)param;
|
||||
@@ -1633,6 +1678,16 @@ MPP_RET mpp_dec_control(MppDec ctx, MpiCmd cmd, void *param)
|
||||
if (flag & MPP_DEC_QUERY_DEC_OUT_FRM)
|
||||
query->dec_out_frm_cnt = dec->dec_out_frame_count;
|
||||
} break;
|
||||
case MPP_DEC_SET_CFG: {
|
||||
MppDecCfgImpl *dec_cfg = (MppDecCfgImpl *)param;
|
||||
|
||||
if (dec_cfg) {
|
||||
mpp_dec_set_cfg(&dec->cfg, &dec_cfg->cfg);
|
||||
mpp_dec_update_cfg(dec);
|
||||
}
|
||||
|
||||
dec_dbg_func("set dec cfg\n");
|
||||
} break;
|
||||
default : {
|
||||
} break;
|
||||
}
|
||||
@@ -1640,3 +1695,50 @@ MPP_RET mpp_dec_control(MppDec ctx, MpiCmd cmd, void *param)
|
||||
dec_dbg_func("%p out\n", dec);
|
||||
return ret;
|
||||
}
|
||||
|
||||
MPP_RET mpp_dec_set_cfg_by_cmd(MppDecCfgSet *set, MpiCmd cmd, void *param)
|
||||
{
|
||||
MppDecBaseCfg *cfg = &set->base;
|
||||
MPP_RET ret = MPP_OK;
|
||||
|
||||
switch (cmd) {
|
||||
case MPP_DEC_SET_PRESENT_TIME_ORDER : {
|
||||
cfg->sort_pts = (param) ? (*((RK_U32 *)param)) : (1);
|
||||
cfg->change |= MPP_DEC_CFG_CHANGE_SORT_PTS;
|
||||
dec_dbg_func("sort time order %d\n", cfg->sort_pts);
|
||||
} break;
|
||||
case MPP_DEC_SET_PARSER_SPLIT_MODE : {
|
||||
cfg->split_parse = (param) ? (*((RK_U32 *)param)) : (0);
|
||||
cfg->change |= MPP_DEC_CFG_CHANGE_SPLIT_PARSE;
|
||||
dec_dbg_func("split parse mode %d\n", cfg->split_parse);
|
||||
} break;
|
||||
case MPP_DEC_SET_PARSER_FAST_MODE : {
|
||||
cfg->fast_parse = (param) ? (*((RK_U32 *)param)) : (0);
|
||||
cfg->change |= MPP_DEC_CFG_CHANGE_FAST_PARSE;
|
||||
dec_dbg_func("fast parse mode %d\n", cfg->fast_parse);
|
||||
} break;
|
||||
case MPP_DEC_SET_DISABLE_ERROR: {
|
||||
cfg->disable_error = (param) ? (*((RK_U32 *)param)) : (1);
|
||||
cfg->change |= MPP_DEC_CFG_CHANGE_DISABLE_ERROR;
|
||||
dec_dbg_func("disable error %d\n", cfg->disable_error);
|
||||
} break;
|
||||
case MPP_DEC_SET_IMMEDIATE_OUT : {
|
||||
cfg->fast_out = (param) ? (*((RK_U32 *)param)) : (0);
|
||||
cfg->change |= MPP_DEC_CFG_CHANGE_FAST_OUT;
|
||||
dec_dbg_func("fast output mode %d\n", cfg->fast_out);
|
||||
} break;
|
||||
case MPP_DEC_SET_ENABLE_DEINTERLACE: {
|
||||
cfg->enable_vproc = (param) ? (*((RK_U32 *)param)) : (1);
|
||||
cfg->change |= MPP_DEC_CFG_CHANGE_ENABLE_VPROC;
|
||||
dec_dbg_func("enable dec_vproc %d\n", cfg->enable_vproc);
|
||||
} break;
|
||||
default : {
|
||||
mpp_err_f("unsupported cfg update cmd %x\n", cmd);
|
||||
ret = MPP_NOK;
|
||||
} break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -71,8 +71,6 @@ static const ParserApi *parsers[] = {
|
||||
};
|
||||
|
||||
typedef struct ParserImpl_t {
|
||||
ParserCfg cfg;
|
||||
|
||||
const ParserApi *api;
|
||||
void *ctx;
|
||||
} ParserImpl;
|
||||
@@ -107,7 +105,6 @@ MPP_RET mpp_parser_init(Parser *prs, ParserCfg *cfg)
|
||||
return ret;
|
||||
}
|
||||
|
||||
p->cfg = *cfg;
|
||||
p->api = api;
|
||||
p->ctx = ctx;
|
||||
*prs = p;
|
||||
|
@@ -24,6 +24,7 @@
|
||||
|
||||
#include "hal_task.h"
|
||||
#include "mpp_enc_cfg.h"
|
||||
#include "mpp_dec_cfg.h"
|
||||
|
||||
typedef enum VpuHwMode_e {
|
||||
MODE_NULL = 0,
|
||||
@@ -40,14 +41,10 @@ typedef struct MppHalCfg_t {
|
||||
MppCodingType coding;
|
||||
MppBufSlots frame_slots;
|
||||
MppBufSlots packet_slots;
|
||||
// for encoder
|
||||
MppEncCfgSet *cfg; /* encoder runtime config */
|
||||
MppEncCfgSet *set; /* encoder input config */
|
||||
MppDecCfgSet *cfg;
|
||||
|
||||
// output
|
||||
HalTaskGroup tasks;
|
||||
RK_S32 task_count;
|
||||
RK_U32 fast_mode;
|
||||
IOInterruptCB hal_int_cb;
|
||||
} MppHalCfg;
|
||||
|
||||
|
@@ -78,16 +78,10 @@ static const MppHalApi *hw_apis[] = {
|
||||
};
|
||||
|
||||
typedef struct MppHalImpl_t {
|
||||
MppCtxType type;
|
||||
MppCodingType coding;
|
||||
MppBufSlots frame_slots;
|
||||
MppBufSlots packet_slots;
|
||||
|
||||
void *ctx;
|
||||
const MppHalApi *api;
|
||||
|
||||
HalTaskGroup tasks;
|
||||
RK_S32 task_count;
|
||||
} MppHalImpl;
|
||||
|
||||
|
||||
@@ -109,13 +103,7 @@ MPP_RET mpp_hal_init(MppHal *ctx, MppHalCfg *cfg)
|
||||
for (i = 0; i < MPP_ARRAY_ELEMS(hw_apis); i++) {
|
||||
if (cfg->type == hw_apis[i]->type &&
|
||||
cfg->coding == hw_apis[i]->coding) {
|
||||
mpp_assert(cfg->task_count > 0);
|
||||
p->type = cfg->type;
|
||||
p->coding = cfg->coding;
|
||||
p->frame_slots = cfg->frame_slots;
|
||||
p->packet_slots = cfg->packet_slots;
|
||||
p->api = hw_apis[i];
|
||||
p->task_count = cfg->task_count;
|
||||
p->ctx = mpp_calloc_size(void, p->api->ctx_size);
|
||||
|
||||
MPP_RET ret = p->api->init(p->ctx, cfg);
|
||||
@@ -124,7 +112,7 @@ MPP_RET mpp_hal_init(MppHal *ctx, MppHalCfg *cfg)
|
||||
break;
|
||||
}
|
||||
|
||||
ret = hal_task_group_init(&p->tasks, p->task_count);
|
||||
ret = hal_task_group_init(&p->tasks, cfg->cfg->status.hal_task_count);
|
||||
if (ret) {
|
||||
mpp_err_f("hal_task_group_init failed ret %d\n", ret);
|
||||
break;
|
||||
|
@@ -100,7 +100,8 @@ MPP_RET hal_h264d_init(void *hal, MppHalCfg *cfg)
|
||||
|
||||
p_hal->frame_slots = cfg->frame_slots;
|
||||
p_hal->packet_slots = cfg->packet_slots;
|
||||
p_hal->fast_mode = cfg->fast_mode;
|
||||
p_hal->cfg = cfg->cfg;
|
||||
p_hal->fast_mode = cfg->cfg->base.fast_parse;
|
||||
|
||||
//!< choose hard mode
|
||||
{
|
||||
|
@@ -122,6 +122,7 @@ typedef struct h264d_hal_ctx_t {
|
||||
HalDecTask *in_task;
|
||||
MppBufSlots frame_slots;
|
||||
MppBufSlots packet_slots;
|
||||
MppDecCfgSet *cfg;
|
||||
MppBufferGroup buf_group;
|
||||
HalBufs cmv_bufs;
|
||||
RK_S32 mv_size;
|
||||
|
@@ -713,7 +713,6 @@ MPP_RET vdpu1_h264d_init(void *hal, MppHalCfg *cfg)
|
||||
H264dHalCtx_t *p_hal = (H264dHalCtx_t *)hal;
|
||||
INP_CHECK(ret, NULL == hal);
|
||||
|
||||
p_hal->fast_mode = cfg->fast_mode;
|
||||
//!< malloc init registers
|
||||
MEM_CHECK(ret, p_hal->priv =
|
||||
mpp_calloc_size(void, sizeof(H264dVdpuPriv_t)));
|
||||
|
@@ -681,7 +681,6 @@ MPP_RET vdpu2_h264d_init(void *hal, MppHalCfg *cfg)
|
||||
H264dHalCtx_t *p_hal = (H264dHalCtx_t *)hal;
|
||||
INP_CHECK(ret, NULL == hal);
|
||||
|
||||
p_hal->fast_mode = cfg->fast_mode;
|
||||
MEM_CHECK(ret, p_hal->priv = mpp_calloc_size(void,
|
||||
sizeof(H264dVdpuPriv_t)));
|
||||
MEM_CHECK(ret, p_hal->reg_ctx = mpp_calloc_size(void, sizeof(H264dVdpuRegCtx_t)));
|
||||
@@ -714,6 +713,7 @@ MPP_RET vdpu2_h264d_init(void *hal, MppHalCfg *cfg)
|
||||
mpp_slots_set_prop(p_hal->frame_slots, SLOTS_HOR_ALIGN, vdpu_hor_align);
|
||||
mpp_slots_set_prop(p_hal->frame_slots, SLOTS_VER_ALIGN, vdpu_ver_align);
|
||||
|
||||
(void)cfg;
|
||||
__RETURN:
|
||||
return MPP_OK;
|
||||
__FAILED:
|
||||
|
@@ -66,7 +66,7 @@ MPP_RET hal_h265d_init(void *ctx, MppHalCfg *cfg)
|
||||
|
||||
p->slots = cfg->frame_slots;
|
||||
p->int_cb = cfg->hal_int_cb;
|
||||
p->fast_mode = cfg->fast_mode;
|
||||
p->fast_mode = cfg->cfg->base.fast_parse;
|
||||
p->packet_slots = cfg->packet_slots;
|
||||
|
||||
mpp_env_get_u32("hal_h265d_debug", &hal_h265d_debug, 0);
|
||||
|
@@ -54,7 +54,7 @@ MPP_RET hal_vp9d_init(void *ctx, MppHalCfg *cfg)
|
||||
|
||||
p->slots = cfg->frame_slots;
|
||||
p->int_cb = cfg->hal_int_cb;
|
||||
p->fast_mode = cfg->fast_mode;
|
||||
p->fast_mode = cfg->cfg->base.fast_parse;
|
||||
p->packet_slots = cfg->packet_slots;
|
||||
|
||||
mpp_env_get_u32("hal_vp9d_debug", &hal_vp9d_debug, 0);
|
||||
|
@@ -1787,8 +1787,8 @@ MPP_RET hal_h265e_vepu22_init(void *hal, MppHalCfg *cfg)
|
||||
ctx->pre_buf = NULL;
|
||||
|
||||
/* pointer to cfg define in controller*/
|
||||
ctx->cfg = cfg->cfg;
|
||||
ctx->set = cfg->set;
|
||||
ctx->cfg = NULL; // NOTE: (MppEncCfgSet *) cfg->cfg;
|
||||
ctx->set = NULL; // NOTE: (MppEncCfgSet *) cfg->set;
|
||||
ctx->int_cb = cfg->hal_int_cb;
|
||||
ctx->option = H265E_SET_CFG_INIT;
|
||||
ctx->init = 0;
|
||||
|
@@ -166,6 +166,7 @@ private:
|
||||
RK_U32 mStatus;
|
||||
|
||||
/* decoder paramter before init */
|
||||
MppDecCfgSet mDecInitcfg;
|
||||
RK_U32 mParserFastMode;
|
||||
RK_U32 mParserNeedSplit;
|
||||
RK_U32 mParserInternalPts; /* for MPEG2/MPEG4 */
|
||||
|
53
mpp/mpp.cpp
53
mpp/mpp.cpp
@@ -17,6 +17,7 @@
|
||||
#define MODULE_TAG "mpp"
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "rk_mpi.h"
|
||||
|
||||
@@ -84,14 +85,12 @@ Mpp::Mpp()
|
||||
mInitDone(0),
|
||||
mMultiFrame(0),
|
||||
mStatus(0),
|
||||
mParserFastMode(0),
|
||||
mParserNeedSplit(0),
|
||||
mParserInternalPts(0),
|
||||
mImmediateOut(0),
|
||||
mExtraPacket(NULL),
|
||||
mDump(NULL)
|
||||
{
|
||||
mpp_env_get_u32("mpp_debug", &mpp_debug, 0);
|
||||
|
||||
memset(&mDecInitcfg, 0, sizeof(mDecInitcfg));
|
||||
mpp_dump_init(&mDump);
|
||||
}
|
||||
|
||||
@@ -138,13 +137,10 @@ MPP_RET Mpp::init(MppCtxType type, MppCodingType coding)
|
||||
mInputPort = mpp_task_queue_get_port(mInputTaskQueue, MPP_PORT_INPUT);
|
||||
mOutputPort = mpp_task_queue_get_port(mOutputTaskQueue, MPP_PORT_OUTPUT);
|
||||
|
||||
MppDecCfg cfg = {
|
||||
MppDecInitCfg cfg = {
|
||||
coding,
|
||||
mParserFastMode,
|
||||
mParserNeedSplit,
|
||||
mParserInternalPts,
|
||||
mImmediateOut,
|
||||
this,
|
||||
&mDecInitcfg,
|
||||
};
|
||||
|
||||
ret = mpp_dec_init(&mDec, &cfg);
|
||||
@@ -799,35 +795,34 @@ MPP_RET Mpp::control_dec(MpiCmd cmd, MppParam param)
|
||||
ret = mpp_dec_control(mDec, cmd, param);
|
||||
notify(MPP_DEC_NOTIFY_INFO_CHG_DONE | MPP_DEC_NOTIFY_BUFFER_MATCH);
|
||||
} break;
|
||||
case MPP_DEC_SET_PARSER_SPLIT_MODE: {
|
||||
RK_U32 flag = *((RK_U32 *)param);
|
||||
mParserNeedSplit = flag;
|
||||
ret = MPP_OK;
|
||||
} break;
|
||||
case MPP_DEC_SET_PARSER_FAST_MODE: {
|
||||
RK_U32 flag = *((RK_U32 *)param);
|
||||
mParserFastMode = flag;
|
||||
ret = MPP_OK;
|
||||
case MPP_DEC_SET_PRESENT_TIME_ORDER :
|
||||
case MPP_DEC_SET_PARSER_SPLIT_MODE :
|
||||
case MPP_DEC_SET_PARSER_FAST_MODE :
|
||||
case MPP_DEC_SET_IMMEDIATE_OUT :
|
||||
case MPP_DEC_SET_DISABLE_ERROR :
|
||||
case MPP_DEC_SET_ENABLE_DEINTERLACE : {
|
||||
/*
|
||||
* These control may be set before mpp_init
|
||||
* When this case happen record the config and wait for decoder init
|
||||
*/
|
||||
if (mDec) {
|
||||
ret = mpp_dec_control(mDec, cmd, param);
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = mpp_dec_set_cfg_by_cmd(&mDecInitcfg, cmd, param);
|
||||
} break;
|
||||
case MPP_DEC_GET_STREAM_COUNT: {
|
||||
AutoMutex autoLock(mPackets->mutex());
|
||||
*((RK_S32 *)param) = mPackets->list_size();
|
||||
ret = MPP_OK;
|
||||
} break;
|
||||
case MPP_DEC_SET_IMMEDIATE_OUT: {
|
||||
mImmediateOut = *((RK_U32 *)param);
|
||||
ret = MPP_OK;
|
||||
if (mDec)
|
||||
ret = mpp_dec_control(mDec, cmd, param);
|
||||
} break;
|
||||
case MPP_DEC_GET_VPUMEM_USED_COUNT :
|
||||
case MPP_DEC_SET_OUTPUT_FORMAT :
|
||||
case MPP_DEC_SET_DISABLE_ERROR:
|
||||
case MPP_DEC_SET_PRESENT_TIME_ORDER:
|
||||
case MPP_DEC_SET_ENABLE_DEINTERLACE:
|
||||
case MPP_DEC_QUERY: {
|
||||
case MPP_DEC_QUERY :
|
||||
case MPP_DEC_SET_CFG : {
|
||||
ret = mpp_dec_control(mDec, cmd, param);
|
||||
}
|
||||
} break;
|
||||
default : {
|
||||
} break;
|
||||
}
|
||||
|
Reference in New Issue
Block a user