mirror of
https://github.com/nyanmisaka/mpp.git
synced 2025-10-11 03:50:03 +08:00
[mpp_dec]: add packet slot to mpp_dec
git-svn-id: https://10.10.10.66:8443/svn/MediaProcessPlatform/trunk/mpp@310 6e48237b-75ef-9749-8fc9-41990f28c85a
This commit is contained in:
@@ -27,7 +27,8 @@
|
|||||||
#define DUMMY_DEC_REF_COUNT 2
|
#define DUMMY_DEC_REF_COUNT 2
|
||||||
|
|
||||||
typedef struct DummyDec_t {
|
typedef struct DummyDec_t {
|
||||||
MppBufSlots slots;
|
MppBufSlots frame_slots;
|
||||||
|
MppBufSlots packet_slots;
|
||||||
RK_U32 task_count;
|
RK_U32 task_count;
|
||||||
|
|
||||||
RK_U32 slots_inited;
|
RK_U32 slots_inited;
|
||||||
@@ -46,7 +47,8 @@ MPP_RET dummy_dec_init(void *dec, ParserCfg *cfg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
p = (DummyDec *)dec;
|
p = (DummyDec *)dec;
|
||||||
p->slots = cfg->slots;
|
p->frame_slots = cfg->frame_slots;
|
||||||
|
p->packet_slots = cfg->packet_slots;
|
||||||
p->task_count = cfg->task_count = 2;
|
p->task_count = cfg->task_count = 2;
|
||||||
p->slots_inited = 0;
|
p->slots_inited = 0;
|
||||||
p->frame_count = 0;
|
p->frame_count = 0;
|
||||||
@@ -114,7 +116,7 @@ MPP_RET dummy_dec_prepare(void *dec, MppPacket pkt, HalDecTask *task)
|
|||||||
p = (DummyDec *)dec;
|
p = (DummyDec *)dec;
|
||||||
// do packet decoding here
|
// do packet decoding here
|
||||||
|
|
||||||
slots = p->slots;
|
slots = p->frame_slots;
|
||||||
frame_count = p->frame_count;
|
frame_count = p->frame_count;
|
||||||
|
|
||||||
// set pos to indicate that buffer is done
|
// set pos to indicate that buffer is done
|
||||||
|
@@ -1692,7 +1692,7 @@ MPP_RET h265d_init(void *ctx, ParserCfg *parser_cfg)
|
|||||||
|
|
||||||
s->picture_struct = 0;
|
s->picture_struct = 0;
|
||||||
|
|
||||||
s->slots = parser_cfg->slots;
|
s->slots = parser_cfg->frame_slots;
|
||||||
|
|
||||||
|
|
||||||
if (h265dctx->extradata_size > 0 && h265dctx->extradata) {
|
if (h265dctx->extradata_size > 0 && h265dctx->extradata) {
|
||||||
|
@@ -354,8 +354,8 @@ RK_S32 hevc_parser_test(ParserDemoCmdContext_t *cmd)
|
|||||||
mpp_buffer_get(mStreamGroup, ¤tstrem, 1024 * 1024);
|
mpp_buffer_get(mStreamGroup, ¤tstrem, 1024 * 1024);
|
||||||
mpp_buffer_get(mStreamGroup, &prestrem, 2 * 1024 * 1024);
|
mpp_buffer_get(mStreamGroup, &prestrem, 2 * 1024 * 1024);
|
||||||
|
|
||||||
parser_cfg.slots = slots;
|
parser_cfg.frame_slots = slots;
|
||||||
hal_cfg.slots = slots;
|
hal_cfg.frame_slots = slots;
|
||||||
h265d_init(mpp_codex_ctx, &parser_cfg);
|
h265d_init(mpp_codex_ctx, &parser_cfg);
|
||||||
hal_h265d_init(hal, &hal_cfg);
|
hal_h265d_init(hal, &hal_cfg);
|
||||||
mpp_log("mallc out \n");
|
mpp_log("mallc out \n");
|
||||||
|
@@ -196,6 +196,13 @@ MPP_RET mpp_buf_slot_set_buffer(MppBufSlots slots, RK_U32 index, MppBuffer b
|
|||||||
MppBuffer mpp_buf_slot_get_buffer(MppBufSlots slots, RK_U32 index);
|
MppBuffer mpp_buf_slot_get_buffer(MppBufSlots slots, RK_U32 index);
|
||||||
MPP_RET mpp_buf_slot_get_display(MppBufSlots slots, MppFrame *frame);
|
MPP_RET mpp_buf_slot_get_display(MppBufSlots slots, MppFrame *frame);
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* NOTE:
|
||||||
|
* buffer slot will be used both for frame and packet
|
||||||
|
* when buffer slot is used for packet management only inc_hw_ref and dec_hw_ref is used
|
||||||
|
*/
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@@ -31,7 +31,8 @@ struct MppDec_t {
|
|||||||
MppHal hal;
|
MppHal hal;
|
||||||
|
|
||||||
// common resource
|
// common resource
|
||||||
MppBufSlots slots;
|
MppBufSlots frame_slots;
|
||||||
|
MppBufSlots packet_slots;
|
||||||
HalTaskGroup tasks;
|
HalTaskGroup tasks;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -31,7 +31,8 @@
|
|||||||
typedef struct DecParserInitCfg_t {
|
typedef struct DecParserInitCfg_t {
|
||||||
// input
|
// input
|
||||||
MppCodingType coding;
|
MppCodingType coding;
|
||||||
MppBufSlots slots;
|
MppBufSlots frame_slots;
|
||||||
|
MppBufSlots packet_slots;
|
||||||
|
|
||||||
// output
|
// output
|
||||||
RK_U32 task_count;
|
RK_U32 task_count;
|
||||||
|
@@ -32,9 +32,9 @@ void *mpp_dec_parser_thread(void *data)
|
|||||||
Mpp *mpp = (Mpp*)data;
|
Mpp *mpp = (Mpp*)data;
|
||||||
MppThread *parser = mpp->mThreadCodec;
|
MppThread *parser = mpp->mThreadCodec;
|
||||||
MppDec *dec = mpp->mDec;
|
MppDec *dec = mpp->mDec;
|
||||||
MppBufSlots slots = dec->slots;
|
|
||||||
HalTaskGroup tasks = dec->tasks;
|
HalTaskGroup tasks = dec->tasks;
|
||||||
MppPacket packet = NULL;
|
MppPacket packet = NULL;
|
||||||
|
MppBufSlots frame_slots = dec->frame_slots;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* parser thread need to wait at cases below:
|
* parser thread need to wait at cases below:
|
||||||
@@ -117,6 +117,7 @@ void *mpp_dec_parser_thread(void *data)
|
|||||||
task_ready = task_dec->valid;
|
task_ready = task_dec->valid;
|
||||||
if (!task_ready)
|
if (!task_ready)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
parser_parse(dec->parser, task_dec);
|
parser_parse(dec->parser, task_dec);
|
||||||
/*
|
/*
|
||||||
* 4. parse local task and slot to check whether new buffer or info change is needed.
|
* 4. parse local task and slot to check whether new buffer or info change is needed.
|
||||||
@@ -124,7 +125,7 @@ void *mpp_dec_parser_thread(void *data)
|
|||||||
* a. first detect info change
|
* a. first detect info change
|
||||||
* b. then detect whether output index has MppBuffer
|
* b. then detect whether output index has MppBuffer
|
||||||
*/
|
*/
|
||||||
wait_on_change = mpp_buf_slot_is_changed(slots);
|
wait_on_change = mpp_buf_slot_is_changed(frame_slots);
|
||||||
if (wait_on_change)
|
if (wait_on_change)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@@ -141,16 +142,16 @@ void *mpp_dec_parser_thread(void *data)
|
|||||||
* frame to hal loop.
|
* frame to hal loop.
|
||||||
*/
|
*/
|
||||||
RK_U32 output;
|
RK_U32 output;
|
||||||
mpp_buf_slot_get_hw_dst(slots, &output);
|
mpp_buf_slot_get_hw_dst(frame_slots, &output);
|
||||||
if (NULL == mpp_buf_slot_get_buffer(slots, output)) {
|
if (NULL == mpp_buf_slot_get_buffer(frame_slots, output)) {
|
||||||
MppBuffer buffer = NULL;
|
MppBuffer buffer = NULL;
|
||||||
RK_U32 size = mpp_buf_slot_get_size(slots);
|
RK_U32 size = mpp_buf_slot_get_size(frame_slots);
|
||||||
mpp_buffer_get(mpp->mFrameGroup, &buffer, size);
|
mpp_buffer_get(mpp->mFrameGroup, &buffer, size);
|
||||||
if (buffer)
|
if (buffer)
|
||||||
mpp_buf_slot_set_buffer(slots, output, buffer);
|
mpp_buf_slot_set_buffer(frame_slots, output, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
wait_on_buffer = (NULL == mpp_buf_slot_get_buffer(slots, output));
|
wait_on_buffer = (NULL == mpp_buf_slot_get_buffer(frame_slots, output));
|
||||||
if (wait_on_buffer)
|
if (wait_on_buffer)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@@ -173,9 +174,9 @@ void *mpp_dec_hal_thread(void *data)
|
|||||||
Mpp *mpp = (Mpp*)data;
|
Mpp *mpp = (Mpp*)data;
|
||||||
MppThread *hal = mpp->mThreadHal;
|
MppThread *hal = mpp->mThreadHal;
|
||||||
MppDec *dec = mpp->mDec;
|
MppDec *dec = mpp->mDec;
|
||||||
MppBufSlots slots = dec->slots;
|
|
||||||
HalTaskGroup tasks = dec->tasks;
|
HalTaskGroup tasks = dec->tasks;
|
||||||
mpp_list *frames = mpp->mFrames;
|
mpp_list *frames = mpp->mFrames;
|
||||||
|
MppBufSlots frame_slots = dec->frame_slots;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* hal thread need to wait at cases below:
|
* hal thread need to wait at cases below:
|
||||||
@@ -229,15 +230,15 @@ void *mpp_dec_hal_thread(void *data)
|
|||||||
* 3. add frame to output list
|
* 3. add frame to output list
|
||||||
* repeat 2 and 3 until not frame can be output
|
* repeat 2 and 3 until not frame can be output
|
||||||
*/
|
*/
|
||||||
mpp_buf_slot_clr_hw_dst(slots, task_dec->output);
|
mpp_buf_slot_clr_hw_dst(frame_slots, task_dec->output);
|
||||||
for (RK_U32 i = 0; i < MPP_ARRAY_ELEMS(task_dec->refer); i++) {
|
for (RK_U32 i = 0; i < MPP_ARRAY_ELEMS(task_dec->refer); i++) {
|
||||||
RK_S32 index = task_dec->refer[i];
|
RK_S32 index = task_dec->refer[i];
|
||||||
if (index >= 0)
|
if (index >= 0)
|
||||||
mpp_buf_slot_dec_hw_ref(slots, index);
|
mpp_buf_slot_dec_hw_ref(frame_slots, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
MppFrame frame = NULL;
|
MppFrame frame = NULL;
|
||||||
while (MPP_OK == mpp_buf_slot_get_display(slots, &frame)) {
|
while (MPP_OK == mpp_buf_slot_get_display(frame_slots, &frame)) {
|
||||||
frames->lock();
|
frames->lock();
|
||||||
frames->add_at_tail(&frame, sizeof(frame));
|
frames->add_at_tail(&frame, sizeof(frame));
|
||||||
mpp->mFramePutCount++;
|
mpp->mFramePutCount++;
|
||||||
@@ -252,7 +253,8 @@ void *mpp_dec_hal_thread(void *data)
|
|||||||
MPP_RET mpp_dec_init(MppDec **dec, MppCodingType coding)
|
MPP_RET mpp_dec_init(MppDec **dec, MppCodingType coding)
|
||||||
{
|
{
|
||||||
MPP_RET ret;
|
MPP_RET ret;
|
||||||
MppBufSlots slots = NULL;
|
MppBufSlots frame_slots = NULL;
|
||||||
|
MppBufSlots packet_slots = NULL;
|
||||||
Parser parser = NULL;
|
Parser parser = NULL;
|
||||||
MppHal hal = NULL;
|
MppHal hal = NULL;
|
||||||
|
|
||||||
@@ -263,15 +265,22 @@ MPP_RET mpp_dec_init(MppDec **dec, MppCodingType coding)
|
|||||||
}
|
}
|
||||||
|
|
||||||
do {
|
do {
|
||||||
ret = mpp_buf_slot_init(&slots);
|
ret = mpp_buf_slot_init(&frame_slots);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
mpp_err_f("could not init buffer slot\n");
|
mpp_err_f("could not init frame buffer slot\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = mpp_buf_slot_init(&packet_slots);
|
||||||
|
if (ret) {
|
||||||
|
mpp_err_f("could not init packet buffer slot\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
ParserCfg parser_cfg = {
|
ParserCfg parser_cfg = {
|
||||||
coding,
|
coding,
|
||||||
slots,
|
frame_slots,
|
||||||
|
packet_slots,
|
||||||
2,
|
2,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -286,7 +295,8 @@ MPP_RET mpp_dec_init(MppDec **dec, MppCodingType coding)
|
|||||||
MPP_CTX_DEC,
|
MPP_CTX_DEC,
|
||||||
coding,
|
coding,
|
||||||
HAL_MODE_LIBVPU,
|
HAL_MODE_LIBVPU,
|
||||||
p->slots,
|
frame_slots,
|
||||||
|
packet_slots,
|
||||||
NULL,
|
NULL,
|
||||||
parser_cfg.task_count,
|
parser_cfg.task_count,
|
||||||
};
|
};
|
||||||
@@ -300,8 +310,9 @@ MPP_RET mpp_dec_init(MppDec **dec, MppCodingType coding)
|
|||||||
p->coding = coding;
|
p->coding = coding;
|
||||||
p->parser = parser;
|
p->parser = parser;
|
||||||
p->hal = hal;
|
p->hal = hal;
|
||||||
p->slots = slots;
|
|
||||||
p->tasks = hal_cfg.tasks;
|
p->tasks = hal_cfg.tasks;
|
||||||
|
p->frame_slots = frame_slots;
|
||||||
|
p->packet_slots = packet_slots;
|
||||||
*dec = p;
|
*dec = p;
|
||||||
return MPP_OK;
|
return MPP_OK;
|
||||||
} while (0);
|
} while (0);
|
||||||
@@ -328,9 +339,14 @@ MPP_RET mpp_dec_deinit(MppDec *dec)
|
|||||||
dec->hal = NULL;
|
dec->hal = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dec->slots) {
|
if (dec->frame_slots) {
|
||||||
mpp_buf_slot_deinit(dec->slots);
|
mpp_buf_slot_deinit(dec->frame_slots);
|
||||||
dec->slots = NULL;
|
dec->frame_slots = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dec->packet_slots) {
|
||||||
|
mpp_buf_slot_deinit(dec->packet_slots);
|
||||||
|
dec->packet_slots = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
mpp_free(dec);
|
mpp_free(dec);
|
||||||
|
@@ -25,8 +25,6 @@
|
|||||||
#include "mpp_packet.h"
|
#include "mpp_packet.h"
|
||||||
#include "mpp_packet_impl.h"
|
#include "mpp_packet_impl.h"
|
||||||
|
|
||||||
#define MPP_TEST_FRAME_SIZE SZ_1M
|
|
||||||
|
|
||||||
void *mpp_enc_control_thread(void *data)
|
void *mpp_enc_control_thread(void *data)
|
||||||
{
|
{
|
||||||
Mpp *mpp = (Mpp*)data;
|
Mpp *mpp = (Mpp*)data;
|
||||||
@@ -100,7 +98,7 @@ void *mpp_enc_hal_thread(void *data)
|
|||||||
|
|
||||||
// for test
|
// for test
|
||||||
MppBuffer buffer;
|
MppBuffer buffer;
|
||||||
mpp_buffer_get(mpp->mFrameGroup, &buffer, MPP_TEST_FRAME_SIZE);
|
mpp_buffer_get(mpp->mFrameGroup, &buffer, SZ_1M);
|
||||||
|
|
||||||
MppFrame frame;
|
MppFrame frame;
|
||||||
mpp_frame_init(&frame);
|
mpp_frame_init(&frame);
|
||||||
|
@@ -34,7 +34,8 @@ typedef struct MppHalCfg_t {
|
|||||||
MppCtxType type;
|
MppCtxType type;
|
||||||
MppCodingType coding;
|
MppCodingType coding;
|
||||||
HalWorkMode mode;
|
HalWorkMode mode;
|
||||||
MppBufSlots slots;
|
MppBufSlots frame_slots;
|
||||||
|
MppBufSlots packet_slots;
|
||||||
|
|
||||||
// output
|
// output
|
||||||
HalTaskGroup tasks;
|
HalTaskGroup tasks;
|
||||||
|
@@ -44,7 +44,8 @@ static const MppHalApi *hw_apis[] = {
|
|||||||
typedef struct MppHalImpl_t {
|
typedef struct MppHalImpl_t {
|
||||||
MppCtxType type;
|
MppCtxType type;
|
||||||
MppCodingType coding;
|
MppCodingType coding;
|
||||||
MppBufSlots slots;
|
MppBufSlots frame_slots;
|
||||||
|
MppBufSlots packet_slots;
|
||||||
|
|
||||||
void *ctx;
|
void *ctx;
|
||||||
const MppHalApi *api;
|
const MppHalApi *api;
|
||||||
@@ -75,7 +76,8 @@ MPP_RET mpp_hal_init(MppHal *ctx, MppHalCfg *cfg)
|
|||||||
mpp_assert(cfg->task_count > 0);
|
mpp_assert(cfg->task_count > 0);
|
||||||
p->type = cfg->type;
|
p->type = cfg->type;
|
||||||
p->coding = cfg->coding;
|
p->coding = cfg->coding;
|
||||||
p->slots = cfg->slots;
|
p->frame_slots = cfg->frame_slots;
|
||||||
|
p->packet_slots = cfg->packet_slots;
|
||||||
p->api = hw_apis[i];
|
p->api = hw_apis[i];
|
||||||
p->task_count = cfg->task_count;
|
p->task_count = cfg->task_count;
|
||||||
p->ctx = mpp_calloc_size(void, p->api->ctx_size);
|
p->ctx = mpp_calloc_size(void, p->api->ctx_size);
|
||||||
|
@@ -255,7 +255,7 @@ MPP_RET hal_h265d_init(void *hal, MppHalCfg *cfg)
|
|||||||
return MPP_ERR_UNKNOW;
|
return MPP_ERR_UNKNOW;
|
||||||
}
|
}
|
||||||
|
|
||||||
reg_cxt->slots = cfg->slots;
|
reg_cxt->slots = cfg->frame_slots;
|
||||||
|
|
||||||
///<- VPUClientInit
|
///<- VPUClientInit
|
||||||
#ifdef ANDROID
|
#ifdef ANDROID
|
||||||
|
@@ -30,6 +30,7 @@
|
|||||||
#include "mpp_packet_impl.h"
|
#include "mpp_packet_impl.h"
|
||||||
|
|
||||||
#define MPP_TEST_FRAME_SIZE SZ_1M
|
#define MPP_TEST_FRAME_SIZE SZ_1M
|
||||||
|
#define MPP_TEST_PACKET_SIZE SZ_512K
|
||||||
|
|
||||||
RK_U32 mpp_debug = 0;
|
RK_U32 mpp_debug = 0;
|
||||||
|
|
||||||
@@ -65,7 +66,10 @@ Mpp::Mpp(MppCtxType type, MppCodingType coding)
|
|||||||
mThreadHal = new MppThread(mpp_dec_hal_thread, this);
|
mThreadHal = new MppThread(mpp_dec_hal_thread, this);
|
||||||
|
|
||||||
mpp_buffer_group_normal_get(&mInternalGroup, MPP_BUFFER_TYPE_ION);
|
mpp_buffer_group_normal_get(&mInternalGroup, MPP_BUFFER_TYPE_ION);
|
||||||
mpp_buffer_group_normal_get(&mPacketGroup, MPP_BUFFER_TYPE_NORMAL);
|
|
||||||
|
mpp_buffer_group_limited_get(&mPacketGroup, MPP_BUFFER_TYPE_ION);
|
||||||
|
mpp_buffer_group_limit_config(mPacketGroup, MPP_TEST_PACKET_SIZE, 4);
|
||||||
|
|
||||||
mpp_buffer_group_limited_get(&mFrameGroup, MPP_BUFFER_TYPE_ION);
|
mpp_buffer_group_limited_get(&mFrameGroup, MPP_BUFFER_TYPE_ION);
|
||||||
mpp_buffer_group_limit_config(mFrameGroup, MPP_TEST_FRAME_SIZE, 4);
|
mpp_buffer_group_limit_config(mFrameGroup, MPP_TEST_FRAME_SIZE, 4);
|
||||||
} break;
|
} break;
|
||||||
|
@@ -57,9 +57,9 @@ static MPP_RET manual_set_env(void)
|
|||||||
static MPP_RET decoder_deinit(MppDec *pApi)
|
static MPP_RET decoder_deinit(MppDec *pApi)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (pApi->slots) {
|
if (pApi->frame_slots) {
|
||||||
mpp_buf_slot_deinit(pApi->slots);
|
mpp_buf_slot_deinit(pApi->frame_slots);
|
||||||
pApi->slots = NULL;
|
pApi->frame_slots = NULL;
|
||||||
}
|
}
|
||||||
if (pApi->parser) {
|
if (pApi->parser) {
|
||||||
parser_deinit(pApi->parser);
|
parser_deinit(pApi->parser);
|
||||||
@@ -81,13 +81,13 @@ static MPP_RET decoder_init(MppDec *pApi)
|
|||||||
MppCodingType coding = MPP_VIDEO_CodingAVC;
|
MppCodingType coding = MPP_VIDEO_CodingAVC;
|
||||||
|
|
||||||
// malloc slot
|
// malloc slot
|
||||||
FUN_CHECK(ret = mpp_buf_slot_init(&pApi->slots));
|
FUN_CHECK(ret = mpp_buf_slot_init(&pApi->frame_slots));
|
||||||
MEM_CHECK(ret, pApi->slots);
|
MEM_CHECK(ret, pApi->frame_slots);
|
||||||
|
|
||||||
// init parser part
|
// init parser part
|
||||||
memset(&parser_cfg, 0, sizeof(parser_cfg));
|
memset(&parser_cfg, 0, sizeof(parser_cfg));
|
||||||
parser_cfg.coding = coding;
|
parser_cfg.coding = coding;
|
||||||
parser_cfg.slots = pApi->slots;
|
parser_cfg.frame_slots = pApi->frame_slots;
|
||||||
FUN_CHECK(ret = parser_init(&pApi->parser, &parser_cfg));
|
FUN_CHECK(ret = parser_init(&pApi->parser, &parser_cfg));
|
||||||
|
|
||||||
// init hal part
|
// init hal part
|
||||||
|
Reference in New Issue
Block a user