summaryrefslogtreecommitdiff
path: root/gralloc/QtiGralloc.cpp
diff options
context:
space:
mode:
authorChristopher Braga <quic_cbraga@quicinc.com>2022-10-18 17:41:10 -0400
committerGerrit - the friendly Code Review server <code-review@localhost>2023-03-07 07:49:31 -0800
commit5b94666d2622f7e8dd58609ca0057250d0fb1b6f (patch)
tree5915323508a78248f704bc2d06431add7d0d9f01 /gralloc/QtiGralloc.cpp
parentda003a2f1e20e737be010f19705b036bc78bc38e (diff)
gralloc: Add handling for custom content metadata
Update QtiGralloc to support getting and setting custom content metadata. Change-Id: I6f79eb0d39a82668ef7fb99e30669eb367ef00b1
Diffstat (limited to 'gralloc/QtiGralloc.cpp')
-rw-r--r--gralloc/QtiGralloc.cpp42
1 files changed, 42 insertions, 0 deletions
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 @@ Error encodeYUVPlaneInfoMetadata(qti_ycbcr *in, hidl_vec<uint8_t> *out) {
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 @@ MetadataType getMetadataType(uint32_t in) {
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 @@ Error get(void *buffer, uint32_t type, void *param) {
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 @@ Error set(void *buffer, uint32_t type, void *param) {
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;