mirror of
https://github.com/nyanmisaka/mpp.git
synced 2025-10-10 19:40:03 +08:00
[hal_task]: change task mechanism to status
git-svn-id: https://10.10.10.66:8443/svn/MediaProcessPlatform/trunk/mpp@313 6e48237b-75ef-9749-8fc9-41990f28c85a
This commit is contained in:
@@ -252,7 +252,7 @@ RK_S32 get_next_nal(FILE* inpf, unsigned char* Buf)
|
||||
|
||||
static RK_S32 poll_task(void *hal, MppBufSlots slots, HalDecTask *dec)
|
||||
{
|
||||
HalTask syn;
|
||||
HalTaskInfo syn;
|
||||
RK_U32 i;
|
||||
syn.dec = *dec;
|
||||
hal_h265d_wait(hal, &syn);
|
||||
@@ -393,7 +393,7 @@ RK_S32 hevc_parser_test(ParserDemoCmdContext_t *cmd)
|
||||
h265d_parse(mpp_codex_ctx, cutask);
|
||||
}
|
||||
if (cutask->valid) {
|
||||
HalTask syn;
|
||||
HalTaskInfo syn;
|
||||
syn.dec = *cutask;
|
||||
mpp_buf_slot_get_hw_dst(slots, &index);
|
||||
|
||||
|
@@ -43,15 +43,18 @@ void *mpp_dec_parser_thread(void *data)
|
||||
* 3. info change on progress
|
||||
* 3. no buffer on analyzing output task
|
||||
*/
|
||||
RK_U32 wait_on_task_hnd = 0;
|
||||
RK_U32 wait_on_packet = 0;
|
||||
RK_U32 wait_on_task = 0;
|
||||
RK_U32 wait_on_prev = 0;
|
||||
RK_U32 wait_on_change = 0;
|
||||
RK_U32 wait_on_buffer = 0;
|
||||
|
||||
RK_U32 packet_ready = 0;
|
||||
RK_U32 task_ready = 0;
|
||||
RK_U32 prev_task_done = 1;
|
||||
RK_U32 curr_task_ready = 0;
|
||||
RK_U32 curr_task_parsed = 0;
|
||||
|
||||
HalTask task_local;
|
||||
HalTaskHnd task = NULL;
|
||||
HalTaskInfo task_local;
|
||||
HalDecTask *task_dec = &task_local.dec;
|
||||
|
||||
while (MPP_THREAD_RUNNING == parser->get_status()) {
|
||||
@@ -59,21 +62,28 @@ void *mpp_dec_parser_thread(void *data)
|
||||
* wait for stream input
|
||||
*/
|
||||
parser->lock();
|
||||
if (wait_on_task || wait_on_packet || wait_on_change || wait_on_buffer)
|
||||
if (wait_on_task_hnd || wait_on_packet ||
|
||||
wait_on_prev || wait_on_change || wait_on_buffer)
|
||||
parser->wait();
|
||||
parser->unlock();
|
||||
|
||||
/*
|
||||
* 1. get task handle from hal for parsing one frame
|
||||
*/
|
||||
wait_on_task = (MPP_OK != hal_task_can_put(tasks));
|
||||
if (wait_on_task)
|
||||
if (!task) {
|
||||
hal_task_get_hnd(tasks, TASK_IDLE, &task);
|
||||
if (task) {
|
||||
wait_on_task_hnd = 0;
|
||||
} else {
|
||||
wait_on_task_hnd = 1;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 2. get packet to parse
|
||||
*/
|
||||
if (!packet_ready) {
|
||||
if (!packet) {
|
||||
mpp_list *packets = mpp->mPackets;
|
||||
Mutex::Autolock autoLock(packets->mutex());
|
||||
if (packets->list_size()) {
|
||||
@@ -82,7 +92,6 @@ void *mpp_dec_parser_thread(void *data)
|
||||
*/
|
||||
packets->del_at_head(&packet, sizeof(packet));
|
||||
mpp->mPacketGetCount++;
|
||||
packet_ready = 1;
|
||||
wait_on_packet = 0;
|
||||
} else {
|
||||
wait_on_packet = 1;
|
||||
@@ -104,21 +113,37 @@ void *mpp_dec_parser_thread(void *data)
|
||||
* 3. if packet size is zero then next packet is needed.
|
||||
*
|
||||
*/
|
||||
if (!task_ready) {
|
||||
hal_task_init(&task_local, MPP_CTX_DEC);
|
||||
if (!curr_task_ready) {
|
||||
hal_task_info_init(&task_local, MPP_CTX_DEC);
|
||||
parser_prepare(dec->parser, packet, task_dec);
|
||||
if (0 == mpp_packet_get_length(packet)) {
|
||||
mpp_free(mpp_packet_get_data(packet));
|
||||
mpp_packet_deinit(&packet);
|
||||
packet_ready = 0;
|
||||
packet = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
task_ready = task_dec->valid;
|
||||
if (!task_ready)
|
||||
curr_task_ready = task_dec->valid;
|
||||
if (!curr_task_ready)
|
||||
continue;
|
||||
|
||||
// wait previous task done
|
||||
if (!prev_task_done) {
|
||||
HalTaskHnd task_prev = NULL;
|
||||
hal_task_get_hnd(tasks, TASK_PROC_DONE, &task_prev);
|
||||
if (task_prev) {
|
||||
prev_task_done = 1;
|
||||
hal_task_hnd_set_status(task_prev, TASK_IDLE);
|
||||
task_prev = NULL;
|
||||
} else {
|
||||
wait_on_prev = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (!curr_task_parsed) {
|
||||
parser_parse(dec->parser, task_dec);
|
||||
curr_task_parsed = 1;
|
||||
}
|
||||
/*
|
||||
* 4. parse local task and slot to check whether new buffer or info change is needed.
|
||||
*
|
||||
@@ -155,15 +180,34 @@ void *mpp_dec_parser_thread(void *data)
|
||||
if (wait_on_buffer)
|
||||
continue;
|
||||
|
||||
// register genertation
|
||||
mpp_hal_reg_gen(dec->hal, &task_local);
|
||||
|
||||
/*
|
||||
* wait previous register set done
|
||||
*/
|
||||
//mpp_hal_hw_wait(dec->hal_ctx, &task_local);
|
||||
|
||||
/*
|
||||
* send current register set to hardware
|
||||
*/
|
||||
//mpp_hal_hw_start(dec->hal_ctx, &task_local);
|
||||
|
||||
mpp_hal_hw_start(dec->hal, &task_local);
|
||||
|
||||
/*
|
||||
* 6. send dxva output information and buffer information to hal thread
|
||||
* combinate video codec dxva output and buffer information
|
||||
*/
|
||||
hal_task_put(tasks, &task_local);
|
||||
mpp->mTaskPutCount++;
|
||||
|
||||
task_ready = 0;
|
||||
hal_task_hnd_set_info(task, &task_local);
|
||||
hal_task_hnd_set_status(task, TASK_PROCESSING);
|
||||
mpp->mThreadHal->signal();
|
||||
|
||||
mpp->mTaskPutCount++;
|
||||
task = NULL;
|
||||
curr_task_ready = 0;
|
||||
curr_task_parsed = 0;
|
||||
prev_task_done = 0;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
@@ -184,45 +228,33 @@ void *mpp_dec_hal_thread(void *data)
|
||||
*/
|
||||
RK_U32 wait_on_task = 0;
|
||||
|
||||
HalTask task_local;
|
||||
HalDecTask *task_dec = &task_local.dec;
|
||||
memset(&task_local, 0, sizeof(task_local));
|
||||
HalTaskHnd task = NULL;
|
||||
HalTaskInfo task_info;
|
||||
HalDecTask *task_dec = &task_info.dec;
|
||||
memset(&task_info, 0, sizeof(task_info));
|
||||
|
||||
while (MPP_THREAD_RUNNING == hal->get_status()) {
|
||||
/*
|
||||
* hal thread wait for dxva interface intput firt
|
||||
*/
|
||||
hal->lock();
|
||||
if (wait_on_task)
|
||||
if (NULL == task)
|
||||
hal->wait();
|
||||
hal->unlock();
|
||||
|
||||
// get hw task first
|
||||
wait_on_task = (MPP_OK != hal_task_can_get(tasks));
|
||||
if (wait_on_task)
|
||||
continue;
|
||||
|
||||
if (NULL == task) {
|
||||
if (MPP_OK == hal_task_get_hnd(tasks, TASK_PROCESSING, &task)) {
|
||||
mpp->mTaskGetCount++;
|
||||
|
||||
hal_task_get(tasks, &task_local);
|
||||
hal_task_hnd_get_info(task, &task_info);
|
||||
mpp_hal_hw_wait(dec->hal, &task_info);
|
||||
|
||||
// register genertation
|
||||
mpp_hal_reg_gen(dec->hal, &task_local);
|
||||
// TODO: may have risk here
|
||||
hal_task_hnd_set_status(task, TASK_PROC_DONE);
|
||||
task = NULL;
|
||||
mpp->mThreadCodec->signal();
|
||||
|
||||
/*
|
||||
* wait previous register set done
|
||||
*/
|
||||
//mpp_hal_hw_wait(dec->hal_ctx, &task_local);
|
||||
|
||||
/*
|
||||
* send current register set to hardware
|
||||
*/
|
||||
//mpp_hal_hw_start(dec->hal_ctx, &task_local);
|
||||
|
||||
mpp_hal_hw_start(dec->hal, &task_local);
|
||||
mpp_hal_hw_wait(dec->hal, &task_local);
|
||||
|
||||
/*
|
||||
* when hardware decoding is done:
|
||||
* 1. clear decoding flag (mark buffer is ready)
|
||||
@@ -246,6 +278,8 @@ void *mpp_dec_hal_thread(void *data)
|
||||
frames->unlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
@@ -33,20 +33,20 @@ MPP_RET hal_dummy_dec_deinit(void *hal)
|
||||
return MPP_OK;
|
||||
}
|
||||
|
||||
MPP_RET hal_dummy_dec_gen_regs(void *hal, HalTask *task)
|
||||
MPP_RET hal_dummy_dec_gen_regs(void *hal, HalTaskInfo *task)
|
||||
{
|
||||
(void)hal;
|
||||
(void)task;
|
||||
return MPP_OK;
|
||||
}
|
||||
MPP_RET hal_dummy_dec_start(void *hal, HalTask *task)
|
||||
MPP_RET hal_dummy_dec_start(void *hal, HalTaskInfo *task)
|
||||
{
|
||||
(void)hal;
|
||||
(void)task;
|
||||
return MPP_OK;
|
||||
}
|
||||
|
||||
MPP_RET hal_dummy_dec_wait(void *hal, HalTask *task)
|
||||
MPP_RET hal_dummy_dec_wait(void *hal, HalTaskInfo *task)
|
||||
{
|
||||
(void)hal;
|
||||
(void)task;
|
||||
|
@@ -33,20 +33,20 @@ MPP_RET hal_dummy_enc_deinit(void *hal)
|
||||
return MPP_OK;
|
||||
}
|
||||
|
||||
MPP_RET hal_dummy_enc_gen_regs(void *hal, HalTask *task)
|
||||
MPP_RET hal_dummy_enc_gen_regs(void *hal, HalTaskInfo *task)
|
||||
{
|
||||
(void)hal;
|
||||
(void)task;
|
||||
return MPP_OK;
|
||||
}
|
||||
MPP_RET hal_dummy_enc_start(void *hal, HalTask *task)
|
||||
MPP_RET hal_dummy_enc_start(void *hal, HalTaskInfo *task)
|
||||
{
|
||||
(void)hal;
|
||||
(void)task;
|
||||
return MPP_OK;
|
||||
}
|
||||
|
||||
MPP_RET hal_dummy_enc_wait(void *hal, HalTask *task)
|
||||
MPP_RET hal_dummy_enc_wait(void *hal, HalTaskInfo *task)
|
||||
{
|
||||
(void)hal;
|
||||
(void)task;
|
||||
|
@@ -27,42 +27,79 @@ typedef struct HalTaskImpl_t HalTaskImpl;
|
||||
typedef struct HalTaskGroupImpl_t HalTaskGroupImpl;
|
||||
|
||||
struct HalTaskImpl_t {
|
||||
RK_U32 index;
|
||||
HalTask task;
|
||||
struct list_head list;
|
||||
HalTaskGroupImpl *group;
|
||||
RK_S32 index;
|
||||
MppTaskStatus status;
|
||||
HalTaskInfo task;
|
||||
};
|
||||
|
||||
struct HalTaskGroupImpl_t {
|
||||
RK_U32 count_put;
|
||||
RK_U32 count_get;
|
||||
MppCtxType type;
|
||||
RK_S32 count;
|
||||
mpp_list *tasks;
|
||||
|
||||
Mutex *lock;
|
||||
|
||||
HalTaskImpl *tasks;
|
||||
struct list_head list[TASK_BUTT];
|
||||
};
|
||||
|
||||
MPP_RET hal_task_group_init(HalTaskGroup *group, MppCtxType type, RK_U32 count)
|
||||
MPP_RET hal_task_group_init(HalTaskGroup *group, MppCtxType type, RK_S32 count)
|
||||
{
|
||||
if (NULL == group || 0 == count) {
|
||||
if (NULL == group) {
|
||||
mpp_err_f("found invalid input group %p count %d\n", group, count);
|
||||
return MPP_ERR_UNKNOW;
|
||||
}
|
||||
|
||||
*group = NULL;
|
||||
HalTaskGroupImpl *p = mpp_malloc(HalTaskGroupImpl, 1);
|
||||
HalTaskGroupImpl *p = NULL;
|
||||
HalTaskImpl *tasks = NULL;
|
||||
Mutex *lock = NULL;
|
||||
|
||||
do {
|
||||
p = mpp_calloc(HalTaskGroupImpl, 1);
|
||||
if (NULL == p) {
|
||||
mpp_err_f("malloc group failed\n");
|
||||
return MPP_NOK;
|
||||
break;
|
||||
}
|
||||
p->tasks = new mpp_list(NULL);
|
||||
if (NULL == p->tasks) {
|
||||
mpp_err_f("malloc task list failed\n");
|
||||
mpp_free(p);
|
||||
return MPP_NOK;
|
||||
lock = new Mutex();
|
||||
if (NULL == lock) {
|
||||
mpp_err_f("new lock failed\n");
|
||||
break;;
|
||||
}
|
||||
tasks = mpp_calloc(HalTaskImpl, count);
|
||||
if (NULL == tasks) {
|
||||
mpp_err_f("malloc tasks list failed\n");
|
||||
break;;
|
||||
}
|
||||
|
||||
p->type = type;
|
||||
p->count = count - 1;
|
||||
p->count_put = p->count_get = 0;
|
||||
p->count = count;
|
||||
p->lock = lock;
|
||||
p->tasks = tasks;
|
||||
|
||||
for (RK_U32 i = 0; i < TASK_BUTT; i++)
|
||||
INIT_LIST_HEAD(&p->list[i]);
|
||||
|
||||
for (RK_U32 i = 0; i < count; i++) {
|
||||
INIT_LIST_HEAD(&tasks[i].list);
|
||||
tasks[i].index = i;
|
||||
tasks[i].group = p;
|
||||
tasks[i].status = TASK_IDLE;
|
||||
list_add_tail(&tasks[i].list, &p->list[TASK_IDLE]);
|
||||
}
|
||||
*group = p;
|
||||
return MPP_OK;
|
||||
} while (0);
|
||||
|
||||
if (p)
|
||||
mpp_free(p);
|
||||
if (lock)
|
||||
delete lock;
|
||||
if (tasks)
|
||||
mpp_free(tasks);
|
||||
|
||||
*group = NULL;
|
||||
return MPP_NOK;
|
||||
}
|
||||
|
||||
MPP_RET hal_task_group_deinit(HalTaskGroup group)
|
||||
@@ -74,38 +111,83 @@ MPP_RET hal_task_group_deinit(HalTaskGroup group)
|
||||
|
||||
HalTaskGroupImpl *p = (HalTaskGroupImpl *)group;
|
||||
if (p->tasks)
|
||||
delete p->tasks;
|
||||
mpp_free(p->tasks);
|
||||
if (p->lock)
|
||||
delete p->lock;
|
||||
mpp_free(p);
|
||||
return MPP_OK;
|
||||
}
|
||||
|
||||
MPP_RET hal_task_can_put(HalTaskGroup group)
|
||||
MPP_RET hal_task_get_hnd(HalTaskGroup group, MppTaskStatus status, HalTaskHnd *hnd)
|
||||
{
|
||||
if (NULL == group) {
|
||||
mpp_err_f("found NULL input group\n");
|
||||
return MPP_ERR_NULL_PTR;
|
||||
if (NULL == group || status >= TASK_BUTT || NULL == hnd) {
|
||||
mpp_err_f("found invaid input group %p status %d hnd %p\n", group, status, hnd);
|
||||
return MPP_ERR_UNKNOW;
|
||||
}
|
||||
|
||||
*hnd = NULL;
|
||||
HalTaskGroupImpl *p = (HalTaskGroupImpl *)group;
|
||||
mpp_list *tasks = p->tasks;
|
||||
Mutex::Autolock auto_lock(tasks->mutex());
|
||||
return (tasks->list_size() < p->count) ? (MPP_OK) : (MPP_NOK);
|
||||
Mutex::Autolock auto_lock(p->lock);
|
||||
struct list_head *list = &p->list[status];
|
||||
if (list_empty(list))
|
||||
return MPP_NOK;
|
||||
|
||||
HalTaskImpl *task = list_entry(list->next, HalTaskImpl, list);
|
||||
mpp_assert(task->status == status);
|
||||
*hnd = task;
|
||||
return MPP_OK;
|
||||
}
|
||||
|
||||
MPP_RET hal_task_can_get(HalTaskGroup group)
|
||||
MPP_RET hal_task_hnd_set_status(HalTaskHnd hnd, MppTaskStatus status)
|
||||
{
|
||||
if (NULL == group) {
|
||||
mpp_err_f("found NULL input group\n");
|
||||
return MPP_ERR_NULL_PTR;
|
||||
if (NULL == hnd || status >= TASK_BUTT) {
|
||||
mpp_err_f("found invaid input hnd %p status %d\n", hnd, status);
|
||||
return MPP_ERR_UNKNOW;
|
||||
}
|
||||
|
||||
HalTaskGroupImpl *p = (HalTaskGroupImpl *)group;
|
||||
mpp_list *tasks = p->tasks;
|
||||
Mutex::Autolock auto_lock(tasks->mutex());
|
||||
return (tasks->list_size()) ? (MPP_OK) : (MPP_NOK);
|
||||
HalTaskImpl *impl = (HalTaskImpl *)hnd;
|
||||
HalTaskGroupImpl *group = impl->group;
|
||||
mpp_assert(group);
|
||||
mpp_assert(impl->index < group->count);
|
||||
|
||||
Mutex::Autolock auto_lock(group->lock);
|
||||
list_del_init(&impl->list);
|
||||
list_add_tail(&impl->list, &group->list[status]);
|
||||
impl->status = status;
|
||||
return MPP_OK;
|
||||
}
|
||||
|
||||
MPP_RET hal_task_init(HalTask *task, MppCtxType type)
|
||||
MPP_RET hal_task_hnd_set_info(HalTaskHnd hnd, HalTaskInfo *task)
|
||||
{
|
||||
if (NULL == hnd || NULL == task) {
|
||||
mpp_err_f("found invaid input hnd %p task %p\n", hnd, task);
|
||||
return MPP_ERR_UNKNOW;
|
||||
}
|
||||
|
||||
HalTaskImpl *impl = (HalTaskImpl *)hnd;
|
||||
HalTaskGroupImpl *group = impl->group;
|
||||
mpp_assert(impl->index < group->count);
|
||||
Mutex::Autolock auto_lock(group->lock);
|
||||
memcpy(&impl->task, task, sizeof(impl->task));
|
||||
return MPP_OK;
|
||||
}
|
||||
|
||||
MPP_RET hal_task_hnd_get_info(HalTaskHnd hnd, HalTaskInfo *task)
|
||||
{
|
||||
if (NULL == hnd || NULL == task) {
|
||||
mpp_err_f("found invaid input hnd %p task %p\n", hnd, task);
|
||||
return MPP_ERR_UNKNOW;
|
||||
}
|
||||
|
||||
HalTaskImpl *impl = (HalTaskImpl *)hnd;
|
||||
HalTaskGroupImpl *group = impl->group;
|
||||
mpp_assert(impl->index < group->count);
|
||||
Mutex::Autolock auto_lock(group->lock);
|
||||
memcpy(task, &impl->task, sizeof(impl->task));
|
||||
return MPP_OK;
|
||||
}
|
||||
|
||||
MPP_RET hal_task_info_init(HalTaskInfo *task, MppCtxType type)
|
||||
{
|
||||
if (NULL == task || type >= MPP_CTX_BUTT) {
|
||||
mpp_err_f("found invalid input task %p type %d\n", task, type);
|
||||
@@ -122,29 +204,3 @@ MPP_RET hal_task_init(HalTask *task, MppCtxType type)
|
||||
return MPP_OK;
|
||||
}
|
||||
|
||||
MPP_RET hal_task_put(HalTaskGroup group, HalTask *task)
|
||||
{
|
||||
MPP_RET ret = hal_task_can_put(group);
|
||||
mpp_assert(ret == MPP_OK);
|
||||
|
||||
HalTaskGroupImpl *p = (HalTaskGroupImpl *)group;
|
||||
mpp_list *tasks = p->tasks;
|
||||
Mutex::Autolock auto_lock(tasks->mutex());
|
||||
tasks->add_at_tail(task, sizeof(*task));
|
||||
p->count_put++;
|
||||
return MPP_OK;
|
||||
}
|
||||
|
||||
MPP_RET hal_task_get(HalTaskGroup group, HalTask *task)
|
||||
{
|
||||
MPP_RET ret = hal_task_can_get(group);
|
||||
mpp_assert(ret == MPP_OK);
|
||||
|
||||
HalTaskGroupImpl *p = (HalTaskGroupImpl *)group;
|
||||
mpp_list *tasks = p->tasks;
|
||||
Mutex::Autolock auto_lock(tasks->mutex());
|
||||
tasks->del_at_head(task, sizeof(*task));
|
||||
p->count_get++;
|
||||
return MPP_OK;
|
||||
}
|
||||
|
||||
|
@@ -33,9 +33,9 @@ extern const MppHalApi hal_api_h264d;
|
||||
|
||||
MPP_RET hal_h264d_init (void *hal, MppHalCfg *cfg);
|
||||
MPP_RET hal_h264d_deinit (void *hal);
|
||||
MPP_RET hal_h264d_gen_regs(void *hal, HalTask *task);
|
||||
MPP_RET hal_h264d_start (void *hal, HalTask *task);
|
||||
MPP_RET hal_h264d_wait (void *hal, HalTask *task);
|
||||
MPP_RET hal_h264d_gen_regs(void *hal, HalTaskInfo *task);
|
||||
MPP_RET hal_h264d_start (void *hal, HalTaskInfo *task);
|
||||
MPP_RET hal_h264d_wait (void *hal, HalTaskInfo *task);
|
||||
MPP_RET hal_h264d_reset (void *hal);
|
||||
MPP_RET hal_h264d_flush (void *hal);
|
||||
MPP_RET hal_h264d_control (void *hal, RK_S32 cmd_type, void *param);
|
||||
|
@@ -32,10 +32,10 @@ extern "C" {
|
||||
extern const MppHalApi hal_api_h265d;
|
||||
|
||||
RK_S32 hal_h265d_init(void *hal, MppHalCfg *cfg);
|
||||
RK_S32 hal_h265d_gen_regs(void *hal, HalTask *syn);
|
||||
RK_S32 hal_h265d_gen_regs(void *hal, HalTaskInfo *syn);
|
||||
RK_S32 hal_h265d_deinit(void *hal);
|
||||
MPP_RET hal_h265d_start(void *hal, HalTask *task);
|
||||
MPP_RET hal_h265d_wait(void *hal, HalTask *task);
|
||||
MPP_RET hal_h265d_start(void *hal, HalTaskInfo *task);
|
||||
MPP_RET hal_h265d_wait(void *hal, HalTaskInfo *task);
|
||||
MPP_RET hal_h265d_reset(void *hal);
|
||||
MPP_RET hal_h265d_flush(void *hal);
|
||||
MPP_RET hal_h265d_control(void *hal, RK_S32 cmd_type, void *param);
|
||||
|
@@ -22,6 +22,15 @@
|
||||
|
||||
#define MAX_DEC_REF_NUM 17
|
||||
|
||||
typedef enum MppTaskStatus_e {
|
||||
TASK_IDLE,
|
||||
TASK_PREPARE,
|
||||
TASK_WAIT_PROC,
|
||||
TASK_PROCESSING,
|
||||
TASK_PROC_DONE,
|
||||
TASK_BUTT,
|
||||
} MppTaskStatus;
|
||||
|
||||
/*
|
||||
* modified by parser
|
||||
*
|
||||
@@ -100,7 +109,7 @@ typedef struct HalEncTask_t {
|
||||
typedef union HalTask_u {
|
||||
HalDecTask dec;
|
||||
HalEncTask enc;
|
||||
} HalTask;
|
||||
} HalTaskInfo;
|
||||
|
||||
typedef void* HalTaskHnd;
|
||||
typedef void* HalTaskGroup;
|
||||
@@ -115,7 +124,7 @@ extern "C" {
|
||||
* NOTE: use mpp_list to implement
|
||||
* the count means the max task waiting for process
|
||||
*/
|
||||
MPP_RET hal_task_group_init(HalTaskGroup *group, MppCtxType type, RK_U32 count);
|
||||
MPP_RET hal_task_group_init(HalTaskGroup *group, MppCtxType type, RK_S32 count);
|
||||
MPP_RET hal_task_group_deinit(HalTaskGroup group);
|
||||
|
||||
/*
|
||||
@@ -123,22 +132,30 @@ MPP_RET hal_task_group_deinit(HalTaskGroup group);
|
||||
*
|
||||
* dec:
|
||||
*
|
||||
* hal_task_can_put(group) - dec test whether can send task to hal
|
||||
* parser->parse(task) - parser write a local task
|
||||
* hal_task_put(group, task) - dec send the task to hal
|
||||
* - codec
|
||||
* hal_task_get_hnd(group, idle, hnd) - dec try get idle task to work
|
||||
* hal_task_hnd_set_status(hnd, prepare) - dec prepare the task
|
||||
* codec prepare task
|
||||
* hal_task_hnd_set_status(hnd, wait_proc) - dec send the task to hardware queue
|
||||
*
|
||||
* hal:
|
||||
* - hal
|
||||
* hal_task_get_hnd(group, wait_proc, hnd) - hal get task on wait_proc status
|
||||
* hal start task
|
||||
* hal_task_set_hnd(hnd, processing) - hal send task to hardware for process
|
||||
* hal wait task done
|
||||
* hal_task_set_hnd(hnd, proc_done) - hal mark task is finished
|
||||
*
|
||||
* hal_task_can_get(group) - hal test whether there is task waiting for process
|
||||
* hal_task_get(group, task) - hal get the task to process
|
||||
* - codec
|
||||
* hal_task_get_hnd(group, task_done, hnd) - codec query the previous finished task
|
||||
* codec do error process on task
|
||||
* hal_task_set_hnd(hnd, idle) - codec mark task is idle
|
||||
*
|
||||
*/
|
||||
MPP_RET hal_task_can_put(HalTaskGroup group);
|
||||
MPP_RET hal_task_can_get(HalTaskGroup group);
|
||||
|
||||
MPP_RET hal_task_init(HalTask *task, MppCtxType type);
|
||||
MPP_RET hal_task_put(HalTaskGroup group, HalTask *task);
|
||||
MPP_RET hal_task_get(HalTaskGroup group, HalTask *task);
|
||||
MPP_RET hal_task_get_hnd(HalTaskGroup group, MppTaskStatus status, HalTaskHnd *hnd);
|
||||
MPP_RET hal_task_hnd_set_status(HalTaskHnd hnd, MppTaskStatus status);
|
||||
MPP_RET hal_task_hnd_set_info(HalTaskHnd hnd, HalTaskInfo *task);
|
||||
MPP_RET hal_task_hnd_get_info(HalTaskHnd hnd, HalTaskInfo *task);
|
||||
MPP_RET hal_task_info_init(HalTaskInfo *task, MppCtxType type);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@@ -39,7 +39,7 @@ typedef struct MppHalCfg_t {
|
||||
|
||||
// output
|
||||
HalTaskGroup tasks;
|
||||
RK_U32 task_count;
|
||||
RK_S32 task_count;
|
||||
} MppHalCfg;
|
||||
|
||||
typedef struct MppHalApi_t {
|
||||
@@ -53,11 +53,11 @@ typedef struct MppHalApi_t {
|
||||
MPP_RET (*deinit)(void *ctx);
|
||||
|
||||
// task preprocess function
|
||||
MPP_RET (*reg_gen)(void *ctx, HalTask *syn);
|
||||
MPP_RET (*reg_gen)(void *ctx, HalTaskInfo *syn);
|
||||
|
||||
// hw operation function
|
||||
MPP_RET (*start)(void *ctx, HalTask *task);
|
||||
MPP_RET (*wait)(void *ctx, HalTask *task);
|
||||
MPP_RET (*start)(void *ctx, HalTaskInfo *task);
|
||||
MPP_RET (*wait)(void *ctx, HalTaskInfo *task);
|
||||
|
||||
MPP_RET (*reset)(void *ctx);
|
||||
MPP_RET (*flush)(void *ctx);
|
||||
@@ -73,9 +73,9 @@ extern "C" {
|
||||
MPP_RET mpp_hal_init(MppHal *ctx, MppHalCfg *cfg);
|
||||
MPP_RET mpp_hal_deinit(MppHal ctx);
|
||||
|
||||
MPP_RET mpp_hal_reg_gen(MppHal ctx, HalTask *task);
|
||||
MPP_RET mpp_hal_hw_start(MppHal ctx, HalTask *task);
|
||||
MPP_RET mpp_hal_hw_wait(MppHal ctx, HalTask *task);
|
||||
MPP_RET mpp_hal_reg_gen(MppHal ctx, HalTaskInfo *task);
|
||||
MPP_RET mpp_hal_hw_start(MppHal ctx, HalTaskInfo *task);
|
||||
MPP_RET mpp_hal_hw_wait(MppHal ctx, HalTaskInfo *task);
|
||||
|
||||
MPP_RET mpp_hal_reset(MppHal ctx);
|
||||
MPP_RET mpp_hal_flush(MppHal ctx);
|
||||
|
@@ -51,7 +51,7 @@ typedef struct MppHalImpl_t {
|
||||
const MppHalApi *api;
|
||||
|
||||
HalTaskGroup tasks;
|
||||
RK_U32 task_count;
|
||||
RK_S32 task_count;
|
||||
} MppHalImpl;
|
||||
|
||||
|
||||
@@ -118,7 +118,7 @@ MPP_RET mpp_hal_deinit(MppHal ctx)
|
||||
return MPP_OK;
|
||||
}
|
||||
|
||||
MPP_RET mpp_hal_reg_gen(MppHal ctx, HalTask *task)
|
||||
MPP_RET mpp_hal_reg_gen(MppHal ctx, HalTaskInfo *task)
|
||||
{
|
||||
if (NULL == ctx || NULL == task) {
|
||||
mpp_err_f("found NULL input ctx %p task %p\n", ctx, task);
|
||||
@@ -129,7 +129,7 @@ MPP_RET mpp_hal_reg_gen(MppHal ctx, HalTask *task)
|
||||
return p->api->reg_gen(p->ctx, task);
|
||||
}
|
||||
|
||||
MPP_RET mpp_hal_hw_start(MppHal ctx, HalTask *task)
|
||||
MPP_RET mpp_hal_hw_start(MppHal ctx, HalTaskInfo *task)
|
||||
{
|
||||
if (NULL == ctx || NULL == task) {
|
||||
mpp_err_f("found NULL input ctx %p task %p\n", ctx, task);
|
||||
@@ -140,7 +140,7 @@ MPP_RET mpp_hal_hw_start(MppHal ctx, HalTask *task)
|
||||
return p->api->start(p->ctx, task);
|
||||
}
|
||||
|
||||
MPP_RET mpp_hal_hw_wait(MppHal ctx, HalTask *task)
|
||||
MPP_RET mpp_hal_hw_wait(MppHal ctx, HalTaskInfo *task)
|
||||
{
|
||||
if (NULL == ctx || NULL == task) {
|
||||
mpp_err_f("found NULL input ctx %p task %p\n", ctx, task);
|
||||
|
@@ -200,7 +200,7 @@ __RETURN:
|
||||
***********************************************************************
|
||||
*/
|
||||
//extern "C"
|
||||
MPP_RET hal_h264d_gen_regs(void *hal, HalTask *task)
|
||||
MPP_RET hal_h264d_gen_regs(void *hal, HalTaskInfo *task)
|
||||
{
|
||||
MPP_RET ret = MPP_ERR_UNKNOW;
|
||||
H264dHalCtx_t *p_hal = (H264dHalCtx_t *)hal;
|
||||
@@ -230,7 +230,7 @@ __RETURN:
|
||||
*/
|
||||
//extern "C"
|
||||
|
||||
MPP_RET hal_h264d_start(void *hal, HalTask *task)
|
||||
MPP_RET hal_h264d_start(void *hal, HalTaskInfo *task)
|
||||
{
|
||||
MPP_RET ret = MPP_ERR_UNKNOW;
|
||||
H264dHalCtx_t *p_hal = (H264dHalCtx_t *)hal;
|
||||
@@ -254,7 +254,7 @@ __RETURN:
|
||||
***********************************************************************
|
||||
*/
|
||||
//extern "C"
|
||||
MPP_RET hal_h264d_wait(void *hal, HalTask *task)
|
||||
MPP_RET hal_h264d_wait(void *hal, HalTaskInfo *task)
|
||||
{
|
||||
MPP_RET ret = MPP_ERR_UNKNOW;
|
||||
H264dHalCtx_t *p_hal = (H264dHalCtx_t *)hal;
|
||||
|
@@ -1255,7 +1255,7 @@ RK_S32 hal_h265d_output_pps_packet(void *hal, void *dxva)
|
||||
return 0;
|
||||
}
|
||||
|
||||
MPP_RET hal_h265d_gen_regs(void *hal, HalTask *syn)
|
||||
MPP_RET hal_h265d_gen_regs(void *hal, HalTaskInfo *syn)
|
||||
{
|
||||
RK_U32 uiMaxCUWidth, uiMaxCUHeight;
|
||||
RK_U32 log2_min_cb_size;
|
||||
@@ -1392,7 +1392,7 @@ MPP_RET hal_h265d_gen_regs(void *hal, HalTask *syn)
|
||||
return ret;
|
||||
}
|
||||
|
||||
MPP_RET hal_h265d_start(void *hal, HalTask *task)
|
||||
MPP_RET hal_h265d_start(void *hal, HalTaskInfo *task)
|
||||
{
|
||||
MPP_RET ret = MPP_OK;
|
||||
h265d_reg_context_t *reg_cxt = (h265d_reg_context_t *)hal;
|
||||
@@ -1414,7 +1414,7 @@ MPP_RET hal_h265d_start(void *hal, HalTask *task)
|
||||
}
|
||||
|
||||
|
||||
MPP_RET hal_h265d_wait(void *hal, HalTask *task)
|
||||
MPP_RET hal_h265d_wait(void *hal, HalTaskInfo *task)
|
||||
{
|
||||
MPP_RET ret = MPP_OK;
|
||||
(void) task;
|
||||
|
@@ -117,7 +117,7 @@ int main(int argc, char **argv)
|
||||
InputParams *pIn = mpp_calloc(InputParams, 1);
|
||||
MppDec *pApi = mpp_calloc(MppDec, 1);
|
||||
MppPacketImpl *pkt = mpp_calloc_size(MppPacketImpl, sizeof(MppPacketImpl));
|
||||
HalTask *task = mpp_calloc_size(HalTask, sizeof(HalTask));
|
||||
HalTaskInfo *task = mpp_calloc_size(HalTaskInfo, sizeof(HalTaskInfo));
|
||||
MEM_CHECK(ret, pIn && pApi && pkt && task);
|
||||
mpp_log("== test start == \n");
|
||||
// set debug mode
|
||||
|
@@ -34,7 +34,7 @@ struct mpp_list_node;
|
||||
class mpp_list
|
||||
{
|
||||
public:
|
||||
mpp_list(node_destructor func);
|
||||
mpp_list(node_destructor func = NULL);
|
||||
~mpp_list();
|
||||
|
||||
// for FIFO or FILO implement
|
||||
@@ -80,7 +80,6 @@ private:
|
||||
static RK_U32 keys;
|
||||
static RK_U32 get_key();
|
||||
|
||||
mpp_list();
|
||||
mpp_list(const mpp_list &);
|
||||
mpp_list &operator=(const mpp_list &);
|
||||
};
|
||||
|
Reference in New Issue
Block a user