Added FUJIFILM MakerNote

This commit is contained in:
Andreas Huggel 2004-03-18 16:11:19 +00:00
parent 77ad0f778b
commit a080a79cac
3 changed files with 386 additions and 4 deletions

View File

@ -20,7 +20,7 @@
# 02111-1307, USA.
#
# File: Makefile
# Version: $Name: $ $Revision: 1.15 $
# Version: $Name: $ $Revision: 1.16 $
# Author(s): Andreas Huggel (ahu) <ahuggel@gmx.net>
# History: 10-Dec-03, ahu: created
#
@ -51,8 +51,8 @@ include $(top_srcdir)/config.mk
CCHDR = rcsid.hpp error.hpp
# Add library C++ source files to this list
CCSRC = canonmn.cpp exif.cpp ifd.cpp image.cpp makernote.cpp tags.cpp \
types.cpp value.cpp
CCSRC = canonmn.cpp exif.cpp fujimn.cpp ifd.cpp image.cpp makernote.cpp \
tags.cpp types.cpp value.cpp
# Add source files of simple applications to this list
BINSRC = example1.cpp taglist.cpp exifprint.cpp exiftest.cpp makernote-test.cpp \
@ -267,8 +267,8 @@ check:
mostlyclean:
$(RM) core
$(RM) $(CCSRC:.cpp=.ii)
$(RM) .mn.d mn.cpp mn.o
$(RM) $(OBJ) $(SOBJ) $(BINOBJ) $(EXIV2OBJ)
$(RM) mn.o
@if test -n "$(CXX_REPOSITORY)"; then \
echo "rm -rf $(CXX_REPOSITORY)"; \
rm -rf $(CXX_REPOSITORY); \
@ -283,8 +283,10 @@ clean: mostlyclean
distclean: clean
$(RM) tags TAGS
$(RM) $(DEP)
$(RM) .mn.d
$(RM) *~ *#
# This command is intended for maintainers to use; it deletes files
# that may need special tools to rebuild.
maintainer-clean: uninstall uninstall-lib distclean
$(RM) mn.cpp

234
src/fujimn.cpp Normal file
View File

