mirror of
https://github.com/nyanmisaka/mpp.git
synced 2025-10-05 09:06:50 +08:00
feat[mpi_enc_test]: Support enc for kmpp flow
Add param -kmpp to enable kmpp. Change-Id: Id0e0dd64cca8f4da29fa7048f22beb3918162bd6 Signed-off-by: Yandong Lin <yandong.lin@rock-chips.com>
This commit is contained in:
@@ -23,6 +23,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include "rk_mpi.h"
|
#include "rk_mpi.h"
|
||||||
|
#include "rk_venc_kcfg.h"
|
||||||
|
|
||||||
#include "mpp_env.h"
|
#include "mpp_env.h"
|
||||||
#include "mpp_mem.h"
|
#include "mpp_mem.h"
|
||||||
@@ -99,6 +100,8 @@ typedef struct {
|
|||||||
CamSource *cam_ctx;
|
CamSource *cam_ctx;
|
||||||
MppEncRoiCtx roi_ctx;
|
MppEncRoiCtx roi_ctx;
|
||||||
|
|
||||||
|
MppVencKcfg init_kcfg;
|
||||||
|
|
||||||
// resources
|
// resources
|
||||||
size_t header_size;
|
size_t header_size;
|
||||||
size_t frame_size;
|
size_t frame_size;
|
||||||
@@ -199,6 +202,43 @@ static RK_S32 get_mdinfo_size(MpiEncTestData *p, MppCodingType type)
|
|||||||
return md_size;
|
return md_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static MPP_RET kmpp_cfg_init(MpiEncMultiCtxInfo *info)
|
||||||
|
{
|
||||||
|
MppVencKcfg init_kcfg = NULL;
|
||||||
|
MpiEncTestData *p = &info->ctx;
|
||||||
|
MPP_RET ret = MPP_NOK;
|
||||||
|
|
||||||
|
mpp_venc_kcfg_init(&init_kcfg, MPP_VENC_KCFG_TYPE_INIT);
|
||||||
|
if (!init_kcfg) {
|
||||||
|
mpp_err_f("kmpp_venc_init_cfg_init failed\n");
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
p->init_kcfg = init_kcfg;
|
||||||
|
|
||||||
|
mpp_venc_kcfg_set_u32(init_kcfg, "type", MPP_CTX_ENC);
|
||||||
|
mpp_venc_kcfg_set_u32(init_kcfg, "coding", p->type);
|
||||||
|
mpp_venc_kcfg_set_s32(init_kcfg, "chan_id", 0);
|
||||||
|
mpp_venc_kcfg_set_s32(init_kcfg, "online", 0);
|
||||||
|
mpp_venc_kcfg_set_u32(init_kcfg, "buf_size", 0);
|
||||||
|
mpp_venc_kcfg_set_u32(init_kcfg, "max_strm_cnt", 0);
|
||||||
|
mpp_venc_kcfg_set_u32(init_kcfg, "shared_buf_en", 0);
|
||||||
|
mpp_venc_kcfg_set_u32(init_kcfg, "smart_en", 0);
|
||||||
|
mpp_venc_kcfg_set_u32(init_kcfg, "max_width", p->width);
|
||||||
|
mpp_venc_kcfg_set_u32(init_kcfg, "max_height", p->height);
|
||||||
|
mpp_venc_kcfg_set_u32(init_kcfg, "max_lt_cnt", 0);
|
||||||
|
mpp_venc_kcfg_set_u32(init_kcfg, "qpmap_en", 0);
|
||||||
|
mpp_venc_kcfg_set_u32(init_kcfg, "chan_dup", 0);
|
||||||
|
mpp_venc_kcfg_set_u32(init_kcfg, "tmvp_enable", 0);
|
||||||
|
mpp_venc_kcfg_set_u32(init_kcfg, "only_smartp", 0);
|
||||||
|
|
||||||
|
ret = p->mpi->control(p->ctx, MPP_SET_VENC_INIT_KCFG, init_kcfg);
|
||||||
|
if (ret)
|
||||||
|
mpp_err_f("mpi control set kmpp enc cfg failed ret %d\n", ret);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
MPP_RET test_ctx_init(MpiEncMultiCtxInfo *info)
|
MPP_RET test_ctx_init(MpiEncMultiCtxInfo *info)
|
||||||
{
|
{
|
||||||
MpiEncTestArgs *cmd = info->cmd;
|
MpiEncTestArgs *cmd = info->cmd;
|
||||||
@@ -1049,6 +1089,9 @@ void *enc_test(void *arg)
|
|||||||
goto MPP_TEST_OUT;
|
goto MPP_TEST_OUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (cmd->kmpp_en)
|
||||||
|
kmpp_cfg_init(info);
|
||||||
|
|
||||||
ret = mpp_init(p->ctx, MPP_CTX_ENC, p->type);
|
ret = mpp_init(p->ctx, MPP_CTX_ENC, p->type);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
mpp_err("mpp_init failed ret %d\n", ret);
|
mpp_err("mpp_init failed ret %d\n", ret);
|
||||||
@@ -1134,6 +1177,8 @@ MPP_TEST_OUT:
|
|||||||
mpp_enc_roi_deinit(p->roi_ctx);
|
mpp_enc_roi_deinit(p->roi_ctx);
|
||||||
p->roi_ctx = NULL;
|
p->roi_ctx = NULL;
|
||||||
}
|
}
|
||||||
|
if (p->init_kcfg)
|
||||||
|
mpp_venc_kcfg_deinit(p->init_kcfg);
|
||||||
|
|
||||||
test_ctx_deinit(p);
|
test_ctx_deinit(p);
|
||||||
|
|
||||||
|
@@ -652,6 +652,25 @@ RK_S32 mpi_enc_opt_bias_p(void *ctx, const char *next)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RK_S32 mpi_enc_opt_kmpp(void *ctx, const char *next)
|
||||||
|
{
|
||||||
|
MpiEncTestArgs *cmd = (MpiEncTestArgs *)ctx;
|
||||||
|
|
||||||
|
if (next) {
|
||||||
|
cmd->kmpp_en = atoi(next);
|
||||||
|
if (cmd->kmpp_en) {
|
||||||
|
if (access("/dev/vcodec", F_OK | R_OK | W_OK)) {
|
||||||
|
mpp_err("failed to access /dev/vcodec, check kmpp devices\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
mpp_err("invalid kmpp enable\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static MppOptInfo enc_opts[] = {
|
static MppOptInfo enc_opts[] = {
|
||||||
{"i", "input_file", "input frame file", mpi_enc_opt_i},
|
{"i", "input_file", "input frame file", mpi_enc_opt_i},
|
||||||
{"o", "output_file", "output encoded bitstream file", mpi_enc_opt_o},
|
{"o", "output_file", "output encoded bitstream file", mpi_enc_opt_o},
|
||||||
@@ -686,7 +705,8 @@ static MppOptInfo enc_opts[] = {
|
|||||||
{"sao_p", "sao_str_p", "sao_str_p, 0:off 1 2 3", mpi_enc_opt_sao_p},
|
{"sao_p", "sao_str_p", "sao_str_p, 0:off 1 2 3", mpi_enc_opt_sao_p},
|
||||||
{"bc", "bitrate container", "rc_container, 0:off 1:weak 2:strong", mpi_enc_opt_bc},
|
{"bc", "bitrate container", "rc_container, 0:off 1:weak 2:strong", mpi_enc_opt_bc},
|
||||||
{"ibias", "bias i", "bias_i", mpi_enc_opt_bias_i},
|
{"ibias", "bias i", "bias_i", mpi_enc_opt_bias_i},
|
||||||
{"pbias", "bias p", "bias_p", mpi_enc_opt_bias_p}
|
{"pbias", "bias p", "bias_p", mpi_enc_opt_bias_p},
|
||||||
|
{"kmpp", "kmpp path enable", "kmpp path enable", mpi_enc_opt_kmpp}
|
||||||
};
|
};
|
||||||
|
|
||||||
static RK_U32 enc_opt_cnt = MPP_ARRAY_ELEMS(enc_opts);
|
static RK_U32 enc_opt_cnt = MPP_ARRAY_ELEMS(enc_opts);
|
||||||
|
@@ -103,6 +103,7 @@ typedef struct MpiEncTestArgs_t {
|
|||||||
RK_U32 psnr_en;
|
RK_U32 psnr_en;
|
||||||
RK_U32 ssim_en;
|
RK_U32 ssim_en;
|
||||||
char *file_slt;
|
char *file_slt;
|
||||||
|
RK_U32 kmpp_en;
|
||||||
} MpiEncTestArgs;
|
} MpiEncTestArgs;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
Reference in New Issue
Block a user