Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 49d80b2a authored by Amit Shekhar's avatar Amit Shekhar
Browse files

msm: vidc: Fix buffer size calculation



Fix buffer size calculation for NV12, NV21 and UBWC color format to
accommodate last row buffers for any frame whose size is not a
multiple of 512x512.

Change-Id: I97c7e01b10cfce90203c3babcdeb6513d0003d34
Signed-off-by: default avatarAmit Shekhar <ashekhar@codeaurora.org>
parent c287f849
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -1229,6 +1229,7 @@ static inline unsigned int VENUS_BUFFER_SIZE(
{
	const unsigned int extra_size = VENUS_EXTRADATA_SIZE(width, height);
	unsigned int uv_alignment = 0, size = 0;
	unsigned int w_alignment = 512;
	unsigned int y_plane, uv_plane, y_stride,
		uv_stride, y_sclines, uv_sclines;
	unsigned int y_ubwc_plane = 0, uv_ubwc_plane = 0;
@@ -1252,6 +1253,17 @@ static inline unsigned int VENUS_BUFFER_SIZE(
	switch (color_fmt) {
	case COLOR_FMT_NV21:
	case COLOR_FMT_NV12:
		uv_alignment = 4096;
		y_plane = y_stride * y_sclines;
		uv_plane = uv_stride * uv_sclines + uv_alignment;
		size = y_plane + uv_plane +
				MSM_MEDIA_MAX(extra_size, 8 * y_stride);
		size = MSM_MEDIA_ALIGN(size, 4096);

		/* Additional size to cover last row of non-aligned frame */
		size += MSM_MEDIA_ALIGN(width, w_alignment) * w_alignment;
		size = MSM_MEDIA_ALIGN(size, 4096);
		break;
	case COLOR_FMT_P010:
		uv_alignment = 4096;
		y_plane = y_stride * y_sclines;
@@ -1288,6 +1300,10 @@ static inline unsigned int VENUS_BUFFER_SIZE(
			uv_meta_plane)*2 +
			MSM_MEDIA_MAX(extra_size + 8192, 48 * y_stride);
		size = MSM_MEDIA_ALIGN(size, 4096);

		/* Additional size to cover last row of non-aligned frame */
		size += MSM_MEDIA_ALIGN(width, w_alignment) * w_alignment;
		size = MSM_MEDIA_ALIGN(size, 4096);
		break;
	case COLOR_FMT_NV12_BPP10_UBWC:
		y_ubwc_plane = MSM_MEDIA_ALIGN(y_stride * y_sclines, 4096);