@ -0,0 +1,234 @@
// ***************************************************************** -*- C++ -*-
/*
* Copyright (C) 2004 Andreas Huggel <ahuggel@gmx.net>
*
* This program is part of the Exiv2 distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/*
File: fujimn.cpp
Version: $Name: $ $Revision: 1.1 $
Author(s): Andreas Huggel (ahu) <ahuggel@gmx.net>
History: 18-Feb-04, ahu: created
07-Mar-04, ahu: isolated as a separate component
Credits: Fujifilm MakerNote implemented according to the specification
in "Appendix 4: Makernote of Fujifilm" of the document
"Exif file format" by TsuruZoh Tachibanaya
<http://park2.wakwak.com/%7Etsuruzoh/Computer/Digicams/exif-e.html>
*/
// *****************************************************************************
#include "rcsid.hpp"
EXIV2_RCSID("@(#) $Name: $ $Revision: 1.1 $ $RCSfile: fujimn.cpp,v $")
// *****************************************************************************
// included header files
#include "types.hpp"
#include "fujimn.hpp"
#include "makernote.hpp"
#include "value.hpp"
// + standard includes
#include <string>
#include <sstream>
#include <iomanip>
// Define DEBUG_MAKERNOTE to output debug information to std::cerr
#undef DEBUG_MAKERNOTE
// *****************************************************************************
// class member definitions
namespace Exif {
const FujiMakerNote::RegisterMakerNote FujiMakerNote::register_;
// Fujifilm MakerNote Tag Info
static const MakerNote::MnTagInfo fujiMnTagInfo[] = {
MakerNote::MnTagInfo(0x0000, "Version", "Fujifilm Makernote version"),
MakerNote::MnTagInfo(0x1000, "Quality", "Image quality setting"),
MakerNote::MnTagInfo(0x1001, "Sharpness", "Sharpness setting"),
MakerNote::MnTagInfo(0x1002, "WhiteBalance", "White balance setting"),
MakerNote::MnTagInfo(0x1003, "Color", "Chroma saturation setting"),
MakerNote::MnTagInfo(0x1004, "Tone", "Contrast setting"),
MakerNote::MnTagInfo(0x1010, "FlashMode", "Flash firing mode setting"),
MakerNote::MnTagInfo(0x1011, "FlashStrength", "Flash firing strength compensation setting"),
MakerNote::MnTagInfo(0x1020, "Macro", "Macro mode setting"),
MakerNote::MnTagInfo(0x1021, "FocusMode", "Focusing mode setting"),
MakerNote::MnTagInfo(0x1030, "SlowSync", "Slow synchro mode setting"),
MakerNote::MnTagInfo(0x1031, "PictureMode", "Picture mode setting"),
MakerNote::MnTagInfo(0x1100, "Continuous", "Continuous shooting or auto bracketing setting"),
MakerNote::MnTagInfo(0x1300, "BlurWarning", "Blur warning status"),
MakerNote::MnTagInfo(0x1301, "FoxusWarning", "Auto Focus warning status"),
MakerNote::MnTagInfo(0x1302, "AeWarning", "Auto Exposure warning status"),
// End of list marker
MakerNote::MnTagInfo(0xffff, "(UnknownFujiMakerNoteTag)", "Unknown FujiMakerNote tag")
};
FujiMakerNote::FujiMakerNote(bool alloc)
: IfdMakerNote(fujiMnTagInfo, alloc), sectionName_("Fujifilm")
{
setByteOrder(littleEndian);
prefix_ = std::string("FUJIFILM\xc\0\0\0", 12);
absOffset_ = false;
}
MakerNote* FujiMakerNote::clone(bool alloc) const
{
return createFujiMakerNote(alloc);
}
std::ostream& FujiMakerNote::printTag(std::ostream& os,
uint16 tag,
const Value& value) const
{
switch (tag) {
case 0x1020: // fallthrough
case 0x1030: // fallthrough
case 0x1100: // fallthrough
case 0x1300: // fallthrough
case 0x1301: // fallthrough
case 0x1302: printOffOn(os, value); break;
case 0x1001: print0x1001(os, value); break;
case 0x1002: print0x1002(os, value); break;
case 0x1003: print0x1003(os, value); break;
case 0x1004: print0x1004(os, value); break;
case 0x1010: print0x1010(os, value); break;
case 0x1021: print0x1021(os, value); break;
case 0x1031: print0x1031(os, value); break;
default:
// All other tags (known or unknown) go here
os << value;
break;
}
return os;
}
std::ostream& FujiMakerNote::printOffOn(
std::ostream& os, const Value& value) const
{
switch (value.toLong()) {
case 0: os << "Off"; break;
case 1: os << "On"; break;
default: os << "(" << value << ")"; break;
}
return os;
}
std::ostream& FujiMakerNote::print0x1001(
std::ostream& os, const Value& value) const
{
switch (value.toLong()) {
case 1: // fallthrough
case 2: os << "Soft"; break;
case 3: os << "Normal"; break;
case 4: // fallthrough
case 5: os << "Hard"; break;
default: os << "(" << value << ")"; break;
}
return os;
}
std::ostream& FujiMakerNote::print0x1002(
std::ostream& os, const Value& value) const
{
switch (value.toLong()) {
case 0: os << "Auto"; break;
case 256: os << "Daylight"; break;
case 512: os << "Cloudy"; break;
case 768: os << "Fluorescent (daylight)"; break;
case 769: os << "Fluorescent (warm white)"; break;
case 770: os << "Fluorescent (cool white)"; break;
case 1024: os << "Incandescent"; break;
case 3480: os << "Custom"; break;
default: os << "(" << value << ")"; break;
}
return os;
}
std::ostream& FujiMakerNote::print0x1003(
std::ostream& os, const Value& value) const
{
switch (value.toLong()) {
case 0: os << "Standard"; break;
case 256: os << "High"; break;
case 512: os << "Original"; break;
default: os << "(" << value << ")"; break;
}
return os;
}
std::ostream& FujiMakerNote::print0x1004(
std::ostream& os, const Value& value) const
{
switch (value.toLong()) {
case 0: os << "Standard"; break;
case 256: os << "Hard"; break;
case 512: os << "Original"; break;
default: os << "(" << value << ")"; break;
}
return os;
}
std::ostream& FujiMakerNote::print0x1010(
std::ostream& os, const Value& value) const
{
switch (value.toLong()) {
case 0: os << "Auto"; break;
case 1: os << "On"; break;
case 2: os << "Off"; break;
case 3: os << "Red-eye"; break;
default: os << "(" << value << ")"; break;
}
return os;
}
std::ostream& FujiMakerNote::print0x1021(
std::ostream& os, const Value& value) const
{
switch (value.toLong()) {
case 0: os << "Auto"; break;
case 1: os << "Manual"; break;
default: os << "(" << value << ")"; break;
}
return os;
}
std::ostream& FujiMakerNote::print0x1031(
std::ostream& os, const Value& value) const
{
switch (value.toLong()) {
case 0: os << "Auto"; break;
case 1: os << "Portrait"; break;
case 2: os << "Landscape"; break;
case 4: os << "Sports"; break;
case 5: os << "Night"; break;
case 6: os << "Program"; break;
case 256: os << "Av priority"; break;
case 512: os << "Tv priority"; break;
case 768: os << "Manual"; break;
default: os << "(" << value << ")"; break;
}
return os;
}
// *****************************************************************************
// free functions
MakerNote* createFujiMakerNote(bool alloc)
{
return new FujiMakerNote(alloc);
}
} // namespace Exif

