[dummy_dec]: add sample buffer slot operation to dummy_dec, dec part is ok, but buffer release has error

[buf_slot]: fix initialization error

git-svn-id: https://10.10.10.66:8443/svn/MediaProcessPlatform/trunk/mpp@224 6e48237b-75ef-9749-8fc9-41990f28c85a
This commit is contained in:
ChenHengming
2015-09-06 21:29:28 +00:00
parent 4145133673
commit 6ac0a7cb50
3 changed files with 87 additions and 30 deletions

View File

@@ -16,58 +16,121 @@
*/ */
#define MODULE_TAG "dummy_dec_api" #define MODULE_TAG "dummy_dec_api"
#include <string.h>
#include "mpp_log.h"
#include "dummy_dec_api.h" #include "dummy_dec_api.h"
#define DUMMY_DEC_FRAME_SIZE SZ_1M
#define DUMMY_DEC_FRAME_COUNT 16
MPP_RET dummy_dec_init(void *decoder, MppParserInitCfg *init) typedef struct DummyDec_t {
MppBufSlots slots;
RK_U32 task_count;
RK_U32 slots_inited;
} DummyDec;
MPP_RET dummy_dec_init(void *dec, MppParserInitCfg *cfg)
{ {
(void)decoder; if (NULL == dec) {
(void)init; mpp_err_f("found NULL intput dec %p cfg %p\n", dec, cfg);
return MPP_ERR_NULL_PTR;
}
DummyDec *p = (DummyDec *)dec;
p->slots = cfg->slots;
p->task_count = cfg->task_count = 2;
p->slots_inited = 0;
return MPP_OK; return MPP_OK;
} }
MPP_RET dummy_dec_deinit(void *decoder) MPP_RET dummy_dec_deinit(void *dec)
{ {
(void)decoder; if (NULL == dec) {
mpp_err_f("found NULL intput\n");
return MPP_ERR_NULL_PTR;
}
return MPP_OK; return MPP_OK;
} }
MPP_RET dummy_dec_reset(void *decoder) MPP_RET dummy_dec_reset(void *dec)
{ {
(void)decoder; if (NULL == dec) {
mpp_err_f("found NULL intput\n");
return MPP_ERR_NULL_PTR;
}
return MPP_OK; return MPP_OK;
} }
MPP_RET dummy_dec_flush(void *decoder) MPP_RET dummy_dec_flush(void *dec)
{ {
(void)decoder; if (NULL == dec) {
mpp_err_f("found NULL intput\n");
return MPP_ERR_NULL_PTR;
}
return MPP_OK; return MPP_OK;
} }
MPP_RET dummy_dec_control(void *decoder, RK_S32 cmd_type, void *param) MPP_RET dummy_dec_control(void *dec, RK_S32 cmd_type, void *param)
{ {
(void)decoder; if (NULL == dec) {
mpp_err_f("found NULL intput\n");
return MPP_ERR_NULL_PTR;
}
(void)cmd_type; (void)cmd_type;
(void)param; (void)param;
return MPP_OK; return MPP_OK;
} }
MPP_RET dummy_dec_parse(void *decoder, MppPacket pkt, HalDecTask *task) MPP_RET dummy_dec_parse(void *dec, MppPacket pkt, HalDecTask *task)
{ {
(void)decoder; if (NULL == dec) {
(void)pkt; mpp_err_f("found NULL intput\n");
(void)task; return MPP_ERR_NULL_PTR;
}
DummyDec *p = (DummyDec *)dec;
// do packet decoding here
// set packet size
mpp_packet_set_size(pkt, 0);
/*
* set slots information
* 1. output index MUST be set
* 2. if one frame can be display, it SHOULD be set display
*/
if (!p->slots_inited) {
mpp_buf_slot_setup(p->slots, DUMMY_DEC_FRAME_COUNT, DUMMY_DEC_FRAME_SIZE, 0);
p->slots_inited = 1;
}
RK_S32 output = -1;
mpp_buf_slot_get_unused(p->slots, &output);
mpp_buf_slot_set_display(p->slots, output);
/*
* setup output task
* 1. valid flag MUST be set if need hardware to run once
* 2. set output slot index
* 3. set reference slot index
*/
task->valid = 1;
task->output = output;
memset(&task->refer, -1, sizeof(task->refer));
return MPP_OK; return MPP_OK;
} }
const MppDecParser dummy_dec_parser = { const MppDecParser dummy_dec_parser = {
"dummy_dec_parser", "dummy_dec_parser",
MPP_VIDEO_CodingUnused, MPP_VIDEO_CodingUnused,
0, sizeof(DummyDec),
0, 0,
dummy_dec_init, dummy_dec_init,
dummy_dec_deinit, dummy_dec_deinit,

View File

@@ -25,12 +25,12 @@ extern "C" {
extern const MppDecParser dummy_dec_parser; extern const MppDecParser dummy_dec_parser;
MPP_RET dummy_dec_init (void *decoder, MppParserInitCfg *cfg); MPP_RET dummy_dec_init (void *dec, MppParserInitCfg *cfg);
MPP_RET dummy_dec_deinit (void *decoder); MPP_RET dummy_dec_deinit (void *dec);
MPP_RET dummy_dec_reset (void *decoder); MPP_RET dummy_dec_reset (void *dec);
MPP_RET dummy_dec_flush (void *decoder); MPP_RET dummy_dec_flush (void *dec);
MPP_RET dummy_dec_control(void *decoder, RK_S32 cmd_type, void *param); MPP_RET dummy_dec_control(void *dec, RK_S32 cmd_type, void *param);
MPP_RET dummy_dec_parse (void *decoder, MppPacket pkt, HalDecTask *task); MPP_RET dummy_dec_parse (void *dec, MppPacket pkt, HalDecTask *task);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@@ -70,17 +70,13 @@ MPP_RET mpp_buf_slot_init(MppBufSlots *slots)
mpp_err_f("found NULL input\n"); mpp_err_f("found NULL input\n");
return MPP_ERR_NULL_PTR; return MPP_ERR_NULL_PTR;
} }
MppBufSlotsImpl *impl = mpp_malloc(MppBufSlotsImpl, 1); MppBufSlotsImpl *impl = mpp_calloc(MppBufSlotsImpl, 1);
if (NULL == impl) { if (NULL == impl) {
*slots = NULL; *slots = NULL;
return MPP_NOK; return MPP_NOK;
} }
impl->lock = new Mutex(); impl->lock = new Mutex();
impl->count = 0;
impl->decode_count = 0;
impl->display_count = 0;
impl->slots = NULL;
*slots = impl; *slots = impl;
return MPP_OK; return MPP_OK;
} }
@@ -113,8 +109,6 @@ MPP_RET mpp_buf_slot_setup(MppBufSlots slots, RK_U32 count, RK_U32 size, RK_U32
impl->slots = mpp_calloc(MppBufSlotEntry, count); impl->slots = mpp_calloc(MppBufSlotEntry, count);
impl->count = count; impl->count = count;
impl->size = size; impl->size = size;
impl->slots = (MppBufSlotEntry *)(impl + 1);
memset(impl->slots, 0, sizeof(MppBufSlotEntry) * count);
} else { } else {
// need to check info change or not // need to check info change or not
if (!changed) { if (!changed) {
@@ -183,7 +177,7 @@ RK_U32 mpp_buf_slot_get_size(MppBufSlots slots)
MPP_RET mpp_buf_slot_get_unused(MppBufSlots slots, RK_U32 *index) MPP_RET mpp_buf_slot_get_unused(MppBufSlots slots, RK_U32 *index)
{ {
if (NULL == slots) { if (NULL == slots || NULL == index) {
mpp_err_f("found NULL input\n"); mpp_err_f("found NULL input\n");
return MPP_ERR_NULL_PTR; return MPP_ERR_NULL_PTR;
} }