diff options
author | Ming Qian <ming.qian@nxp.com> | 2020-08-28 14:54:32 +0800 |
---|---|---|
committer | Ming Qian <ming.qian@nxp.com> | 2020-08-31 13:32:01 +0800 |
commit | 454af5522985b07eae2b9671046099a98717dec4 (patch) | |
tree | 5f102bc4ae73f3dfebf890d40b4bdd6e7246d6bb /drivers/mxc | |
parent | 0f10fa52f0a638809fda3ee1afa503f1e6eb9538 (diff) |
MLK-24593:[8QM_MEK/8QXP_MEK]mxc:vpu_windsor: support change bitrate dynamically
update the encoder parameters when bitrate is changed
Signed-off-by: Ming Qian <ming.qian@nxp.com>
Reviewed-by: Shijie Qin <shijie.qin@nxp.com>
Diffstat (limited to 'drivers/mxc')
-rw-r--r-- | drivers/mxc/vpu_windsor/vpu_encoder_b0.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/drivers/mxc/vpu_windsor/vpu_encoder_b0.c b/drivers/mxc/vpu_windsor/vpu_encoder_b0.c index d1227440f7d8..6d3188997550 100644 --- a/drivers/mxc/vpu_windsor/vpu_encoder_b0.c +++ b/drivers/mxc/vpu_windsor/vpu_encoder_b0.c @@ -2287,6 +2287,36 @@ static void record_start_time(struct vpu_ctx *ctx, enum QUEUE_TYPE type) ts.tv_nsec / NSEC_PER_MSEC; } +static int update_encode_param(struct vpu_ctx *ctx) +{ + struct vpu_attr *attr; + pMEDIAIP_ENC_PARAM enc_param; + pMEDIAIP_ENC_EXPERT_MODE_PARAM expert; + bool change = false; + + attr = get_vpu_ctx_attr(ctx); + enc_param = get_rpc_enc_param(ctx); + expert = get_rpc_expert_mode_param(ctx); + + if (enc_param->eBitRateMode == MEDIAIP_ENC_BITRATECONTROLMODE_CBR && + attr->param.eBitRateMode == enc_param->eBitRateMode && + attr->param.uTargetBitrate != enc_param->uTargetBitrate) { + vpu_dbg(LVL_CTRL, "[%d] bitrate %d -> %d (kbps)\n", + ctx->str_index, + enc_param->uTargetBitrate, + attr->param.uTargetBitrate); + expert->Static.rate_control_bitrate = + enc_param->uTargetBitrate = attr->param.uTargetBitrate; + change = true; + } + + if (!change) + return 0; + + vpu_ctx_send_cmd(ctx, GTB_ENC_CMD_PARAMETER_UPD, 0, NULL); + return 0; +} + static bool update_yuv_addr(struct vpu_ctx *ctx) { bool bGotAFrame = FALSE; @@ -2311,6 +2341,7 @@ static bool update_yuv_addr(struct vpu_ctx *ctx) if (desc->uLumaBase != 0) bGotAFrame = TRUE; + update_encode_param(ctx); /* * keeps increasing, * so just a frame input count rather than a Frame buffer ID |