diff options
author | Philipp Zabel <p.zabel@pengutronix.de> | 2020-03-18 21:36:49 +0300 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab+huawei@kernel.org> | 2020-04-21 18:21:31 +0300 |
commit | 66f92c4e1701d9d3c8b97503bd3aeb614a441a62 (patch) | |
tree | b61a0418ddedeb5ad31dc31707853001f69926d9 | |
parent | 1d3ac27801e51ca919ba78350d0b0079ceb1a39b (diff) | |
download | linux-66f92c4e1701d9d3c8b97503bd3aeb614a441a62.tar.xz |
media: coda: add RC enable controls
Currently the encoder enables the rate control algorithms if the bitrate
control is non-zero. Implement the V4L2_CID_MPEG_VIDEO_FRAME_RC_ENABLE
and V4L2_CID_MPEG_VIDEO_MB_RC_ENABLE controls to allow userspace to
choose frame-level or macroblock-level rate control updates, or to
explicitly disable rate control. Both controls are initially enabled to
keep the current behavior.
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
-rw-r--r-- | drivers/media/platform/coda/coda-bit.c | 9 | ||||
-rw-r--r-- | drivers/media/platform/coda/coda-common.c | 10 | ||||
-rw-r--r-- | drivers/media/platform/coda/coda.h | 2 |
3 files changed, 19 insertions, 2 deletions
diff --git a/drivers/media/platform/coda/coda-bit.c b/drivers/media/platform/coda/coda-bit.c index 3443396ba5f3..b021604eceaa 100644 --- a/drivers/media/platform/coda/coda-bit.c +++ b/drivers/media/platform/coda/coda-bit.c @@ -1215,7 +1215,8 @@ static int coda_start_encoding(struct coda_ctx *ctx) coda_write(dev, value, CODA_CMD_ENC_SEQ_GOP_SIZE); } - if (ctx->params.bitrate) { + if (ctx->params.bitrate && (ctx->params.frame_rc_enable || + ctx->params.mb_rc_enable)) { ctx->params.bitrate_changed = false; ctx->params.h264_intra_qp_changed = false; @@ -1276,7 +1277,11 @@ static int coda_start_encoding(struct coda_ctx *ctx) } coda_write(dev, value, CODA_CMD_ENC_SEQ_OPTION); - coda_write(dev, 0, CODA_CMD_ENC_SEQ_RC_INTERVAL_MODE); + if (ctx->params.frame_rc_enable && !ctx->params.mb_rc_enable) + value = 1; + else + value = 0; + coda_write(dev, value, CODA_CMD_ENC_SEQ_RC_INTERVAL_MODE); coda_setup_iram(ctx); diff --git a/drivers/media/platform/coda/coda-common.c b/drivers/media/platform/coda/coda-common.c index 80ad2db3e9c9..6f41f74d492c 100644 --- a/drivers/media/platform/coda/coda-common.c +++ b/drivers/media/platform/coda/coda-common.c @@ -2223,6 +2223,12 @@ static int coda_s_ctrl(struct v4l2_ctrl *ctrl) case V4L2_CID_MPEG_VIDEO_H264_CONSTRAINED_INTRA_PREDICTION: ctx->params.h264_constrained_intra_pred_flag = ctrl->val; break; + case V4L2_CID_MPEG_VIDEO_FRAME_RC_ENABLE: + ctx->params.frame_rc_enable = ctrl->val; + break; + case V4L2_CID_MPEG_VIDEO_MB_RC_ENABLE: + ctx->params.mb_rc_enable = ctrl->val; + break; case V4L2_CID_MPEG_VIDEO_H264_CHROMA_QP_INDEX_OFFSET: ctx->params.h264_chroma_qp_index_offset = ctrl->val; break; @@ -2322,6 +2328,10 @@ static void coda_encode_ctrls(struct coda_ctx *ctx) V4L2_CID_MPEG_VIDEO_H264_CONSTRAINED_INTRA_PREDICTION, 0, 1, 1, 0); v4l2_ctrl_new_std(&ctx->ctrls, &coda_ctrl_ops, + V4L2_CID_MPEG_VIDEO_FRAME_RC_ENABLE, 0, 1, 1, 1); + v4l2_ctrl_new_std(&ctx->ctrls, &coda_ctrl_ops, + V4L2_CID_MPEG_VIDEO_MB_RC_ENABLE, 0, 1, 1, 1); + v4l2_ctrl_new_std(&ctx->ctrls, &coda_ctrl_ops, V4L2_CID_MPEG_VIDEO_H264_CHROMA_QP_INDEX_OFFSET, -12, 12, 1, 0); v4l2_ctrl_new_std_menu(&ctx->ctrls, &coda_ctrl_ops, V4L2_CID_MPEG_VIDEO_H264_PROFILE, diff --git a/drivers/media/platform/coda/coda.h b/drivers/media/platform/coda/coda.h index af0f8252b0c6..b81f3aca9209 100644 --- a/drivers/media/platform/coda/coda.h +++ b/drivers/media/platform/coda/coda.h @@ -148,6 +148,8 @@ struct coda_params { bool h264_intra_qp_changed; bool intra_refresh_changed; bool slice_mode_changed; + bool frame_rc_enable; + bool mb_rc_enable; }; struct coda_buffer_meta { |