mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-08 20:07:46 +09:00
CHROMIUM: [media] rk3288-vpu: Add helper for encode plane sizes calculation
Currently plane sizes calculation on encoder side is happening only in vidioc_s_fmt() function, howerver as a prerequisite for further patch adding further code which needs this operation, this patch adds a common helper function, which performs this operation. BUG=chrome-os-partner:41585 TEST=AppRTC loopback Signed-off-by: Tomasz Figa <tfiga@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/289047 Reviewed-by: Pawel Osciak <posciak@chromium.org> Change-Id: I6e5769667ae40b3fb5758ce9471b4ddd6866183f Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com> Signed-off-by: Yakir Yang <ykk@rock-chips.com>
This commit is contained in:
@@ -536,6 +536,25 @@ static int vidioc_try_fmt(struct file *file, void *priv, struct v4l2_format *f)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void calculate_plane_sizes(struct rk3288_vpu_fmt *fmt,
|
||||
unsigned int w, unsigned int h,
|
||||
struct v4l2_pix_format_mplane *pix_fmt_mp)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < fmt->num_planes; ++i) {
|
||||
pix_fmt_mp->plane_fmt[i].bytesperline = w * fmt->depth[i] / 8;
|
||||
pix_fmt_mp->plane_fmt[i].sizeimage = h *
|
||||
pix_fmt_mp->plane_fmt[i].bytesperline;
|
||||
/*
|
||||
* All of multiplanar formats we support have chroma
|
||||
* planes subsampled by 2 vertically.
|
||||
*/
|
||||
if (i != 0)
|
||||
pix_fmt_mp->plane_fmt[i].sizeimage /= 2;
|
||||
}
|
||||
}
|
||||
|
||||
static int vidioc_s_fmt(struct file *file, void *priv, struct v4l2_format *f)
|
||||
{
|
||||
struct v4l2_pix_format_mplane *pix_fmt_mp = &f->fmt.pix_mp;
|
||||
@@ -543,7 +562,6 @@ static int vidioc_s_fmt(struct file *file, void *priv, struct v4l2_format *f)
|
||||
unsigned int mb_width, mb_height;
|
||||
struct rk3288_vpu_fmt *fmt;
|
||||
int ret = 0;
|
||||
int i;
|
||||
|
||||
vpu_debug_enter();
|
||||
|
||||
@@ -599,19 +617,8 @@ static int vidioc_s_fmt(struct file *file, void *priv, struct v4l2_format *f)
|
||||
pix_fmt_mp->width, pix_fmt_mp->height,
|
||||
mb_width, mb_height);
|
||||
|
||||
for (i = 0; i < fmt->num_planes; ++i) {
|
||||
pix_fmt_mp->plane_fmt[i].bytesperline =
|
||||
mb_width * MB_DIM * fmt->depth[i] / 8;
|
||||
pix_fmt_mp->plane_fmt[i].sizeimage =
|
||||
pix_fmt_mp->plane_fmt[i].bytesperline
|
||||
* mb_height * MB_DIM;
|
||||
/*
|
||||
* All of multiplanar formats we support have chroma
|
||||
* planes subsampled by 2.
|
||||
*/
|
||||
if (i != 0)
|
||||
pix_fmt_mp->plane_fmt[i].sizeimage /= 2;
|
||||
}
|
||||
calculate_plane_sizes(fmt, mb_width * MB_DIM,
|
||||
mb_height * MB_DIM, pix_fmt_mp);
|
||||
|
||||
/* Reset crop rectangle. */
|
||||
ctx->src_crop.width = pix_fmt_mp->width;
|
||||
|
||||
Reference in New Issue
Block a user