summaryrefslogtreecommitdiff
path: root/src/android/jpeg/exif.h
diff options
context:
space:
mode:
authorKieran Bingham <kieran.bingham@ideasonboard.com>2020-09-09 16:44:44 +0530
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2020-09-10 07:12:47 +0300
commitc3d1329b93f0e27cb4b58c998c540c92a8158f20 (patch)
tree8ed376bd2cbede739a90646c333fa6035383c4c6 /src/android/jpeg/exif.h
parente917655d06ec86224b10b992e036460a7334b407 (diff)
android: jpeg: Add EXIF infrastructure
Provide helper classes to utilise the libexif interfaces and link against libexif to support tag additions when creating JPEG images. Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Signed-off-by: Umang Jain <email@uajain.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'src/android/jpeg/exif.h')
-rw-r--r--src/android/jpeg/exif.h46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/android/jpeg/exif.h b/src/android/jpeg/exif.h
new file mode 100644
index 00000000..8dfc3245
--- /dev/null
+++ b/src/android/jpeg/exif.h
@@ -0,0 +1,46 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * Copyright (C) 2020, Google Inc.
+ *
+ * exif.h - EXIF tag creator using libexif
+ */
+#ifndef __ANDROID_JPEG_EXIF_H__
+#define __ANDROID_JPEG_EXIF_H__
+
+#include <ctime>
+#include <string>
+
+#include <libexif/exif-data.h>
+
+#include <libcamera/span.h>
+
+class Exif
+{
+public:
+ Exif();
+ ~Exif();
+
+ libcamera::Span<const uint8_t> data() const { return { exifData_, size_ }; }
+ [[nodiscard]] int generate();
+
+private:
+ ExifEntry *createEntry(ExifIfd ifd, ExifTag tag);
+ ExifEntry *createEntry(ExifIfd ifd, ExifTag tag, ExifFormat format,
+ unsigned long components, unsigned int size);
+
+ void setShort(ExifIfd ifd, ExifTag tag, uint16_t item);
+ void setLong(ExifIfd ifd, ExifTag tag, uint32_t item);
+ void setString(ExifIfd ifd, ExifTag tag, ExifFormat format,
+ const std::string &item);
+ void setRational(ExifIfd ifd, ExifTag tag, ExifRational item);
+
+ bool valid_;
+
+ ExifData *data_;
+ ExifMem *mem_;
+
+ unsigned char *exifData_;
+ unsigned int size_;
+};
+
+#endif /* __ANDROID_JPEG_EXIF_H__ */