video: driver: add ROI metadata support
add extra size for input meta buffer when ROI metadata is enabled. add dependency of rate control and color format. Change-Id: Icefd3f9e319d596f88090cee331417c0b2946180 Signed-off-by: Darshana Patil <darshana@codeaurora.org>
This commit is contained in:
@@ -119,7 +119,11 @@ static struct msm_platform_inst_capability instance_data_waipio[] = {
|
||||
MSM_VIDC_FMT_NV12C,
|
||||
MSM_VIDC_FMT_NV12 | MSM_VIDC_FMT_NV21 | MSM_VIDC_FMT_NV12C |
|
||||
MSM_VIDC_FMT_RGBA8888 | MSM_VIDC_FMT_RGBA8888C,
|
||||
MSM_VIDC_FMT_NV12C},
|
||||
MSM_VIDC_FMT_NV12C,
|
||||
0, 0,
|
||||
CAP_FLAG_ROOT,
|
||||
{0},
|
||||
{META_ROI_INFO}},
|
||||
{PIX_FMTS, ENC, HEVC,
|
||||
MSM_VIDC_FMT_NV12,
|
||||
MSM_VIDC_FMT_TP10C,
|
||||
@@ -130,7 +134,7 @@ static struct msm_platform_inst_capability instance_data_waipio[] = {
|
||||
0, 0,
|
||||
CAP_FLAG_ROOT,
|
||||
{0},
|
||||
{PROFILE, MIN_FRAME_QP, MAX_FRAME_QP, I_FRAME_QP}},
|
||||
{PROFILE, MIN_FRAME_QP, MAX_FRAME_QP, I_FRAME_QP, META_ROI_INFO}},
|
||||
|
||||
{PIX_FMTS, DEC, HEVC|HEIC,
|
||||
MSM_VIDC_FMT_NV12,
|
||||
@@ -335,7 +339,7 @@ static struct msm_platform_inst_capability instance_data_waipio[] = {
|
||||
{LTR_COUNT, IR_RANDOM, TIME_DELTA_BASED_RC, I_FRAME_QP,
|
||||
ENH_LAYER_COUNT, BIT_RATE, CONTENT_ADAPTIVE_CODING,
|
||||
BITRATE_BOOST, MIN_QUALITY, VBV_DELAY, PEAK_BITRATE,
|
||||
SLICE_MODE},
|
||||
SLICE_MODE, META_ROI_INFO},
|
||||
msm_vidc_adjust_bitrate_mode, msm_vidc_set_u32_enum},
|
||||
|
||||
{BITRATE_MODE, ENC, HEVC,
|
||||
@@ -353,7 +357,7 @@ static struct msm_platform_inst_capability instance_data_waipio[] = {
|
||||
CONSTANT_QUALITY, ENH_LAYER_COUNT,
|
||||
CONTENT_ADAPTIVE_CODING, BIT_RATE,
|
||||
BITRATE_BOOST, MIN_QUALITY, VBV_DELAY,
|
||||
PEAK_BITRATE, SLICE_MODE},
|
||||
PEAK_BITRATE, SLICE_MODE, META_ROI_INFO},
|
||||
msm_vidc_adjust_bitrate_mode, msm_vidc_set_u32_enum},
|
||||
|
||||
{LOSSLESS, ENC, HEVC|HEIC,
|
||||
@@ -1290,7 +1294,11 @@ static struct msm_platform_inst_capability instance_data_waipio[] = {
|
||||
V4L2_MPEG_MSM_VIDC_DISABLE, V4L2_MPEG_MSM_VIDC_ENABLE,
|
||||
1, V4L2_MPEG_MSM_VIDC_DISABLE,
|
||||
V4L2_CID_MPEG_VIDC_METADATA_ROI_INFO,
|
||||
HFI_PROP_ROI_INFO},
|
||||
HFI_PROP_ROI_INFO,
|
||||
CAP_FLAG_INPUT_PORT,
|
||||
{BITRATE_MODE, PIX_FMTS},
|
||||
{0},
|
||||
msm_vidc_adjust_roi_info, NULL},
|
||||
|
||||
/* configure image properties */
|
||||
{FRAME_WIDTH, ENC, HEIC, 512, 16384, 1, 16384},
|
||||
|
@@ -39,6 +39,7 @@ int msm_vidc_adjust_hevc_max_qp(void *instance, struct v4l2_ctrl *ctrl);
|
||||
int msm_vidc_adjust_hevc_frame_qp(void *instance, struct v4l2_ctrl *ctrl);
|
||||
int msm_vidc_adjust_v4l2_properties(struct msm_vidc_inst *inst);
|
||||
int msm_vidc_adjust_session_priority(void *instance, struct v4l2_ctrl *ctrl);
|
||||
int msm_vidc_adjust_roi_info(void *instance, struct v4l2_ctrl *ctrl);
|
||||
|
||||
int msm_vidc_set_header_mode(void *instance,
|
||||
enum msm_vidc_inst_capability_type cap_id);
|
||||
|
@@ -87,7 +87,8 @@ static inline bool is_input_meta_enabled(struct msm_vidc_inst *inst)
|
||||
} else if (is_encode_session(inst)) {
|
||||
enabled = (inst->capabilities->cap[META_SEQ_HDR_NAL].value ||
|
||||
inst->capabilities->cap[META_EVA_STATS].value ||
|
||||
inst->capabilities->cap[META_BUF_TAG].value);
|
||||
inst->capabilities->cap[META_BUF_TAG].value ||
|
||||
inst->capabilities->cap[META_ROI_INFO].value);
|
||||
}
|
||||
return enabled;
|
||||
}
|
||||
|
@@ -340,9 +340,47 @@ skip_calc:
|
||||
return ALIGN(frame_size, SZ_4K);
|
||||
}
|
||||
|
||||
static inline u32 ROI_METADATA_SIZE(
|
||||
u32 width, u32 height, u32 lcu_size) {
|
||||
u32 lcu_width = 0;
|
||||
u32 lcu_height = 0;
|
||||
u32 n_shift = 0;
|
||||
|
||||
while (lcu_size && !(lcu_size & 0x1)) {
|
||||
n_shift++;
|
||||
lcu_size = lcu_size >> 1;
|
||||
}
|
||||
lcu_width = (width + (lcu_size - 1)) >> n_shift;
|
||||
lcu_height = (height + (lcu_size - 1)) >> n_shift;
|
||||
|
||||
return (((lcu_width + 7) >> 3) << 3) * lcu_height * 2;
|
||||
}
|
||||
|
||||
u32 msm_vidc_encoder_input_meta_size(struct msm_vidc_inst *inst)
|
||||
{
|
||||
return ALIGN(1 * 1024 * 1024, SZ_4K);
|
||||
u32 size = 0;
|
||||
u32 lcu_size = 0;
|
||||
struct v4l2_format *f;
|
||||
|
||||
if (!inst || !inst->capabilities) {
|
||||
d_vpr_e("%s: invalid params\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
size = ALIGN(16 * 1024, SZ_4K);
|
||||
|
||||
if (inst->capabilities->cap[META_ROI_INFO].value) {
|
||||
lcu_size = 16;
|
||||
|
||||
f = &inst->fmts[OUTPUT_PORT];
|
||||
if (f->fmt.pix_mp.pixelformat == V4L2_PIX_FMT_HEVC)
|
||||
lcu_size = 32;
|
||||
|
||||
f = &inst->fmts[INPUT_PORT];
|
||||
size += ROI_METADATA_SIZE(f->fmt.pix_mp.width,
|
||||
f->fmt.pix_mp.height, lcu_size);
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
u32 msm_vidc_encoder_output_meta_size(struct msm_vidc_inst *inst)
|
||||
|
@@ -1629,6 +1629,38 @@ int msm_vidc_adjust_session_priority(void *instance, struct v4l2_ctrl *ctrl)
|
||||
return rc;
|
||||
}
|
||||
|
||||
int msm_vidc_adjust_roi_info(void *instance, struct v4l2_ctrl *ctrl)
|
||||
{
|
||||
struct msm_vidc_inst_capability *capability;
|
||||
s32 adjusted_value;
|
||||
struct msm_vidc_inst *inst = (struct msm_vidc_inst *) instance;
|
||||
s32 rc_type = -1, pix_fmt = -1;
|
||||
|
||||
if (!inst || !inst->capabilities) {
|
||||
d_vpr_e("%s: invalid params\n", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
capability = inst->capabilities;
|
||||
|
||||
adjusted_value = ctrl ? ctrl->val : capability->cap[META_ROI_INFO].value;
|
||||
|
||||
if (msm_vidc_get_parent_value(inst, META_ROI_INFO, BITRATE_MODE,
|
||||
&rc_type, __func__))
|
||||
return -EINVAL;
|
||||
|
||||
if (msm_vidc_get_parent_value(inst, META_ROI_INFO, PIX_FMTS,
|
||||
&pix_fmt, __func__))
|
||||
return -EINVAL;
|
||||
|
||||
if (rc_type != HFI_RC_VBR_CFR || !is_8bit_colorformat(pix_fmt))
|
||||
adjusted_value = 0;
|
||||
|
||||
msm_vidc_update_cap_value(inst, META_ROI_INFO,
|
||||
adjusted_value, __func__);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Loop over instance capabilities with CAP_FLAG_ROOT
|
||||
* and call adjust function, where
|
||||
|
Reference in New Issue
Block a user