summaryrefslogtreecommitdiff
path: root/libs/gui/HdrMetadata.cpp
diff options
context:
space:
mode:
author TreeHugger Robot <treehugger-gerrit@google.com> 2018-01-05 03:03:42 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2018-01-05 03:03:42 +0000
commitcdd574e12df39e0921a4b2f3f34955f49b9a3d40 (patch)
tree7310d209b7a70e08d9109147f0810e5b5cb77cac /libs/gui/HdrMetadata.cpp
parent9f2eb0fbbfbbc7c84b95c2da4a3ae6dab32919bd (diff)
parent9bad0d7e726e6b264c528a3dd13d0c58fd92c0e1 (diff)
Merge "Add plumbing for HDR metadata"
Diffstat (limited to 'libs/gui/HdrMetadata.cpp')
-rw-r--r--libs/gui/HdrMetadata.cpp69
1 files changed, 69 insertions, 0 deletions
diff --git a/libs/gui/HdrMetadata.cpp b/libs/gui/HdrMetadata.cpp
new file mode 100644
index 0000000000..299bdfa381
--- /dev/null
+++ b/libs/gui/HdrMetadata.cpp
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <gui/HdrMetadata.h>
+
+namespace android {
+
+size_t HdrMetadata::getFlattenedSize() const {
+ size_t size = sizeof(validTypes);
+ if (validTypes & SMPTE2086) {
+ size += sizeof(smpte2086);
+ }
+ if (validTypes & CTA861_3) {
+ size += sizeof(cta8613);
+ }
+ return size;
+}
+
+status_t HdrMetadata::flatten(void* buffer, size_t size) const {
+ if (size < getFlattenedSize()) {
+ return NO_MEMORY;
+ }
+
+ FlattenableUtils::write(buffer, size, validTypes);
+ if (validTypes & SMPTE2086) {
+ FlattenableUtils::write(buffer, size, smpte2086);
+ }
+ if (validTypes & CTA861_3) {
+ FlattenableUtils::write(buffer, size, cta8613);
+ }
+
+ return NO_ERROR;
+}
+
+status_t HdrMetadata::unflatten(void const* buffer, size_t size) {
+ if (size < sizeof(validTypes)) {
+ return NO_MEMORY;
+ }
+ FlattenableUtils::read(buffer, size, validTypes);
+ if (validTypes & SMPTE2086) {
+ if (size < sizeof(smpte2086)) {
+ return NO_MEMORY;
+ }
+ FlattenableUtils::read(buffer, size, smpte2086);
+ }
+ if (validTypes & CTA861_3) {
+ if (size < sizeof(cta8613)) {
+ return NO_MEMORY;
+ }
+ FlattenableUtils::read(buffer, size, cta8613);
+ }
+
+ return NO_ERROR;
+}
+
+} // namespace android