Merge 5b94666d2622f7e8dd58609ca0057250d0fb1b6f on remote branch
Change-Id: Ic5b7bfbe97a14fcb7d256cafc59b077c32daf234
diff --git a/gralloc/QtiGralloc.cpp b/gralloc/QtiGralloc.cpp
index e71e545..e913090 100644
--- a/gralloc/QtiGralloc.cpp
+++ b/gralloc/QtiGralloc.cpp
@@ -30,6 +30,8 @@
#include "QtiGralloc.h"
#include <log/log.h>
+#include "color_extensions.h"
+
namespace qtigralloc {
using android::hardware::graphics::mapper::V4_0::IMapper;
@@ -216,6 +218,38 @@
return Error::NONE;
}
+Error decodeCustomContentMetadata(hidl_vec<uint8_t> &in, void *out) {
+ static size_t target_size = sizeof(CustomContentMetadata);
+
+ if (in.size() != target_size || !out) {
+ return Error::BAD_VALUE;
+ }
+
+ CustomContentMetadata *c_md_in = reinterpret_cast<CustomContentMetadata *>(in.data());
+ CustomContentMetadata *c_md_out = reinterpret_cast<CustomContentMetadata *>(out);
+
+ if (c_md_in->size > CUSTOM_METADATA_SIZE_BYTES) {
+ return Error::BAD_VALUE;
+ }
+
+ c_md_out->size = c_md_in->size;
+ memcpy(c_md_out->metadataPayload, c_md_in->metadataPayload, c_md_in->size);
+ return Error::NONE;
+}
+
+Error encodeCustomContentMetadata(const void *in, hidl_vec<uint8_t> *out) {
+ static size_t target_size = sizeof(CustomContentMetadata);
+
+ if (!in || !out) {
+ return Error::BAD_VALUE;
+ }
+
+ out->resize(target_size);
+
+ memcpy(out->data(), in, target_size);
+ return Error::NONE;
+}
+
MetadataType getMetadataType(uint32_t in) {
switch (in) {
case QTI_VT_TIMESTAMP:
@@ -272,6 +306,8 @@
return MetadataType_YuvPlaneInfo;
case QTI_TIMED_RENDERING:
return MetadataType_TimedRendering;
+ case QTI_CUSTOM_CONTENT_METADATA:
+ return MetadataType_CustomContentMetadata;
default:
return MetadataType_Invalid;
}
@@ -404,6 +440,9 @@
err = static_cast<Error>(android::gralloc4::decodeUint32(
qtigralloc::MetadataType_TimedRendering, bytestream, reinterpret_cast<uint32_t *>(param)));
break;
+ case QTI_CUSTOM_CONTENT_METADATA:
+ err = decodeCustomContentMetadata(bytestream, param);
+ break;
default:
param = nullptr;
return Error::UNSUPPORTED;
@@ -484,6 +523,9 @@
android::gralloc4::encodeUint32(qtigralloc::MetadataType_TimedRendering,
*reinterpret_cast<uint32_t *>(param), &bytestream));
break;
+ case QTI_CUSTOM_CONTENT_METADATA:
+ err = encodeCustomContentMetadata(param, &bytestream);
+ break;
default:
param = nullptr;
return Error::UNSUPPORTED;