mirror of
https://github.com/nyanmisaka/mpp.git
synced 2025-10-05 09:06:50 +08:00
[mpp_hal]: add hal_h264d_api to mpp_hal
git-svn-id: https://10.10.10.66:8443/svn/MediaProcessPlatform/trunk/mpp@207 6e48237b-75ef-9749-8fc9-41990f28c85a
This commit is contained in:
@@ -65,7 +65,7 @@ MPP_RET h264d_parser(void *decoder, MppPacket pkt, HalDecTask *task)
|
||||
}
|
||||
|
||||
const MppDecParser api_h264d_parser = {
|
||||
"h264d",
|
||||
"h264d_parser",
|
||||
MPP_VIDEO_CodingAVC,
|
||||
0,
|
||||
0,
|
||||
|
@@ -72,7 +72,6 @@ struct MppDec_t {
|
||||
const MppDecParser *parser_api;
|
||||
void *parser_ctx;
|
||||
|
||||
const MppHalApi *hal_api;
|
||||
MppHal hal_ctx;
|
||||
|
||||
// common resource
|
||||
|
@@ -160,7 +160,7 @@ void *mpp_dec_hal_thread(void *data)
|
||||
* hal thread wait for dxva interface intput firt
|
||||
*/
|
||||
hal->lock();
|
||||
if (0 == hal_task_get_hnd(dec->tasks, 1, &task_hnd))
|
||||
if (hal_task_get_hnd(dec->tasks, 1, &task_hnd))
|
||||
hal->wait();
|
||||
hal->unlock();
|
||||
|
||||
|
@@ -36,6 +36,8 @@ struct HalTaskImpl_t {
|
||||
struct HalTaskGroupImpl_t {
|
||||
struct list_head list_unused;
|
||||
struct list_head list_used;
|
||||
RK_U32 count_unused;
|
||||
RK_U32 count_used;
|
||||
Mutex *lock;
|
||||
MppCtxType type;
|
||||
HalTaskImpl *node;
|
||||
@@ -48,6 +50,11 @@ static size_t get_task_size(HalTaskGroupImpl *group)
|
||||
|
||||
MPP_RET hal_task_group_init(HalTaskGroup *group, MppCtxType type, RK_U32 count)
|
||||
{
|
||||
if (NULL == group || 0 == count) {
|
||||
mpp_err_f("found invalid input group %p count %d\n", group, count);
|
||||
return MPP_ERR_UNKNOW;
|
||||
}
|
||||
|
||||
HalTaskGroupImpl *p = mpp_malloc_size(HalTaskGroupImpl,
|
||||
sizeof(HalTaskGroupImpl) + count * sizeof(HalTaskImpl));
|
||||
if (NULL == p) {
|
||||
@@ -67,12 +74,18 @@ MPP_RET hal_task_group_init(HalTaskGroup *group, MppCtxType type, RK_U32 count)
|
||||
p->node[i].group = p;
|
||||
list_add_tail(&p->node[i].list, &p->list_unused);
|
||||
}
|
||||
p->count_unused = count;
|
||||
*group = p;
|
||||
return MPP_OK;
|
||||
}
|
||||
|
||||
MPP_RET hal_task_group_deinit(HalTaskGroup group)
|
||||
{
|
||||
if (NULL == group) {
|
||||
mpp_err_f("found NULL input group\n");
|
||||
return MPP_ERR_NULL_PTR;
|
||||
}
|
||||
|
||||
HalTaskGroupImpl *p = (HalTaskGroupImpl *)group;
|
||||
if (p->lock) {
|
||||
delete p->lock;
|
||||
@@ -84,6 +97,11 @@ MPP_RET hal_task_group_deinit(HalTaskGroup group)
|
||||
|
||||
MPP_RET hal_task_get_hnd(HalTaskGroup group, RK_U32 used, HalTaskHnd *hnd)
|
||||
{
|
||||
if (NULL == group || NULL == hnd) {
|
||||
mpp_err_f("found NULL input group %p hnd %d\n", group, hnd);
|
||||
return MPP_ERR_NULL_PTR;
|
||||
}
|
||||
|
||||
HalTaskGroupImpl *p = (HalTaskGroupImpl *)group;
|
||||
Mutex::Autolock auto_lock(p->lock);
|
||||
struct list_head *head = (used) ? (&p->list_used) : (&p->list_unused);
|
||||
@@ -99,12 +117,27 @@ MPP_RET hal_task_get_hnd(HalTaskGroup group, RK_U32 used, HalTaskHnd *hnd)
|
||||
|
||||
MPP_RET hal_task_set_used(HalTaskHnd hnd, RK_U32 used)
|
||||
{
|
||||
if (NULL == hnd) {
|
||||
mpp_err_f("found NULL input\n");
|
||||
return MPP_ERR_NULL_PTR;
|
||||
}
|
||||
|
||||
HalTaskImpl *impl = (HalTaskImpl *)hnd;
|
||||
HalTaskGroupImpl *group = impl->group;
|
||||
Mutex::Autolock auto_lock(group->lock);
|
||||
struct list_head *head = (used) ? (&group->list_used) : (&group->list_unused);
|
||||
list_del_init(&impl->list);
|
||||
list_add_tail(&impl->list, head);
|
||||
if (impl->used)
|
||||
group->count_used--;
|
||||
else
|
||||
group->count_unused--;
|
||||
if (used)
|
||||
group->count_used++;
|
||||
else
|
||||
group->count_unused++;
|
||||
|
||||
impl->used = used;
|
||||
return MPP_OK;
|
||||
}
|
||||
|
||||
|
@@ -332,7 +332,7 @@ extern "C" {
|
||||
|
||||
extern const MppHalApi api_h264d_hal;
|
||||
|
||||
MPP_RET hal_h264d_init (void **hal, MppHalCfg *cfg);
|
||||
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);
|
||||
|
@@ -33,7 +33,10 @@ typedef struct MppHalCfg_t {
|
||||
} MppHalCfg;
|
||||
|
||||
typedef struct {
|
||||
char *name;
|
||||
MppCodingType coding;
|
||||
RK_U32 ctx_size;
|
||||
RK_U32 flag;
|
||||
|
||||
MPP_RET (*init)(void *ctx, MppHalCfg *cfg);
|
||||
MPP_RET (*deinit)(void *ctx);
|
||||
|
@@ -18,21 +18,33 @@
|
||||
|
||||
#include "mpp_mem.h"
|
||||
#include "mpp_log.h"
|
||||
#include "mpp_common.h"
|
||||
|
||||
#include "mpp.h"
|
||||
#include "mpp_hal.h"
|
||||
#include "mpp_frame_impl.h"
|
||||
|
||||
typedef struct {
|
||||
MppCodingType mCoding;
|
||||
#include "hal_h264d_api.h"
|
||||
|
||||
void *mHalCtx;
|
||||
MppHalApi *api;
|
||||
/*
|
||||
* all hardware api static register here
|
||||
*/
|
||||
static const MppHalApi *hw_apis[] = {
|
||||
&api_h264d_hal,
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
MppCtxType type;
|
||||
MppCodingType coding;
|
||||
|
||||
void *ctx;
|
||||
const MppHalApi *api;
|
||||
|
||||
HalTaskGroup tasks;
|
||||
RK_U32 task_count;
|
||||
} MppHalImpl;
|
||||
|
||||
|
||||
MPP_RET mpp_hal_init(MppHal *ctx, MppHalCfg *cfg)
|
||||
{
|
||||
if (NULL == ctx || NULL == cfg) {
|
||||
@@ -47,18 +59,36 @@ MPP_RET mpp_hal_init(MppHal *ctx, MppHalCfg *cfg)
|
||||
return MPP_ERR_MALLOC;
|
||||
}
|
||||
|
||||
RK_U32 i;
|
||||
for (i = 0; i < MPP_ARRAY_ELEMS(hw_apis); i++) {
|
||||
if (cfg->coding == hw_apis[i]->coding) {
|
||||
// TODO: task count should be considered according to hardware feature
|
||||
cfg->task_count = 2;
|
||||
MPP_RET ret = hal_task_group_init(&cfg->tasks, cfg->type, cfg->task_count);
|
||||
p->type = cfg->type;
|
||||
p->coding = cfg->coding;
|
||||
p->api = hw_apis[i];
|
||||
p->task_count = cfg->task_count;
|
||||
p->ctx = mpp_malloc_size(void, p->api->ctx_size);
|
||||
p->api->init(p->ctx, cfg);
|
||||
|
||||
MPP_RET ret = hal_task_group_init(&p->tasks, p->type, p->task_count);
|
||||
if (ret) {
|
||||
mpp_err_f("hal_task_group_init failed ret %d\n", ret);
|
||||
mpp_free(p);
|
||||
return MPP_ERR_MALLOC;
|
||||
break;
|
||||
}
|
||||
|
||||
p->tasks = cfg->tasks;
|
||||
p->task_count = cfg->task_count;
|
||||
cfg->tasks = p->tasks;
|
||||
*ctx = p;
|
||||
return MPP_OK;
|
||||
}
|
||||
}
|
||||
|
||||
mpp_err_f("could not found coding type %d\n", cfg->coding);
|
||||
if (p->ctx)
|
||||
mpp_free(p->ctx);
|
||||
mpp_free(p);
|
||||
|
||||
return MPP_NOK;
|
||||
}
|
||||
|
||||
MPP_RET mpp_hal_deinit(MppHal ctx)
|
||||
@@ -69,6 +99,9 @@ MPP_RET mpp_hal_deinit(MppHal ctx)
|
||||
}
|
||||
|
||||
MppHalImpl *p = (MppHalImpl*)ctx;
|
||||
if (p->ctx)
|
||||
mpp_free(p->ctx);
|
||||
if (p->tasks)
|
||||
hal_task_group_deinit(p->tasks);
|
||||
mpp_free(p);
|
||||
return MPP_OK;
|
||||
|
@@ -19,48 +19,63 @@
|
||||
#include "hal_h264d_api.h"
|
||||
|
||||
|
||||
MPP_RET hal_h264d_init(void **hal, MppHalCfg *cfg)
|
||||
MPP_RET hal_h264d_init(void *hal, MppHalCfg *cfg)
|
||||
{
|
||||
(void)hal;
|
||||
(void)cfg;
|
||||
return MPP_OK;
|
||||
}
|
||||
|
||||
MPP_RET hal_h264d_deinit(void *hal)
|
||||
{
|
||||
(void)hal;
|
||||
return MPP_OK;
|
||||
}
|
||||
|
||||
MPP_RET hal_h264d_gen_regs(void *hal, HalTask *task)
|
||||
{
|
||||
(void)hal;
|
||||
(void)task;
|
||||
return MPP_OK;
|
||||
}
|
||||
MPP_RET hal_h264d_start(void *hal, HalTask *task)
|
||||
{
|
||||
(void)hal;
|
||||
(void)task;
|
||||
return MPP_OK;
|
||||
}
|
||||
|
||||
MPP_RET hal_h264d_wait(void *hal, HalTask *task)
|
||||
{
|
||||
(void)hal;
|
||||
(void)task;
|
||||
return MPP_OK;
|
||||
}
|
||||
|
||||
MPP_RET hal_h264d_reset(void *hal)
|
||||
{
|
||||
(void)hal;
|
||||
return MPP_OK;
|
||||
}
|
||||
|
||||
MPP_RET hal_h264d_flush(void *hal)
|
||||
{
|
||||
(void)hal;
|
||||
return MPP_OK;
|
||||
}
|
||||
|
||||
MPP_RET hal_h264d_control(void *hal, RK_S32 cmd_type, void *param)
|
||||
{
|
||||
(void)hal;
|
||||
(void)cmd_type;
|
||||
(void)param;
|
||||
return MPP_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
const MppHalApi api_h264d_hal = {
|
||||
"h264d_rkdec",
|
||||
MPP_VIDEO_CodingAVC,
|
||||
0,
|
||||
0,
|
||||
hal_h264d_init,
|
||||
hal_h264d_deinit,
|
||||
@@ -71,3 +86,4 @@ const MppHalApi api_h264d_hal = {
|
||||
hal_h264d_flush,
|
||||
hal_h264d_control,
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user