diff options
author | Umang Jain <email@uajain.com> | 2020-09-09 16:44:45 +0530 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2020-09-10 07:12:47 +0300 |
commit | 6f09a619cca412f029c124cff8bbf1647d3d68cf (patch) | |
tree | 1e2dfd0e54e1c0f95af95bc0e9d97a7b1fafeae2 /src/android/jpeg/exif.cpp | |
parent | c3d1329b93f0e27cb4b58c998c540c92a8158f20 (diff) |
android: jpeg: Support an initial set of EXIF metadata tags
Create a Exif object with various metadata tags set, just before
the encoder starts to encode the frame. The object is passed
directly as libcamera::Span<> to make sure EXIF tags can be set
in a single place i.e. in CameraDevice and the encoder only has
the job to write the data in the final output.
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.cpp')
-rw-r--r-- | src/android/jpeg/exif.cpp | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/src/android/jpeg/exif.cpp b/src/android/jpeg/exif.cpp index 0e2d364d..1ced5534 100644 --- a/src/android/jpeg/exif.cpp +++ b/src/android/jpeg/exif.cpp @@ -168,6 +168,56 @@ void Exif::setString(ExifIfd ifd, ExifTag tag, ExifFormat format, const std::str exif_entry_unref(entry); } +void Exif::setMake(const std::string &make) +{ + setString(EXIF_IFD_0, EXIF_TAG_MAKE, EXIF_FORMAT_ASCII, make); +} + +void Exif::setModel(const std::string &model) +{ + setString(EXIF_IFD_0, EXIF_TAG_MODEL, EXIF_FORMAT_ASCII, model); +} + +void Exif::setSize(const Size &size) +{ + setLong(EXIF_IFD_EXIF, EXIF_TAG_PIXEL_Y_DIMENSION, size.height); + setLong(EXIF_IFD_EXIF, EXIF_TAG_PIXEL_X_DIMENSION, size.width); +} + +void Exif::setTimestamp(time_t timestamp) +{ + char str[20]; + std::strftime(str, sizeof(str), "%Y:%m:%d %H:%M:%S", + std::localtime(×tamp)); + std::string ts(str); + + setString(EXIF_IFD_0, EXIF_TAG_DATE_TIME, EXIF_FORMAT_ASCII, ts); + setString(EXIF_IFD_EXIF, EXIF_TAG_DATE_TIME_ORIGINAL, EXIF_FORMAT_ASCII, ts); + setString(EXIF_IFD_EXIF, EXIF_TAG_DATE_TIME_DIGITIZED, EXIF_FORMAT_ASCII, ts); +} + +void Exif::setOrientation(int orientation) +{ + int value; + switch (orientation) { + case 0: + default: + value = 1; + break; + case 90: + value = 8; + break; + case 180: + value = 3; + break; + case 270: + value = 6; + break; + } + + setShort(EXIF_IFD_0, EXIF_TAG_ORIENTATION, value); +} + [[nodiscard]] int Exif::generate() { if (exifData_) { |