video: driver: Add support for AV1 film grain
Add support to handle AV1 bitstreams with flim grain for both UBWC and linear colorformats. Change-Id: Ica07853d992c566c3471dc007ad8c22aba796dd4 Signed-off-by: Mihir Ganu <quic_mganu@quicinc.com>
This commit is contained in:
@@ -1482,7 +1482,7 @@ static struct msm_platform_inst_capability instance_data_kalama[] = {
|
||||
{FILM_GRAIN, DEC, AV1,
|
||||
V4L2_MPEG_MSM_VIDC_DISABLE, V4L2_MPEG_MSM_VIDC_ENABLE,
|
||||
1, V4L2_MPEG_MSM_VIDC_DISABLE,
|
||||
0,
|
||||
V4L2_CID_MPEG_VIDC_AV1D_FILM_GRAIN_PRESENT,
|
||||
HFI_PROP_AV1_FILM_GRAIN_PRESENT},
|
||||
|
||||
{SUPER_BLOCK, DEC, AV1,
|
||||
|
@@ -220,15 +220,22 @@ static u32 msm_vidc_decoder_dpb_size_iris3(struct msm_vidc_inst *inst)
|
||||
return size;
|
||||
}
|
||||
|
||||
/*
|
||||
* For legacy codecs (non-AV1), DPB is calculated only
|
||||
* for linear formats. For AV1, DPB is needed for film-grain
|
||||
* enabled bitstreams (UBWC & linear).
|
||||
*/
|
||||
color_fmt = inst->capabilities->cap[PIX_FMTS].value;
|
||||
if (!is_linear_colorformat(color_fmt))
|
||||
if (!is_linear_colorformat(color_fmt) &&
|
||||
inst->codec != MSM_VIDC_AV1)
|
||||
return size;
|
||||
|
||||
f = &inst->fmts[OUTPUT_PORT];
|
||||
width = f->fmt.pix_mp.width;
|
||||
height = f->fmt.pix_mp.height;
|
||||
|
||||
if (color_fmt == MSM_VIDC_FMT_NV12) {
|
||||
if (color_fmt == MSM_VIDC_FMT_NV12 ||
|
||||
color_fmt == MSM_VIDC_FMT_NV12C) {
|
||||
v4l2_fmt = V4L2_PIX_FMT_VIDC_NV12C;
|
||||
HFI_NV12_UBWC_IL_CALC_BUF_SIZE_V2(size, width, height,
|
||||
VIDEO_Y_STRIDE_BYTES(v4l2_fmt, width), VIDEO_Y_SCANLINES(v4l2_fmt, height),
|
||||
@@ -237,7 +244,8 @@ static u32 msm_vidc_decoder_dpb_size_iris3(struct msm_vidc_inst *inst)
|
||||
height),
|
||||
VIDEO_UV_META_STRIDE(v4l2_fmt, width), VIDEO_UV_META_SCANLINES(v4l2_fmt,
|
||||
height));
|
||||
} else if (color_fmt == MSM_VIDC_FMT_P010) {
|
||||
} else if (color_fmt == MSM_VIDC_FMT_P010 ||
|
||||
color_fmt == MSM_VIDC_FMT_TP10C) {
|
||||
v4l2_fmt = V4L2_PIX_FMT_VIDC_TP10C;
|
||||
HFI_YUV420_TP10_UBWC_CALC_BUF_SIZE(size,
|
||||
VIDEO_Y_STRIDE_BYTES(v4l2_fmt, width), VIDEO_Y_SCANLINES(v4l2_fmt, height),
|
||||
@@ -605,7 +613,9 @@ static int msm_buffer_dpb_count(struct msm_vidc_inst *inst)
|
||||
/* decoder dpb buffer count */
|
||||
if (is_decode_session(inst)) {
|
||||
color_fmt = inst->capabilities->cap[PIX_FMTS].value;
|
||||
if (is_linear_colorformat(color_fmt))
|
||||
if (is_linear_colorformat(color_fmt) ||
|
||||
(inst->codec == MSM_VIDC_AV1 &&
|
||||
(inst->capabilities->cap[FILM_GRAIN].value)))
|
||||
count = inst->buffers.output.min_count;
|
||||
|
||||
return count;
|
||||
|
@@ -600,6 +600,36 @@ static int msm_vdec_set_av1_superblock_enabled(struct msm_vidc_inst *inst,
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int msm_vdec_set_opb_enable(struct msm_vidc_inst *inst)
|
||||
{
|
||||
int rc = 0;
|
||||
u32 color_fmt;
|
||||
u32 opb_enable = 0;
|
||||
|
||||
if (inst->codec != MSM_VIDC_AV1)
|
||||
return 0;
|
||||
|
||||
color_fmt = inst->capabilities->cap[PIX_FMTS].value;
|
||||
if (is_linear_colorformat(color_fmt) ||
|
||||
inst->capabilities->cap[FILM_GRAIN].value)
|
||||
opb_enable = 1;
|
||||
|
||||
i_vpr_h(inst, "%s: OPB enable: %d", __func__, opb_enable);
|
||||
rc = venus_hfi_session_property(inst,
|
||||
HFI_PROP_OPB_ENABLE,
|
||||
HFI_HOST_FLAGS_NONE,
|
||||
get_hfi_port(inst, OUTPUT_PORT),
|
||||
HFI_PAYLOAD_U32,
|
||||
&opb_enable,
|
||||
sizeof(u32));
|
||||
if (rc) {
|
||||
i_vpr_e(inst, "%s: set property failed\n", __func__);
|
||||
return rc;
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int msm_vdec_set_colorformat(struct msm_vidc_inst *inst)
|
||||
{
|
||||
int rc = 0;
|
||||
@@ -917,6 +947,10 @@ static int msm_vdec_set_output_properties(struct msm_vidc_inst *inst)
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
rc = msm_vdec_set_opb_enable(inst);
|
||||
if (rc)
|
||||
return rc;
|
||||
|
||||
rc = msm_vdec_set_colorformat(inst);
|
||||
if (rc)
|
||||
return rc;
|
||||
|
@@ -533,7 +533,8 @@ exit:
|
||||
void msm_vidc_add_volatile_flag(struct v4l2_ctrl *ctrl)
|
||||
{
|
||||
if (ctrl->id == V4L2_CID_MIN_BUFFERS_FOR_OUTPUT ||
|
||||
ctrl->id == V4L2_CID_MIN_BUFFERS_FOR_CAPTURE)
|
||||
ctrl->id == V4L2_CID_MIN_BUFFERS_FOR_CAPTURE ||
|
||||
ctrl->id == V4L2_CID_MPEG_VIDC_AV1D_FILM_GRAIN_PRESENT)
|
||||
ctrl->flags |= V4L2_CTRL_FLAG_VOLATILE;
|
||||
}
|
||||
|
||||
|
@@ -2027,6 +2027,11 @@ int msm_vidc_get_control(struct msm_vidc_inst *inst, struct v4l2_ctrl *ctrl)
|
||||
inst->buffers.input.extra_count;
|
||||
i_vpr_h(inst, "g_min: input buffers %d\n", ctrl->val);
|
||||
break;
|
||||
case V4L2_CID_MPEG_VIDC_AV1D_FILM_GRAIN_PRESENT:
|
||||
ctrl->val = inst->capabilities->cap[FILM_GRAIN].value;
|
||||
i_vpr_h(inst, "%s: film grain present: %d\n",
|
||||
__func__, ctrl->val);
|
||||
break;
|
||||
default:
|
||||
i_vpr_e(inst, "invalid ctrl %s id %d\n",
|
||||
ctrl->name, ctrl->id);
|
||||
|
@@ -191,6 +191,9 @@ enum v4l2_mpeg_video_av1_tier {
|
||||
};
|
||||
/* Decoder Timestamp Reorder control */
|
||||
#define V4L2_CID_MPEG_VIDC_TS_REORDER (V4L2_CID_MPEG_VIDC_BASE + 0x34)
|
||||
/* AV1 Decoder Film Grain */
|
||||
#define V4L2_CID_MPEG_VIDC_AV1D_FILM_GRAIN_PRESENT \
|
||||
(V4L2_CID_MPEG_VIDC_BASE + 0x35)
|
||||
|
||||
/* Deprecate below controls once availble in gki and gsi bionic header */
|
||||
#ifndef V4L2_CID_MPEG_VIDEO_BASELAYER_PRIORITY_ID
|
||||
|
Reference in New Issue
Block a user