diff --git a/mpp/codec/dec/h265/test/h265d_parser_test.c b/mpp/codec/dec/h265/test/h265d_parser_test.c index aed8c1da..8f9d2dbe 100644 --- a/mpp/codec/dec/h265/test/h265d_parser_test.c +++ b/mpp/codec/dec/h265/test/h265d_parser_test.c @@ -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); diff --git a/mpp/codec/mpp_dec.cpp b/mpp/codec/mpp_dec.cpp index 8f1d1f97..a6ca7258 100644 --- a/mpp/codec/mpp_dec.cpp +++ b/mpp/codec/mpp_dec.cpp @@ -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) - continue; + 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; - parser_parse(dec->parser, task_dec); + // 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,66 +228,56 @@ 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++; - mpp->mTaskGetCount++; + hal_task_hnd_get_info(task, &task_info); + mpp_hal_hw_wait(dec->hal, &task_info); - hal_task_get(tasks, &task_local); + // TODO: may have risk here + hal_task_hnd_set_status(task, TASK_PROC_DONE); + task = NULL; + mpp->mThreadCodec->signal(); - // register genertation - mpp_hal_reg_gen(dec->hal, &task_local); - mpp->mThreadCodec->signal(); + /* + * when hardware decoding is done: + * 1. clear decoding flag (mark buffer is ready) + * 2. use get_display to get a new frame with buffer + * 3. add frame to output list + * repeat 2 and 3 until not frame can be 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++) { + RK_S32 index = task_dec->refer[i]; + if (index >= 0) + mpp_buf_slot_dec_hw_ref(frame_slots, index); + } - /* - * 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) - * 2. use get_display to get a new frame with buffer - * 3. add frame to output list - * repeat 2 and 3 until not frame can be 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++) { - RK_S32 index = task_dec->refer[i]; - if (index >= 0) - mpp_buf_slot_dec_hw_ref(frame_slots, index); - } - - MppFrame frame = NULL; - while (MPP_OK == mpp_buf_slot_get_display(frame_slots, &frame)) { - frames->lock(); - frames->add_at_tail(&frame, sizeof(frame)); - mpp->mFramePutCount++; - frames->signal(); - frames->unlock(); + MppFrame frame = NULL; + while (MPP_OK == mpp_buf_slot_get_display(frame_slots, &frame)) { + frames->lock(); + frames->add_at_tail(&frame, sizeof(frame)); + mpp->mFramePutCount++; + frames->signal(); + frames->unlock(); + } + } } } diff --git a/mpp/hal/dummy/hal_dummy_dec_api.c b/mpp/hal/dummy/hal_dummy_dec_api.c index af8d0c72..bcc831e8 100644 --- a/mpp/hal/dummy/hal_dummy_dec_api.c +++ b/mpp/hal/dummy/hal_dummy_dec_api.c @@ -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; diff --git a/mpp/hal/dummy/hal_dummy_enc_api.c b/mpp/hal/dummy/hal_dummy_enc_api.c index fa4657a6..89f84ec7 100644 --- a/mpp/hal/dummy/hal_dummy_enc_api.c +++ b/mpp/hal/dummy/hal_dummy_enc_api.c @@ -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; diff --git a/mpp/hal/hal_task.cpp b/mpp/hal/hal_task.cpp index 489884ac..8482908d 100644 --- a/mpp/hal/hal_task.cpp +++ b/mpp/hal/hal_task.cpp @@ -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); - if (NULL == p) { - mpp_err_f("malloc group failed\n"); - return MPP_NOK; - } - p->tasks = new mpp_list(NULL); - if (NULL == p->tasks) { - mpp_err_f("malloc task list failed\n"); + 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"); + break; + } + 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; + 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); - return MPP_NOK; - } - p->type = type; - p->count = count - 1; - p->count_put = p->count_get = 0; - *group = p; - return MPP_OK; + 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; -} - diff --git a/mpp/hal/inc/hal_h264d_api.h b/mpp/hal/inc/hal_h264d_api.h index 6cde13b6..87a446f2 100644 --- a/mpp/hal/inc/hal_h264d_api.h +++ b/mpp/hal/inc/hal_h264d_api.h @@ -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); diff --git a/mpp/hal/inc/hal_h265d_api.h b/mpp/hal/inc/hal_h265d_api.h index 2b7cd76d..f9c4eb71 100644 --- a/mpp/hal/inc/hal_h265d_api.h +++ b/mpp/hal/inc/hal_h265d_api.h @@ -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); diff --git a/mpp/hal/inc/hal_task.h b/mpp/hal/inc/hal_task.h index ac69f617..d98d63bd 100644 --- a/mpp/hal/inc/hal_task.h +++ b/mpp/hal/inc/hal_task.h @@ -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 } diff --git a/mpp/hal/inc/mpp_hal.h b/mpp/hal/inc/mpp_hal.h index 98a82a68..143c71da 100644 --- a/mpp/hal/inc/mpp_hal.h +++ b/mpp/hal/inc/mpp_hal.h @@ -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); diff --git a/mpp/hal/mpp_hal.cpp b/mpp/hal/mpp_hal.cpp index 2a645d9c..9be2cbfa 100644 --- a/mpp/hal/mpp_hal.cpp +++ b/mpp/hal/mpp_hal.cpp @@ -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); diff --git a/mpp/hal/rkdec/h264d/hal_h264d_api.c b/mpp/hal/rkdec/h264d/hal_h264d_api.c index 6139d08a..48b2b5c1 100644 --- a/mpp/hal/rkdec/h264d/hal_h264d_api.c +++ b/mpp/hal/rkdec/h264d/hal_h264d_api.c @@ -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; diff --git a/mpp/hal/rkdec/h265d/hal_h265d_reg.c b/mpp/hal/rkdec/h265d/hal_h265d_reg.c index c11827b3..39b5aff5 100644 --- a/mpp/hal/rkdec/h265d/hal_h265d_reg.c +++ b/mpp/hal/rkdec/h265d/hal_h265d_reg.c @@ -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; diff --git a/mpp/test/h264d_test.c b/mpp/test/h264d_test.c index 028e96ca..4cf675ca 100644 --- a/mpp/test/h264d_test.c +++ b/mpp/test/h264d_test.c @@ -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 diff --git a/osal/inc/mpp_list.h b/osal/inc/mpp_list.h index a8454acd..8712b72e 100644 --- a/osal/inc/mpp_list.h +++ b/osal/inc/mpp_list.h @@ -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 &); };