Merge "gralloc: Update buffer size calc for NV12 color formats"
diff --git a/gralloc/QtiMapper4.h b/gralloc/QtiMapper4.h
index 3c5137f..936393d 100644
--- a/gralloc/QtiMapper4.h
+++ b/gralloc/QtiMapper4.h
@@ -267,7 +267,10 @@
       {qtigralloc::MetadataType_AlignedHeightInPixels, "height in private_handle_t", true, false},
 #ifdef METADATA_V2
       {qtigralloc::MetadataType_StandardMetadataStatus, "Is standard metadata set", true, false},
-      {qtigralloc::MetadataType_VendorMetadataStatus, "Is vendor metadata set", true, false}
+      {qtigralloc::MetadataType_VendorMetadataStatus, "Is vendor metadata set", true, false},
+#endif
+#ifdef QTI_BUFFER_TYPE
+      {qtigralloc::MetadataType_BufferType, "Buffer type from private_handle_t", true, false},
 #endif
   };
 };
diff --git a/gralloc/gr_buf_mgr.cpp b/gralloc/gr_buf_mgr.cpp
index 7e9f57f..825d20b 100644
--- a/gralloc/gr_buf_mgr.cpp
+++ b/gralloc/gr_buf_mgr.cpp
@@ -1392,6 +1392,12 @@
       qtigralloc::encodeMetadataState(metadata->isVendorMetadataSet, out);
       break;
 #endif
+#ifdef QTI_BUFFER_TYPE
+    case QTI_BUFFER_TYPE:
+      android::gralloc4::encodeUint32(qtigralloc::MetadataType_BufferType, handle->buffer_type,
+                                      out);
+      break;
+#endif
     default:
       error = Error::UNSUPPORTED;
   }
diff --git a/gralloc/gr_utils.cpp b/gralloc/gr_utils.cpp
index 0cd2276..21e504a 100644
--- a/gralloc/gr_utils.cpp
+++ b/gralloc/gr_utils.cpp
@@ -658,6 +658,9 @@
   plane_info[0].step = step;
   plane_info[0].stride = width;
   plane_info[0].stride_bytes = static_cast<int32_t>(alignedWidth);
+  if (format == HAL_PIXEL_FORMAT_RAW16) {
+    plane_info[0].stride_bytes = static_cast<int32_t>(alignedWidth * GetBpp(format));
+  }
   plane_info[0].scanlines = height;
   plane_info[0].size = size;