146
src/fujimn.hpp Normal file
View File

@ -0,0 +1,146 @@
// ***************************************************************** -*- C++ -*-
/*
* Copyright (C) 2004 Andreas Huggel <ahuggel@gmx.net>
*
* This program is part of the Exiv2 distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/*!
@file fujimn.hpp
@brief Fujifilm MakerNote implemented according to the specification
in "Appendix 4: Makernote of Fujifilm" of the document
"Exif file format" by TsuruZoh Tachibanaya
<http://park2.wakwak.com/%7Etsuruzoh/Computer/Digicams/exif-e.html>
@version $Name: $ $Revision: 1.1 $
@author Andreas Huggel (ahu)
<a href="mailto:ahuggel@gmx.net">ahuggel@gmx.net</a>
@date 11-Feb-04, ahu: created
*/
#ifndef FUJIMN_HPP_
#define FUJIMN_HPP_
// *****************************************************************************
// included header files
#include "types.hpp"
#include "makernote.hpp"
// + standard includes
#include <string>
#include <iosfwd>
// *****************************************************************************
// namespace extensions
namespace Exif {
// *****************************************************************************
// class declarations
class Value;
// *****************************************************************************
// free functions
/*!
@brief Return a pointer to a newly created empty MakerNote initialized to
operate in the memory management model indicated. The caller owns
this copy and is responsible to delete it!
@param alloc Memory management model for the new MakerNote. Determines if
memory required to store data should be allocated and deallocated
(true) or not (false). If false, only pointers to the buffer
provided to read() will be kept. See Ifd for more background on
this concept.
*/
MakerNote* createFujiMakerNote(bool alloc =true);
// *****************************************************************************
// class definitions
//! MakerNote for Fujifilm cameras
class FujiMakerNote : public IfdMakerNote {
public:
//! @name Creators
//@{
/*!
@brief Constructor. Allows to choose whether or not memory management
is required for the makernote entries.
*/
FujiMakerNote(bool alloc =true);
//! Virtual destructor
virtual ~FujiMakerNote() {}
//@}
//! @name Accessors
//@{
MakerNote* clone(bool alloc =true) const;
//! Return the name of the makernote section ("Fujifilm")
std::string sectionName(uint16 tag) const { return sectionName_; }
std::ostream& printTag(std::ostream& os,
uint16 tag,
const Value& value) const;
//@}
//! @name Print functions for Fujifilm %MakerNote tags
//@{
//! Print Off or On status
std::ostream& printOffOn(std::ostream& os, const Value& value) const;
//! Print sharpness
std::ostream& print0x1001(std::ostream& os, const Value& value) const;
//! Print white balance
std::ostream& print0x1002(std::ostream& os, const Value& value) const;
//! Print color
std::ostream& print0x1003(std::ostream& os, const Value& value) const;
//! Print tone
std::ostream& print0x1004(std::ostream& os, const Value& value) const;
//! Print flash mode
std::ostream& print0x1010(std::ostream& os, const Value& value) const;
//! Print focus mode
std::ostream& print0x1021(std::ostream& os, const Value& value) const;
//! Print picture mode
std::ostream& print0x1031(std::ostream& os, const Value& value) const;
//@}
private:
//! Structure used to auto-register the MakerNote.
struct RegisterMakerNote {
//! Default constructor
RegisterMakerNote()
{
MakerNoteFactory& mnf = MakerNoteFactory::instance();
mnf.registerMakerNote("FUJIFILM", "*", createFujiMakerNote);
}
};
/*!
The static member variable is initialized before main (see note) and
will in the process register the MakerNote class. (Remember the
definition of the variable in the implementation file!)
@note The standard says that, if no function is explicitly called ever
in a module, then that module's static data might be never
initialized. This clause was introduced to allow dynamic link
libraries. The idea is, with this clause the loader is not
forced to eagerly load all modules, but load them only on
demand.
*/
static const RegisterMakerNote register_;
//! The section name (second part of the key) used for makernote tags
std::string sectionName_;
}; // class FujiMakerNote
} // namespace Exif
#endif // #ifndef FUJIMN_HPP_