-
Notifications
You must be signed in to change notification settings - Fork 286
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Base Media File Format #1475
Base Media File Format #1475
Changes from 9 commits
92469f4
460a802
0844e1b
fa39234
f5c6e75
e19fca6
2104665
c608148
f0a321d
7b5854e
81e0f99
4fa0a88
04481dd
a75ac74
0360a7d
6d13e44
630fb23
ea96814
0b4b7c6
1b47e1e
64866cc
8976a23
8d7133d
bafea0f
4a96025
f190f49
29f3d5c
28b41f5
108670b
4ff8fcd
913ee33
9515e46
4ae0a1d
4d3af08
3ed67d3
5c77888
c46e800
dcfe538
44d976c
0250046
ca180e0
ea1c918
4ca05ed
f69de0d
fd9cb67
c84274e
0e1412a
55d2201
71d29fe
70eaef9
4d70f5c
4adc301
19fe69c
b983a9d
df68648
a0e6361
ee4d143
c3e7011
0ad4645
5410395
80e2030
1eeeece
3bfea0c
c59c53a
2f2dd7d
21c610e
db9bec3
87e536d
f1303cb
ae66869
2c0f3c2
e09d093
4c52861
0da1a50
9d28943
e3fd0c6
212f1b5
02477fa
19aab43
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
install(FILES | ||
asfvideo.hpp | ||
basicio.hpp | ||
bmffimage.hpp | ||
bmpimage.hpp | ||
config.h | ||
convert.hpp | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
// ***************************************************************** -*- C++ -*- | ||
/* | ||
* Copyright (C) 2021 Exiv2 authors | ||
* 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., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301 USA. | ||
*/ | ||
|
||
#pragma once | ||
|
||
// ***************************************************************************** | ||
#include "exiv2lib_export.h" | ||
|
||
// included header files | ||
#include "image.hpp" | ||
|
||
// ***************************************************************************** | ||
// namespace extensions | ||
namespace Exiv2 | ||
{ | ||
EXIV2API bool enableBMFF(bool enable = true); | ||
hassec marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should not this function has return type There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The return value is important. It tells the caller if the code has been built with BMFF support. In the documentation and samples, we ignore the return value. However, "real" applications can use this to "gray out" a UI option such as "Use bmff support", or to post an alert such as bmff support cannot be enabled on this platform. |
||
|
||
// ***************************************************************************** | ||
// class definitions | ||
|
||
// Add Base Media File Format to the supported image formats | ||
namespace ImageType { | ||
const int bmff = 15; //!< BMFF (bmff) image type (see class BMFF) | ||
} | ||
|
||
/*! | ||
@brief Class to access BMFF images. | ||
*/ | ||
class EXIV2API BmffImage : public Image { | ||
public: | ||
//! @name Creators | ||
//@{ | ||
/*! | ||
@brief Constructor to open a BMFF image. Since the | ||
constructor can not return a result, callers should check the | ||
good() method after object construction to determine success | ||
or failure. | ||
@param io An auto-pointer that owns a BasicIo instance used for | ||
reading and writing image metadata. \b Important: The constructor | ||
takes ownership of the passed in BasicIo instance through the | ||
auto-pointer. Callers should not continue to use the BasicIo | ||
instance after it is passed to this method. Use the Image::io() | ||
method to get a temporary reference. | ||
@param create Specifies if an existing image should be read (false) | ||
or if a new file should be created (true). | ||
*/ | ||
BmffImage(BasicIo::AutoPtr io, bool create); | ||
//@} | ||
|
||
//! @name Manipulators | ||
//@{ | ||
void readMetadata() /* override */ ; | ||
void writeMetadata() /* override */ ; | ||
|
||
/*! | ||
@brief Print out the structure of image file. | ||
@throw Error if reading of the file fails or the image data is | ||
not valid (does not look like data of the specific image type). | ||
@warning This function is not thread safe and intended for exiv2 -pS for debugging. | ||
*/ | ||
void printStructure(std::ostream& out, PrintStructureOption option,int depth) /* override */ ; | ||
|
||
/*! | ||
@brief Todo: Not supported yet(?). Calling this function will throw | ||
an instance of Error(kerInvalidSettingForImage). | ||
*/ | ||
void setComment(const std::string& comment) /* override */ ; | ||
//@} | ||
|
||
//! @name Accessors | ||
//@{ | ||
std::string mimeType() const /* override */ ; | ||
//@} | ||
#if 0 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove block or add comment why it's there (still testing, debug..) |
||
BmffImage& operator=(const BmffImage& rhs) /* = delete*/ ; | ||
BmffImage& operator=(const BmffImage&& rhs) /* = delete */ ; | ||
BmffImage(const BmffImage& rhs) /* = delete */; | ||
BmffImage(const BmffImage&& rhs) /* = delete */; | ||
#endif | ||
|
||
private: | ||
uint32_t fileType; | ||
|
||
/*! | ||
@brief Provides the main implementation of writeMetadata() by | ||
writing all buffered metadata to the provided BasicIo. | ||
@param oIo BasicIo instance to write to (a temporary location). | ||
|
||
@return 4 if opening or writing to the associated BasicIo fails | ||
*/ | ||
void doWriteMetadata(BasicIo& outIo); | ||
//@} | ||
|
||
std::string toAscii(long n); | ||
|
||
}; // class BmffImage | ||
|
||
// ***************************************************************************** | ||
// template, inline and free functions | ||
|
||
// These could be static private functions on Image subclasses but then | ||
// ImageFactory needs to be made a friend. | ||
/*! | ||
@brief Create a new BMFF instance and return an auto-pointer to it. | ||
Caller owns the returned object and the auto-pointer ensures that | ||
it will be deleted. | ||
*/ | ||
EXIV2API Image::AutoPtr newBmffInstance(BasicIo::AutoPtr io, bool create); | ||
|
||
//! Check if the file iIo is a BMFF image. | ||
EXIV2API bool isBmffType(BasicIo& iIo, bool advance); | ||
} // namespace Exiv2 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,6 +46,9 @@ | |
#include "exiv2/image.hpp" | ||
#include "exiv2/ini.hpp" | ||
#include "exiv2/iptc.hpp" | ||
#ifdef EXV_ENABLE_BMFF | ||
kmilos marked this conversation as resolved.
Show resolved
Hide resolved
|
||
#include "bmffimage.hpp" | ||
#endif// EXV_ENABLE_BMFF | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Space missing before comment |
||
#include "exiv2/jp2image.hpp" | ||
#include "exiv2/jpgimage.hpp" | ||
#include "exiv2/metadatum.hpp" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,7 +42,7 @@ namespace Exiv2 | |
// Add JPEG-2000 to the supported image formats | ||
namespace ImageType | ||
{ | ||
const int jp2 = 15; //!< JPEG-2000 image type | ||
const int jp2 = 19; //!< JPEG-2000 image type | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is the new type using the value 15 and There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 15 is used by bmff, and 19 by jp2. Let's replace that with an enum in 'main'. I didn't want change it to an enum for a "dot" because if it's not broken, don't fix it. However, when we get to 'main/0.28' we can fix this. 509 rmills@rmillsm1:~/gnu/github/exiv2/bmff $ grep 'const int' include/exiv2/*image.hpp
include/exiv2/bmffimage.hpp: const int bmff = 15; //!< BMFF (bmff) image type (see class BMFF)
include/exiv2/bmpimage.hpp: const int bmp = 14; //!< Windows bitmap (bmp) image type (see class BmpImage)
include/exiv2/cr2image.hpp: const int cr2 = 7; //!< CR2 image type (see class Cr2Image)
include/exiv2/crwimage.hpp: const int crw = 3; //!< CRW image type (see class CrwImage)
include/exiv2/epsimage.hpp: const int eps = 18; //!< EPS image type
include/exiv2/gifimage.hpp: const int gif = 11; //!< GIF image type (see class GifImage)
include/exiv2/image.hpp: const int none = 0; //!< Not an image
include/exiv2/jp2image.hpp: const int jp2 = 19; //!< JPEG-2000 image type
include/exiv2/jpgimage.hpp: const int jpeg = 1; //!< JPEG image type (see class JpegImage)
include/exiv2/jpgimage.hpp: const int exv = 2; //!< EXV image type (see class ExvImage)
include/exiv2/mrwimage.hpp: const int mrw = 5; //!< MRW image type (see class MrwImage)
include/exiv2/orfimage.hpp: const int orf = 9; //!< ORF image type (see class OrfImage)
include/exiv2/pgfimage.hpp: const int pgf = 17; //!< PGF image type (see class PgfImage)
include/exiv2/pngimage.hpp: const int png = 6; //!< PNG image type (see class PngImage)
include/exiv2/psdimage.hpp: const int psd = 12; //!< Photoshop (PSD) image type (see class PsdImage)
include/exiv2/rafimage.hpp: const int raf = 8; //!< RAF image type (see class RafImage)
include/exiv2/rw2image.hpp: const int rw2 = 16; //!< RW2 image type (see class Rw2Image)
include/exiv2/tgaimage.hpp: const int tga = 13; //!< Truevision TARGA (tga) image type (see class TgaImage)
include/exiv2/tiffimage.hpp: const int tiff = 4; //!< TIFF image type (see class TiffImage)
include/exiv2/tiffimage.hpp: const int dng = 4; //!< DNG image type (see class TiffImage)
include/exiv2/tiffimage.hpp: const int nef = 4; //!< NEF image type (see class TiffImage)
include/exiv2/tiffimage.hpp: const int pef = 4; //!< PEF image type (see class TiffImage)
include/exiv2/tiffimage.hpp: const int arw = 4; //!< ARW image type (see class TiffImage)
include/exiv2/tiffimage.hpp: const int sr2 = 4; //!< SR2 image type (see class TiffImage)
include/exiv2/tiffimage.hpp: const int srw = 4; //!< SRW image type (see class TiffImage)
include/exiv2/webpimage.hpp: const int webp = 23; //!< Treating webp as an image type>
510 rmills@rmillsm1:~/gnu/github/exiv2/bmff $ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've realised during lunch that you're asking "why not leave jp2 unchanged and set bmff=19?". When I started working with Peter, the only way I could change anything was to send him a patch and that's what I did. I didn't want to discuss what that code means, so I accepted his 15 (even though it's wrong). You're right. Now that we're cleaning up and the end, I should restore jp2 = 15 and set bmff = 19. Good Catch. |
||
} | ||
|
||
/*! | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix alignment?