gralloc1: Get aligned width and height for ubwc interlaced layout
The get custom stride and height perform api is updated to
calculate aligned width and height for ubwc interlaced layout.
Change-Id: Ibb595ae6bc3bea7dd6abcc6ed6f80ba7c7577fba
CRs-Fixed: 2062852
diff --git a/libgralloc1/gr_buf_mgr.cpp b/libgralloc1/gr_buf_mgr.cpp
index 7e0ba14..bcd3d7a 100644
--- a/libgralloc1/gr_buf_mgr.cpp
+++ b/libgralloc1/gr_buf_mgr.cpp
@@ -630,9 +630,20 @@
}
BufferDim_t buffer_dim;
+ int interlaced = 0;
if (getMetaData(hnd, GET_BUFFER_GEOMETRY, &buffer_dim) == 0) {
*stride = buffer_dim.sliceWidth;
*height = buffer_dim.sliceHeight;
+ } else if (getMetaData(hnd, GET_PP_PARAM_INTERLACED, &interlaced) == 0) {
+ if (interlaced && IsUBwcFormat(hnd->format)) {
+ unsigned int alignedw = 0, alignedh = 0;
+ // Get re-aligned height for single ubwc interlaced field and
+ // multiple by 2 to get frame height.
+ BufferInfo info(hnd->width, ((hnd->height+1)>>1), hnd->format);
+ GetAlignedWidthAndHeight(info, &alignedw, &alignedh);
+ *stride = static_cast<int>(alignedw);
+ *height = static_cast<int>(alignedh * 2);
+ }
} else {
*stride = hnd->width;
*height = hnd->height;