payload_type = HFI_PAYLOAD_U32;
} else {
codec_align = inst->codec == V4L2_PIX_FMT_HEVC ? 32 : 16;
- resolution = ALIGN(inst->fmt_dst->fmt.pix_mp.width, codec_align) << 16 |
- ALIGN(inst->fmt_dst->fmt.pix_mp.height, codec_align);
+ resolution = ALIGN(inst->enc_scale_width, codec_align) << 16 |
+ ALIGN(inst->enc_scale_height, codec_align);
inst_hfi_gen2->dst_subcr_params.bitstream_resolution = resolution;
payload_type = HFI_PAYLOAD_32_PACKED;
}
left_offset = inst->crop.left;
top_offset = inst->crop.top;
} else {
- bottom_offset = (ALIGN(inst->fmt_dst->fmt.pix_mp.height, codec_align) -
- inst->fmt_dst->fmt.pix_mp.height);
- right_offset = (ALIGN(inst->fmt_dst->fmt.pix_mp.width, codec_align) -
- inst->fmt_dst->fmt.pix_mp.width);
+ bottom_offset = (ALIGN(inst->enc_scale_height, codec_align) -
+ inst->enc_scale_height);
+ right_offset = (ALIGN(inst->enc_scale_width, codec_align) -
+ inst->enc_scale_width);
left_offset = 0;
top_offset = 0;
}
return BUF_PERSIST;
case HFI_BUFFER_PARTIAL_DATA:
return BUF_PARTIAL;
+ case HFI_BUFFER_VPSS:
+ return BUF_VPSS;
default:
return 0;
}
* @hfi_rc_type: rate control type
* @enc_raw_width: source image width for encoder instance
* @enc_raw_height: source image height for encoder instance
+ * @enc_scale_width: scale width for encoder instance
+ * @enc_scale_height: scale height for encoder instance
*/
struct iris_inst {
u32 hfi_rc_type;
u32 enc_raw_width;
u32 enc_raw_height;
+ u32 enc_scale_width;
+ u32 enc_scale_height;
};
#endif
BUF_DPB,
};
+static const u32 sm8550_enc_ip_int_buf_tbl[] = {
+ BUF_VPSS,
+};
+
static const u32 sm8550_enc_op_int_buf_tbl[] = {
BUF_BIN,
BUF_COMV,
.dec_op_int_buf_tbl = sm8550_dec_op_int_buf_tbl,
.dec_op_int_buf_tbl_size = ARRAY_SIZE(sm8550_dec_op_int_buf_tbl),
+ .enc_ip_int_buf_tbl = sm8550_enc_ip_int_buf_tbl,
+ .enc_ip_int_buf_tbl_size = ARRAY_SIZE(sm8550_enc_ip_int_buf_tbl),
.enc_op_int_buf_tbl = sm8550_enc_op_int_buf_tbl,
.enc_op_int_buf_tbl_size = ARRAY_SIZE(sm8550_enc_op_int_buf_tbl),
};
.dec_op_int_buf_tbl = sm8550_dec_op_int_buf_tbl,
.dec_op_int_buf_tbl_size = ARRAY_SIZE(sm8550_dec_op_int_buf_tbl),
+ .enc_ip_int_buf_tbl = sm8550_enc_ip_int_buf_tbl,
+ .enc_ip_int_buf_tbl_size = ARRAY_SIZE(sm8550_enc_ip_int_buf_tbl),
.enc_op_int_buf_tbl = sm8550_enc_op_int_buf_tbl,
.enc_op_int_buf_tbl_size = ARRAY_SIZE(sm8550_enc_op_int_buf_tbl),
};
.dec_op_int_buf_tbl = sm8550_dec_op_int_buf_tbl,
.dec_op_int_buf_tbl_size = ARRAY_SIZE(sm8550_dec_op_int_buf_tbl),
+ .enc_ip_int_buf_tbl = sm8550_enc_ip_int_buf_tbl,
+ .enc_ip_int_buf_tbl_size = ARRAY_SIZE(sm8550_enc_ip_int_buf_tbl),
.enc_op_int_buf_tbl = sm8550_enc_op_int_buf_tbl,
.enc_op_int_buf_tbl_size = ARRAY_SIZE(sm8550_enc_op_int_buf_tbl),
};
.dec_op_int_buf_tbl = sm8550_dec_op_int_buf_tbl,
.dec_op_int_buf_tbl_size = ARRAY_SIZE(sm8550_dec_op_int_buf_tbl),
+ .enc_ip_int_buf_tbl = sm8550_enc_ip_int_buf_tbl,
+ .enc_ip_int_buf_tbl_size = ARRAY_SIZE(sm8550_enc_ip_int_buf_tbl),
.enc_op_int_buf_tbl = sm8550_enc_op_int_buf_tbl,
.enc_op_int_buf_tbl_size = ARRAY_SIZE(sm8550_enc_op_int_buf_tbl),
};
inst->enc_raw_width = DEFAULT_WIDTH;
inst->enc_raw_height = DEFAULT_HEIGHT;
+ inst->enc_scale_width = DEFAULT_WIDTH;
+ inst->enc_scale_height = DEFAULT_HEIGHT;
memcpy(&inst->fw_caps[0], &core->inst_fw_caps_enc[0],
INST_FW_CAP_MAX * sizeof(struct platform_inst_fw_cap));
static int iris_venc_s_fmt_output(struct iris_inst *inst, struct v4l2_format *f)
{
+ const struct iris_fmt *venc_fmt;
struct v4l2_format *fmt;
+ u32 codec_align;
iris_venc_try_fmt(inst, f);
- if (!(find_format(inst, f->fmt.pix_mp.pixelformat, f->type)))
+ venc_fmt = find_format(inst, f->fmt.pix_mp.pixelformat, f->type);
+ if (!venc_fmt)
return -EINVAL;
+ codec_align = venc_fmt->pixfmt == V4L2_PIX_FMT_HEVC ? 32 : 16;
+
fmt = inst->fmt_dst;
fmt->type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
+ /*
+ * If output format size != input format size,
+ * it is considered a scaling case,
+ * and the scaled size needs to be saved.
+ */
+ if (f->fmt.pix_mp.width != inst->fmt_src->fmt.pix_mp.width ||
+ f->fmt.pix_mp.height != inst->fmt_src->fmt.pix_mp.height) {
+ inst->enc_scale_width = f->fmt.pix_mp.width;
+ inst->enc_scale_height = f->fmt.pix_mp.height;
+ fmt->fmt.pix_mp.width = ALIGN(f->fmt.pix_mp.width, codec_align);
+ fmt->fmt.pix_mp.height = ALIGN(f->fmt.pix_mp.height, codec_align);
+ }
fmt->fmt.pix_mp.num_planes = 1;
fmt->fmt.pix_mp.plane_fmt[0].bytesperline = 0;
fmt->fmt.pix_mp.plane_fmt[0].sizeimage = iris_get_buffer_size(inst, BUF_OUTPUT);
inst->enc_raw_width = f->fmt.pix_mp.width;
inst->enc_raw_height = f->fmt.pix_mp.height;
+ inst->enc_scale_width = f->fmt.pix_mp.width;
+ inst->enc_scale_height = f->fmt.pix_mp.height;
if (f->fmt.pix_mp.width != inst->crop.width ||
f->fmt.pix_mp.height != inst->crop.height) {
inline bool is_scaling_enabled(struct iris_inst *inst)
{
- return inst->crop.left != inst->compose.left ||
- inst->crop.top != inst->compose.top ||
- inst->crop.width != inst->compose.width ||
- inst->crop.height != inst->compose.height;
+ struct v4l2_pix_format_mplane *dst_fmt = &inst->fmt_dst->fmt.pix_mp;
+ struct v4l2_pix_format_mplane *src_fmt = &inst->fmt_src->fmt.pix_mp;
+
+ return dst_fmt->width != src_fmt->width ||
+ dst_fmt->height != src_fmt->height;
}
static inline