mirror of
https://github.com/nyanmisaka/mpp.git
synced 2025-10-07 01:52:46 +08:00
[enc_impl]: Rename and new enc_impl function
Change-Id: Ie0acfc1e66256db6acfba09e3c62b04ceda5e2a5 Signed-off-by: Herman Chen <herman.chen@rock-chips.com>
This commit is contained in:
@@ -29,7 +29,7 @@
|
||||
#include "h264e_codec.h"
|
||||
#include "h264e_syntax.h"
|
||||
|
||||
#include "mpp_enc_impl.h"
|
||||
#include "enc_impl_api.h"
|
||||
|
||||
#define H264E_DBG_FUNCTION (0x00000001)
|
||||
|
||||
|
@@ -49,7 +49,7 @@ RK_U32 mpp_enc_debug = 0;
|
||||
|
||||
typedef struct MppEncImpl_t {
|
||||
MppCodingType coding;
|
||||
EncImpl controller;
|
||||
EncImpl impl;
|
||||
MppHal hal;
|
||||
|
||||
MppThread *thread_enc;
|
||||
@@ -297,7 +297,7 @@ void *mpp_enc_control_thread(void *data)
|
||||
|
||||
{
|
||||
AutoMutex auto_lock(&enc->lock);
|
||||
ret = enc_impl_proc_hal(enc->controller, hal_task);
|
||||
ret = enc_impl_proc_hal(enc->impl, hal_task);
|
||||
if (ret) {
|
||||
mpp_err("mpp %p enc_impl_proc_hal failed return %d", mpp, ret);
|
||||
goto TASK_END;
|
||||
@@ -392,7 +392,7 @@ MPP_RET mpp_enc_init(MppEnc *enc, MppEncCfg *cfg)
|
||||
MppCodingType coding = cfg->coding;
|
||||
MppBufSlots frame_slots = NULL;
|
||||
MppBufSlots packet_slots = NULL;
|
||||
EncImpl controller = NULL;
|
||||
EncImpl impl = NULL;
|
||||
MppHal hal = NULL;
|
||||
MppEncImpl *p = NULL;
|
||||
RK_S32 task_count = 2;
|
||||
@@ -435,14 +435,14 @@ MPP_RET mpp_enc_init(MppEnc *enc, MppEncCfg *cfg)
|
||||
task_count,
|
||||
};
|
||||
|
||||
ret = enc_impl_init(&controller, &ctrl_cfg);
|
||||
ret = enc_impl_init(&impl, &ctrl_cfg);
|
||||
if (ret) {
|
||||
mpp_err_f("could not init controller\n");
|
||||
mpp_err_f("could not init impl\n");
|
||||
break;
|
||||
}
|
||||
cb.callBack = hal_enc_callback;
|
||||
cb.opaque = controller;
|
||||
// then init hal with task count from controller
|
||||
cb.opaque = impl;
|
||||
// then init hal with task count from impl
|
||||
MppHalCfg hal_cfg = {
|
||||
MPP_CTX_ENC,
|
||||
coding,
|
||||
@@ -465,7 +465,7 @@ MPP_RET mpp_enc_init(MppEnc *enc, MppEncCfg *cfg)
|
||||
}
|
||||
|
||||
p->coding = coding;
|
||||
p->controller = controller;
|
||||
p->impl = impl;
|
||||
p->hal = hal;
|
||||
p->mpp = cfg->mpp;
|
||||
p->tasks = hal_cfg.tasks;
|
||||
@@ -492,9 +492,9 @@ MPP_RET mpp_enc_deinit(MppEnc ctx)
|
||||
return MPP_ERR_NULL_PTR;
|
||||
}
|
||||
|
||||
if (enc->controller) {
|
||||
enc_impl_deinit(enc->controller);
|
||||
enc->controller = NULL;
|
||||
if (enc->impl) {
|
||||
enc_impl_deinit(enc->impl);
|
||||
enc->impl = NULL;
|
||||
}
|
||||
|
||||
if (enc->hal) {
|
||||
@@ -623,7 +623,7 @@ MPP_RET mpp_enc_control(MppEnc ctx, MpiCmd cmd, void *param)
|
||||
enc_dbg_ctrl("set all config\n");
|
||||
memcpy(&enc->set, param, sizeof(enc->set));
|
||||
|
||||
ret = enc_impl_proc_cfg(enc->controller, MPP_ENC_SET_RC_CFG, param);
|
||||
ret = enc_impl_proc_cfg(enc->impl, MPP_ENC_SET_RC_CFG, param);
|
||||
if (!ret)
|
||||
ret = mpp_hal_control(enc->hal, MPP_ENC_SET_RC_CFG, &enc->set.rc);
|
||||
|
||||
@@ -660,7 +660,7 @@ MPP_RET mpp_enc_control(MppEnc ctx, MpiCmd cmd, void *param)
|
||||
enc_dbg_ctrl("set rc config\n");
|
||||
memcpy(&enc->set.rc, param, sizeof(enc->set.rc));
|
||||
|
||||
ret = enc_impl_proc_cfg(enc->controller, cmd, param);
|
||||
ret = enc_impl_proc_cfg(enc->impl, cmd, param);
|
||||
if (!ret)
|
||||
ret = mpp_hal_control(enc->hal, cmd, param);
|
||||
|
||||
@@ -689,7 +689,7 @@ MPP_RET mpp_enc_control(MppEnc ctx, MpiCmd cmd, void *param)
|
||||
|
||||
case MPP_ENC_SET_IDR_FRAME : {
|
||||
enc_dbg_ctrl("idr request\n");
|
||||
ret = enc_impl_proc_cfg(enc->controller, cmd, param);
|
||||
ret = enc_impl_proc_cfg(enc->impl, cmd, param);
|
||||
} break;
|
||||
case MPP_ENC_GET_EXTRA_INFO : {
|
||||
enc_dbg_ctrl("get extra info\n");
|
||||
|
@@ -44,41 +44,26 @@ static const EncImplApi *controllers[] = {
|
||||
#endif
|
||||
};
|
||||
|
||||
typedef struct ControllerImpl_t {
|
||||
typedef struct EncImplCtx_t {
|
||||
EncImplCfg cfg;
|
||||
const EncImplApi *api;
|
||||
void *ctx;
|
||||
} ControllerImpl;
|
||||
} EncImplCtx;
|
||||
|
||||
MPP_RET enc_impl_proc_hal(EncImpl ctrl, HalEncTask *task)
|
||||
MPP_RET enc_impl_init(EncImpl *impl, EncImplCfg *cfg)
|
||||
{
|
||||
if (NULL == ctrl || NULL == task) {
|
||||
mpp_err_f("found NULL input\n");
|
||||
if (NULL == impl || NULL == cfg) {
|
||||
mpp_err_f("found NULL input controller %p config %p\n", impl, cfg);
|
||||
return MPP_ERR_NULL_PTR;
|
||||
}
|
||||
|
||||
MPP_RET ret = MPP_OK;
|
||||
ControllerImpl *p = (ControllerImpl *)ctrl;
|
||||
if (p->api->proc_hal)
|
||||
ret = p->api->proc_hal(p->ctx, task);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
MPP_RET enc_impl_init(EncImpl *ctrl, EncImplCfg *cfg)
|
||||
{
|
||||
if (NULL == ctrl || NULL == cfg) {
|
||||
mpp_err_f("found NULL input controller %p config %p\n", ctrl, cfg);
|
||||
return MPP_ERR_NULL_PTR;
|
||||
}
|
||||
|
||||
*ctrl = NULL;
|
||||
*impl = NULL;
|
||||
|
||||
RK_U32 i;
|
||||
for (i = 0; i < MPP_ARRAY_ELEMS(controllers); i++) {
|
||||
const EncImplApi *api = controllers[i];
|
||||
if (cfg->coding == api->coding) {
|
||||
ControllerImpl *p = mpp_calloc(ControllerImpl, 1);
|
||||
EncImplCtx *p = mpp_calloc(EncImplCtx, 1);
|
||||
void *ctx = mpp_calloc_size(void, api->ctx_size);
|
||||
if (NULL == ctx || NULL == p) {
|
||||
mpp_err_f("failed to alloc parser context\n");
|
||||
@@ -97,7 +82,7 @@ MPP_RET enc_impl_init(EncImpl *ctrl, EncImplCfg *cfg)
|
||||
|
||||
p->api = api;
|
||||
p->ctx = ctx;
|
||||
*ctrl = p;
|
||||
*impl = p;
|
||||
return MPP_OK;
|
||||
}
|
||||
}
|
||||
@@ -105,14 +90,14 @@ MPP_RET enc_impl_init(EncImpl *ctrl, EncImplCfg *cfg)
|
||||
return MPP_NOK;
|
||||
}
|
||||
|
||||
MPP_RET enc_impl_deinit(EncImpl ctrl)
|
||||
MPP_RET enc_impl_deinit(EncImpl impl)
|
||||
{
|
||||
if (NULL == ctrl) {
|
||||
if (NULL == impl) {
|
||||
mpp_err_f("found NULL input\n");
|
||||
return MPP_ERR_NULL_PTR;
|
||||
}
|
||||
|
||||
ControllerImpl *p = (ControllerImpl *)ctrl;
|
||||
EncImplCtx *p = (EncImplCtx *)impl;
|
||||
if (p->api->deinit)
|
||||
p->api->deinit(p->ctx);
|
||||
|
||||
@@ -121,32 +106,137 @@ MPP_RET enc_impl_deinit(EncImpl ctrl)
|
||||
return MPP_OK;
|
||||
}
|
||||
|
||||
MPP_RET hal_enc_callback(void *ctrl, void *err_info)
|
||||
MPP_RET enc_impl_proc_cfg(EncImpl impl, RK_S32 cmd, void *para)
|
||||
{
|
||||
if (NULL == ctrl) {
|
||||
if (NULL == impl) {
|
||||
mpp_err_f("found NULL input\n");
|
||||
return MPP_ERR_NULL_PTR;
|
||||
}
|
||||
|
||||
MPP_RET ret = MPP_OK;
|
||||
ControllerImpl *p = (ControllerImpl *)ctrl;
|
||||
if (p->api->callback)
|
||||
ret = p->api->callback(p->ctx, err_info);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
MPP_RET enc_impl_proc_cfg(EncImpl ctrl, RK_S32 cmd, void *para)
|
||||
{
|
||||
if (NULL == ctrl) {
|
||||
mpp_err_f("found NULL input\n");
|
||||
return MPP_ERR_NULL_PTR;
|
||||
}
|
||||
|
||||
MPP_RET ret = MPP_OK;
|
||||
ControllerImpl *p = (ControllerImpl *)ctrl;
|
||||
EncImplCtx *p = (EncImplCtx *)impl;
|
||||
if (p->api->proc_cfg)
|
||||
ret = p->api->proc_cfg(p->ctx, cmd, para);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
MPP_RET enc_impl_gen_hdr(EncImpl impl, MppPacket pkt)
|
||||
{
|
||||
if (NULL == impl) {
|
||||
mpp_err_f("found NULL input\n");
|
||||
return MPP_ERR_NULL_PTR;
|
||||
}
|
||||
|
||||
MPP_RET ret = MPP_OK;
|
||||
EncImplCtx *p = (EncImplCtx *)impl;
|
||||
if (p->api->gen_hdr)
|
||||
ret = p->api->gen_hdr(p->ctx, pkt);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
MPP_RET enc_impl_proc_dpb(EncImpl impl)
|
||||
{
|
||||
if (NULL == impl) {
|
||||
mpp_err_f("found NULL input\n");
|
||||
return MPP_ERR_NULL_PTR;
|
||||
}
|
||||
|
||||
MPP_RET ret = MPP_OK;
|
||||
EncImplCtx *p = (EncImplCtx *)impl;
|
||||
if (p->api->proc_dpb)
|
||||
ret = p->api->proc_dpb(p->ctx);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
MPP_RET enc_impl_proc_rc(EncImpl impl)
|
||||
{
|
||||
if (NULL == impl) {
|
||||
mpp_err_f("found NULL input\n");
|
||||
return MPP_ERR_NULL_PTR;
|
||||
}
|
||||
|
||||
MPP_RET ret = MPP_OK;
|
||||
EncImplCtx *p = (EncImplCtx *)impl;
|
||||
if (p->api->proc_rc)
|
||||
ret = p->api->proc_rc(p->ctx);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
MPP_RET enc_impl_proc_hal(EncImpl impl, HalEncTask *task)
|
||||
{
|
||||
if (NULL == impl || NULL == task) {
|
||||
mpp_err_f("found NULL input\n");
|
||||
return MPP_ERR_NULL_PTR;
|
||||
}
|
||||
|
||||
MPP_RET ret = MPP_OK;
|
||||
EncImplCtx *p = (EncImplCtx *)impl;
|
||||
if (p->api->proc_hal)
|
||||
ret = p->api->proc_hal(p->ctx, task);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
MPP_RET enc_impl_update_dpb(EncImpl impl)
|
||||
{
|
||||
if (NULL == impl) {
|
||||
mpp_err_f("found NULL input\n");
|
||||
return MPP_ERR_NULL_PTR;
|
||||
}
|
||||
|
||||
MPP_RET ret = MPP_OK;
|
||||
EncImplCtx *p = (EncImplCtx *)impl;
|
||||
if (p->api->update_dpb)
|
||||
ret = p->api->update_dpb(p->ctx);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
MPP_RET enc_impl_update_hal(EncImpl impl, HalEncTask *task)
|
||||
{
|
||||
if (NULL == impl || NULL == task) {
|
||||
mpp_err_f("found NULL input\n");
|
||||
return MPP_ERR_NULL_PTR;
|
||||
}
|
||||
|
||||
MPP_RET ret = MPP_OK;
|
||||
EncImplCtx *p = (EncImplCtx *)impl;
|
||||
if (p->api->update_hal)
|
||||
ret = p->api->update_hal(p->ctx, task);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
MPP_RET enc_impl_update_rc(EncImpl impl)
|
||||
{
|
||||
if (NULL == impl) {
|
||||
mpp_err_f("found NULL input\n");
|
||||
return MPP_ERR_NULL_PTR;
|
||||
}
|
||||
|
||||
MPP_RET ret = MPP_OK;
|
||||
EncImplCtx *p = (EncImplCtx *)impl;
|
||||
if (p->api->update_rc)
|
||||
ret = p->api->update_rc(p->ctx);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
MPP_RET hal_enc_callback(void *impl, void *err_info)
|
||||
{
|
||||
if (NULL == impl) {
|
||||
mpp_err_f("found NULL input\n");
|
||||
return MPP_ERR_NULL_PTR;
|
||||
}
|
||||
|
||||
MPP_RET ret = MPP_OK;
|
||||
EncImplCtx *p = (EncImplCtx *)impl;
|
||||
if (p->api->callback)
|
||||
ret = p->api->callback(p->ctx, err_info);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
Reference in New Issue
Block a user