[h264e]: add rotation configuration

Change-Id: I148814a644264b341d6db1d7af767dd485942829
Signed-off-by: Lin Kesheng <lks@rock-chips.com>
This commit is contained in:
Lin Kesheng
2017-03-14 09:20:18 +08:00
committed by Herman Chen
parent c72e0b86ad
commit cad4b4b886
6 changed files with 41 additions and 30 deletions

View File

@@ -386,7 +386,7 @@ typedef enum MppEncPrepCfgChange_e {
* 5x5 sharpen core
*
* enable_y - enable luma sharpen
* enable_c - enable chroma sharpen
* enable_uv - enable chroma sharpen
*/
typedef struct {
RK_U32 enable_y;
@@ -396,6 +396,21 @@ typedef struct {
RK_S32 threshold;
} MppEncPrepSharpenCfg;
/*
* input frame rotation parameter
* 0 - disable rotation
* 1 - 90 degree
* 2 - 180 degree
* 3 - 270 degree
*/
typedef enum MppEncRotationCfg_t {
MPP_ENC_ROT_0,
MPP_ENC_ROT_90,
MPP_ENC_ROT_180,
MPP_ENC_ROT_270,
MPP_ENC_ROT_BUTT
} MppEncRotationCfg;
typedef struct MppEncPrepCfg_t {
RK_U32 change;
@@ -418,14 +433,7 @@ typedef struct MppEncPrepCfg_t {
MppFrameFormat format;
MppFrameColorSpace color;
/*
* input frame rotation parameter
* 0 - disable rotation
* 1 - 90 degree
* 2 - 180 degree
* 3 - 270 degree
*/
RK_S32 rotation;
MppEncRotationCfg rotation;
/*
* input frame mirroring parameter

View File

@@ -81,7 +81,7 @@ MPP_RET h264e_init(void *ctx, ControllerCfg *ctrl_cfg)
prep->hor_stride = 1280;
prep->ver_stride = 720;
prep->format = MPP_FMT_YUV420SP;
prep->rotation = 0;
prep->rotation = MPP_ENC_ROT_0;
prep->mirroring = 0;
prep->denoise = 0;

View File

@@ -535,12 +535,6 @@ void mpp_enc_update_prep_cfg(MppEncPrepCfg *dst, MppEncPrepCfg *src)
RK_U32 change = src->change;
if (change) {
if (change & MPP_ENC_PREP_CFG_CHANGE_INPUT) {
dst->width = src->width;
dst->height = src->height;
dst->hor_stride = src->hor_stride;
dst->ver_stride = src->ver_stride;
}
if (change & MPP_ENC_PREP_CFG_CHANGE_FORMAT)
dst->format = src->format;
@@ -557,6 +551,18 @@ void mpp_enc_update_prep_cfg(MppEncPrepCfg *dst, MppEncPrepCfg *src)
if (change & MPP_ENC_PREP_CFG_CHANGE_SHARPEN)
dst->sharpen = src->sharpen;
if (change & MPP_ENC_PREP_CFG_CHANGE_INPUT) {
if (dst->rotation == MPP_ENC_ROT_90 || dst->rotation == MPP_ENC_ROT_270) {
dst->width = src->height;
dst->height = src->width;
} else {
dst->width = src->width;
dst->height = src->height;
}
dst->hor_stride = src->hor_stride;
dst->ver_stride = src->ver_stride;
}
/*
* NOTE: use OR here for avoiding overwrite on multiple config
* When next encoding is trigger the change flag will be clear

View File

@@ -2433,6 +2433,7 @@ static MPP_RET h264e_rkv_set_pp_regs(H264eRkvRegSet *regs, H264eHwCfg *syn,
RK_S32 stridec = 0;
regs->swreg14.src_cfmt = syn->input_format;
regs->swreg19.src_rot = prep_cfg->rotation;
for (k = 0; k < 5; k++)
regs->swreg21_scr_stbl[k] = 0;
@@ -2443,8 +2444,7 @@ static MPP_RET h264e_rkv_set_pp_regs(H264eRkvRegSet *regs, H264eHwCfg *syn,
if (syn->hor_stride) {
stridey = syn->hor_stride - 1;
} else {
stridey = (regs->swreg19.src_rot == 1 || regs->swreg19.src_rot == 3)
? (syn->height - 1) : (syn->width - 1);
stridey = syn->width - 1;
if (regs->swreg14.src_cfmt == 0 )
stridey = (stridey + 1) * 4 - 1;
else if (regs->swreg14.src_cfmt == 1 )
@@ -2531,18 +2531,13 @@ h264e_rkv_update_hw_cfg(H264eHalContext *ctx, HalEncTask *task,
if (change & MPP_ENC_PREP_CFG_CHANGE_INPUT) {
hw_cfg->width = prep->width;
hw_cfg->height = prep->height;
hw_cfg->input_format = prep->format;
hw_cfg->hor_stride = prep->hor_stride;
hw_cfg->ver_stride = prep->ver_stride;
// for smaller resolution, SEI may have a bad influence on RC
if (hw_cfg->width * hw_cfg->height < 640 * 480)
ctx->sei_mode = MPP_ENC_SEI_MODE_DISABLE;
h264e_rkv_set_format(hw_cfg, prep);
}
if (change & MPP_ENC_PREP_CFG_CHANGE_FORMAT) {
hw_cfg->input_format = prep->format;
h264e_rkv_set_format(hw_cfg, prep);
switch (prep->color) {
case MPP_FRAME_SPC_RGB : {
/* BT.601 */
@@ -2880,7 +2875,7 @@ MPP_RET hal_h264e_rkv_gen_regs(void *hal, HalTaskInfo *task)
regs->swreg13.axi_brsp_cke = 0x7f;
regs->swreg13.cime_dspw_orsd = 0x0;
h264e_rkv_set_pp_regs(regs, syn, &ctx->set->prep,
h264e_rkv_set_pp_regs(regs, syn, &ctx->cfg->prep,
bufs->hw_pp_buf[buf2_idx], bufs->hw_pp_buf[1 - buf2_idx]);
h264e_rkv_set_ioctl_extra_info(&ioctl_reg_info->extra_info, syn, regs);

View File

@@ -817,18 +817,18 @@ MPP_RET h264e_vpu_update_hw_cfg(H264eHalContext *ctx, HalEncTask *task,
if (change & MPP_ENC_PREP_CFG_CHANGE_INPUT) {
hw_cfg->width = prep->width;
hw_cfg->height = prep->height;
hw_cfg->input_format = prep->format;
// for libvpu, 8-pixel alignment is enough
mpp_assert(prep->hor_stride == MPP_ALIGN(prep->width, 8));
mpp_assert(prep->ver_stride == MPP_ALIGN(prep->height, 8));
hw_cfg->hor_stride = prep->hor_stride;
hw_cfg->ver_stride = prep->ver_stride;
h264e_vpu_set_format(hw_cfg, prep);
}
if (change & MPP_ENC_PREP_CFG_CHANGE_FORMAT) {
hw_cfg->input_format = prep->format;
h264e_vpu_set_format(hw_cfg, prep);
switch (prep->color) {
case MPP_FRAME_SPC_RGB : {
/* BT.601 */

View File

@@ -521,12 +521,14 @@ MPP_RET test_mpp_setup(MpiEncTestData *p)
p->qp_init = (p->type == MPP_VIDEO_CodingMJPEG) ? (10) : (26);
prep_cfg->change = MPP_ENC_PREP_CFG_CHANGE_INPUT |
MPP_ENC_PREP_CFG_CHANGE_ROTATION |
MPP_ENC_PREP_CFG_CHANGE_FORMAT;
prep_cfg->width = p->width;
prep_cfg->height = p->height;
prep_cfg->hor_stride = p->hor_stride;
prep_cfg->ver_stride = p->ver_stride;
prep_cfg->format = p->fmt;
prep_cfg->rotation = MPP_ENC_ROT_0;
ret = mpi->control(ctx, MPP_ENC_SET_PREP_CFG, prep_cfg);
if (ret) {
mpp_err("mpi control enc set prep cfg failed ret %d\n", ret);