-
Notifications
You must be signed in to change notification settings - Fork 284
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 all 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 |
---|---|---|
|
@@ -7,6 +7,7 @@ if (${EXIV2_ENABLE_WEBREADY}) | |
set(EXV_USE_SSH ${EXIV2_ENABLE_SSH}) | ||
set(EXV_USE_CURL ${EXIV2_ENABLE_CURL}) | ||
endif() | ||
set(EXV_ENABLE_BMFF ${EXIV2_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. Fix alignment? |
||
set(EXV_ENABLE_VIDEO ${EXIV2_ENABLE_VIDEO}) | ||
set(EXV_ENABLE_WEBREADY ${EXIV2_ENABLE_WEBREADY}) | ||
set(EXV_HAVE_LENSDATA ${EXIV2_ENABLE_LENSDATA}) | ||
|
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,170 @@ | ||
// ***************************************************************** -*- 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" | ||
#include "iostream" | ||
|
||
// ***************************************************************************** | ||
// 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. |
||
|
||
struct Iloc | ||
{ | ||
Iloc(uint32_t ID = 0, uint32_t start = 0, uint32_t length = 0) : ID_(ID), start_(start), length_(length){}; | ||
virtual ~Iloc(){}; | ||
|
||
uint32_t ID_; | ||
uint32_t start_; | ||
uint32_t length_; | ||
|
||
std::string toString() const; | ||
}; // class Iloc | ||
|
||
// ***************************************************************************** | ||
// class definitions | ||
|
||
// Add Base Media File Format to the supported image formats | ||
namespace ImageType | ||
{ | ||
const int bmff = 19; //!< 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); | ||
//@} | ||
|
||
//@{ | ||
/*! | ||
@brief parse embedded tiff file (Exif metadata) | ||
@param root_tag root of parse tree Tag::root, Tag::cmt2 etc. | ||
@param length tiff block length | ||
@param start offset in file (default, io_->tell()) | ||
@ | ||
*/ | ||
void parseTiff(uint32_t root_tag, uint32_t length); | ||
void parseTiff(uint32_t root_tag, uint32_t length,uint32_t start); | ||
//@} | ||
hassec marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
//@{ | ||
/*! | ||
@brief parse embedded xmp/xml | ||
@param length xmp block length | ||
@param start offset in file | ||
@ | ||
*/ | ||
void parseXmp(uint32_t length,uint32_t start); | ||
//@} | ||
|
||
//! @name Manipulators | ||
//@{ | ||
void readMetadata() /* override */; | ||
void writeMetadata() /* override */; | ||
void setComment(const std::string& comment) /* override */; | ||
void printStructure(std::ostream& out, Exiv2::PrintStructureOption option,int depth); | ||
//@} | ||
|
||
//! @name Accessors | ||
//@{ | ||
std::string mimeType() const /* override */; | ||
int pixelWidth() const; | ||
int pixelHeight() const; | ||
//@} | ||
|
||
Exiv2::ByteOrder endian_ ; | ||
|
||
private: | ||
void openOrThrow(); | ||
/*! | ||
@brief recursiveBoxHandler | ||
@throw Error if we visit a box more than once | ||
@return address of next box | ||
@warning This function should only be called by readMetadata() | ||
*/ | ||
long boxHandler(std::ostream& out=std::cout, Exiv2::PrintStructureOption option=kpsNone,int depth = 0); | ||
std::string indent(int i) | ||
{ | ||
return std::string(2*i,' '); | ||
} | ||
|
||
uint32_t fileType_; | ||
std::set<uint64_t> visits_; | ||
uint64_t visits_max_; | ||
uint16_t unknownID_; // 0xffff | ||
uint16_t exifID_; | ||
uint16_t xmpID_; | ||
std::map<uint32_t, Iloc> ilocs_; | ||
bool bReadMetadata_; | ||
//@} | ||
|
||
/*! | ||
@brief box utilities | ||
*/ | ||
std::string toAscii(long n); | ||
std::string boxName(uint32_t box); | ||
bool superBox(uint32_t box); | ||
bool fullBox(uint32_t box); | ||
std::string uuidName(Exiv2::DataBuf& uuid); | ||
|
||
}; // 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 |
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.
Hm, I didn't mean remove HEIC (and from main page neither below)... As per Wikipedia, I believe we should have HEIF, HEIC, and AVIF documented.
The HIF/HEIF is the same as JPG/JPEG IMHO, no need to handle specially.
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.
@clanmills Maybe I just do a PR with what I had in mind?
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.
Yes. My telepathy is down at the moment! Can you wait until this PR has been merged into 0.27-maintenance and then open a new PR.
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.
Sorry, saw this late and already pushed - just minor formatting changes though...
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.
Milos. Please don't make cosmetic changes to existing code that isn't part of the PR. It introduces changes between old-master and 0.27-maintenance which makes porting fixes from old-master more tricky. @neheb did a lot of work last Fall on 'master' and it would be good to see if we can merge his great work into 0.27-maintenance.
@neheb: I'm sorry to let you know that the Team has decided to hibernate 'master'. #1466 (comment)
@piponazo and @hassec have both proposed reformatting all the code with clang-tidy. I think we should consider doing that on 'main' when that ships as 0.28. Currently scheduled for 2021-09-15.
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.
Apologies Robin, I reverted my commits now. I'll do just the relevant subset once this PR is merged.
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.
@kmilos Thank you for both making the change and reverting the change. I know you intended well with those changes.