/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
* Copyright (C) 2020, Google Inc.
*
* exif.cpp - EXIF tag creation using libexif
*/
#include "exif.h"
#include <cmath>
#include <iomanip>
#include <map>
#include <sstream>
#include <tuple>
#include <uchar.h>
#include "libcamera/internal/log.h"
#include "libcamera/internal/utils.h"
using namespace libcamera;
LOG_DEFINE_CATEGORY(EXIF)
/*
* List of EXIF tags that we set directly because they are not supported
* by libexif version 0.6.21.
*/
enum class _ExifTag {
OFFSET_TIME = 0x9010,
OFFSET_TIME_ORIGINAL = 0x9011,
OFFSET_TIME_DIGITIZED = 0x9012,
};
/*
* The Exif class should be instantiated and specific properties set
* through the exposed public API.
*
* Once all desired properties have been set, the user shall call
* generate() to process the entries and generate the Exif data.
*
* Calls to generate() must check the return code to determine if any error
* occurred during the construction of the Exif data, and if successful the
* data can be obtained using the data() method.
*/
Exif::Exif()
: valid_(false), data_(nullptr), order_(EXIF_BYTE_ORDER_INTEL),
exifData_(0), size_(0)
{
/* Create an ExifMem allocator to construct entries. */
mem_ = exif_mem_new_default();
if (!mem_) {
LOG(EXIF, Error) << "Failed to allocate ExifMem Allocator";
return;
}
data_ = exif_data_new_mem(mem_);
if (!data_) {
|