gralloc: Add getter and setter for transcode stats feature

Add setter and getter for transcode stats in gralloc.
feature used to set stat info received from video decoder to gralloc.
This decoder stat enables to fine tune encoding in second pass.

Change-Id: I781ce6ea2eadd07bf9b0f38c302f6ce7a05351bb
Signed-off-by: Mahesh Kumar Sharma <quic_smahesh@quicinc.com>
diff --git a/gralloc/QtiGralloc.cpp b/gralloc/QtiGralloc.cpp
index 954c46d..e71e545 100644
--- a/gralloc/QtiGralloc.cpp
+++ b/gralloc/QtiGralloc.cpp
@@ -164,6 +164,23 @@
   return Error::NONE;
 }
 
+Error decodeVideoTranscodeStatsMetadata(hidl_vec<uint8_t> &in, VideoTranscodeStatsMetadata *out) {
+  if (!in.size() || !out) {
+    return Error::BAD_VALUE;
+  }
+  memcpy(out, in.data(), sizeof(VideoTranscodeStatsMetadata));
+  return Error::NONE;
+}
+
+Error encodeVideoTranscodeStatsMetadata(VideoTranscodeStatsMetadata &in, hidl_vec<uint8_t> *out) {
+  if (!out) {
+    return Error::BAD_VALUE;
+  }
+  out->resize(sizeof(VideoTranscodeStatsMetadata));
+  memcpy(out->data(), &in, sizeof(VideoTranscodeStatsMetadata));
+  return Error::NONE;
+}
+
 Error decodeVideoTimestampInfo(hidl_vec<uint8_t> &in, VideoTimestampInfo *out) {
   if (!in.size() || !out) {
     return Error::BAD_VALUE;
@@ -225,6 +242,8 @@
       return MetadataType_CVPMetadata;
     case QTI_VIDEO_HISTOGRAM_STATS:
       return MetadataType_VideoHistogramStats;
+    case QTI_VIDEO_TRANSCODE_STATS:
+      return MetadataType_VideoTranscodeStats;
     case QTI_VIDEO_TS_INFO:
       return MetadataType_VideoTimestampInfo;
     case QTI_FD:
@@ -326,6 +345,10 @@
       err = decodeVideoHistogramMetadata(bytestream,
                                          reinterpret_cast<VideoHistogramMetadata *>(param));
       break;
+    case QTI_VIDEO_TRANSCODE_STATS:
+      err = decodeVideoTranscodeStatsMetadata(bytestream,
+                                   reinterpret_cast<VideoTranscodeStatsMetadata *>(param));
+      break;
     case QTI_VIDEO_TS_INFO:
       err = decodeVideoTimestampInfo(bytestream, reinterpret_cast<VideoTimestampInfo *>(param));
       break;
@@ -449,6 +472,10 @@
       err = encodeVideoHistogramMetadata(*reinterpret_cast<VideoHistogramMetadata *>(param),
                                          &bytestream);
       break;
+    case QTI_VIDEO_TRANSCODE_STATS:
+      err = encodeVideoTranscodeStatsMetadata(
+            *reinterpret_cast<VideoTranscodeStatsMetadata *>(param), &bytestream);
+      break;
     case QTI_VIDEO_TS_INFO:
       err = encodeVideoTimestampInfo(*reinterpret_cast<VideoTimestampInfo *>(param), &bytestream);
       break;