fix(video) clang-format quicktimevideo

main
Christoph Hasse 3 years ago
parent 9afb877324
commit 3456f30988

@ -37,8 +37,7 @@ namespace Exiv2 {
/*!
@brief Class to access QuickTime video files.
*/
class QuickTimeVideo:public Image
{
class QuickTimeVideo : public Image {
public:
//! @name Creators
//@{
@ -81,7 +80,7 @@ namespace Exiv2 {
@param buf Data buffer which cotains tag ID.
@param size Size of the data block used to store Tag Information.
*/
void tagDecoder(Exiv2::DataBuf & buf, unsigned long size);
void tagDecoder(Exiv2::DataBuf& buf, uint64_t size);
private:
/*!
@ -89,37 +88,37 @@ namespace Exiv2 {
in the respective XMP container.
@param size Size of the data block used to store Tag Information.
*/
void fileTypeDecoder(unsigned long size);
void fileTypeDecoder(uint64_t size);
/*!
@brief Interpret Media Header Tag, and save it
in the respective XMP container.
@param size Size of the data block used to store Tag Information.
*/
void mediaHeaderDecoder(unsigned long size);
void mediaHeaderDecoder(uint64_t size);
/*!
@brief Interpret Video Header Tag, and save it
in the respective XMP container.
@param size Size of the data block used to store Tag Information.
*/
void videoHeaderDecoder(unsigned long size);
void videoHeaderDecoder(uint64_t size);
/*!
@brief Interpret Movie Header Tag, and save it
in the respective XMP container.
@param size Size of the data block used to store Tag Information.
*/
void movieHeaderDecoder(unsigned long size);
void movieHeaderDecoder(uint64_t size);
/*!
@brief Interpret Track Header Tag, and save it
in the respective XMP container.
@param size Size of the data block used to store Tag Information.
*/
void trackHeaderDecoder(unsigned long size);
void trackHeaderDecoder(uint64_t size);
/*!
@brief Interpret Handler Tag, and save it
in the respective XMP container.
@param size Size of the data block used to store Tag Information.
*/
void handlerDecoder(unsigned long size);
void handlerDecoder(uint64_t size);
/*!
@brief Interpret Tag which contain other sub-tags,
and save it in the respective XMP container.
@ -130,7 +129,7 @@ namespace Exiv2 {
in the respective XMP container.
@param size Size of the data block used to store Tag Information.
*/
void sampleDesc(unsigned long size);
void sampleDesc(uint64_t size);
/*!
@brief Interpret Image Description Tag, and save it
in the respective XMP container.
@ -141,37 +140,37 @@ namespace Exiv2 {
in the respective XMP container.
@param size Size of the data block used to store Tag Information.
*/
void userDataDecoder(unsigned long size);
void userDataDecoder(uint64_t size);
/*!
@brief Interpret Preview Tag, and save it
in the respective XMP container.
@param size Size of the data block used to store Tag Information.
*/
void previewTagDecoder(unsigned long size);
void previewTagDecoder(uint64_t size);
/*!
@brief Interpret Meta Keys Tags, and save it
in the respective XMP container.
@param size Size of the data block used to store Tag Information.
*/
void keysTagDecoder(unsigned long size);
void keysTagDecoder(uint64_t size);
/*!
@brief Interpret Track Aperture Tags, and save it
in the respective XMP container.
@param size Size of the data block used to store Tag Information.
*/
void trackApertureTagDecoder(unsigned long size);
void trackApertureTagDecoder(uint64_t size);
/*!
@brief Interpret Nikon Tag, and save it
in the respective XMP container.
@param size Size of the data block used to store Tag Information.
*/
void NikonTagsDecoder(unsigned long size);
void NikonTagsDecoder(uint64_t size);
/*!
@brief Interpret Tags from Different Camera make, and save it
in the respective XMP container.
@param size Size of the data block used to store Tag Information.
*/
void CameraTagsDecoder(unsigned long size);
void CameraTagsDecoder(uint64_t size);
/*!
@brief Interpret Audio Description Tag, and save it
in the respective XMP container.
@ -192,7 +191,7 @@ namespace Exiv2 {
be skipped and not decoded.
@param size Size of the data block that is to skipped.
*/
void discard(unsigned long size);
void discard(uint64_t size);
/*!
@brief Calculates Aspect Ratio of a video, and stores it in the
respective XMP container.

@ -29,6 +29,7 @@
#include "orfimage.hpp"
#include "pgfimage.hpp"
#include "psdimage.hpp"
#include "quicktimevideo.hpp"
#include "rafimage.hpp"
#include "rw2image.hpp"
#include "tags_int.hpp"
@ -36,7 +37,6 @@
#include "tiffimage.hpp"
#include "webpimage.hpp"
#include "xmpsidecar.hpp"
#include "quicktimevideo.hpp"
// + standard includes
#include <array>

@ -21,16 +21,16 @@
// included header files
#include "config.h"
#include "basicio.hpp"
#include "error.hpp"
#include "futils.hpp"
#include "quicktimevideo.hpp"
#include "tags.hpp"
#include "tags_int.hpp"
#include "quicktimevideo.hpp"
#include "futils.hpp"
#include "basicio.hpp"
// + standard includes
#include <array>
#include <cmath>
#include <iostream>
#include <array>
#include <string>
// *****************************************************************************
// class member definitions
@ -123,16 +123,11 @@ namespace Exiv2 {
{"qt ", "Apple QuickTime (.MOV/QT)"},
{"sdv ", "SD Memory Card Video"},
{"ssc1", "Samsung stereoscopic, single stream"},
{ "ssc2", "Samsung stereoscopic, dual stream" }
};
{"ssc2", "Samsung stereoscopic, dual stream"}};
extern const TagVocabulary handlerClassTags[] = {
{ "dhlr", "Data Handler" },
{ "mhlr", "Media Handler" }
};
extern const TagVocabulary handlerClassTags[] = {{"dhlr", "Data Handler"}, {"mhlr", "Media Handler"}};
extern const TagVocabulary handlerTypeTags[] = {
{ "alis", "Alias Data" },
extern const TagVocabulary handlerTypeTags[] = {{"alis", "Alias Data"},
{"crsm", "Clock Reference"},
{"hint", "Hint Track"},
{"ipsm", "IPMP"},
@ -147,11 +142,9 @@ namespace Exiv2 {
{"text", "Text"},
{"tmcd", "Time Code"},
{"url ", "URL"},
{ "vide", "Video Track" }
};
{"vide", "Video Track"}};
extern const TagVocabulary vendorIDTags[] = {
{ "FFMP", "FFmpeg" },
extern const TagVocabulary vendorIDTags[] = {{"FFMP", "FFmpeg"},
{"appl", "Apple"},
{"olym", "Olympus"},
{"GIC ", "General Imaging Co."},
@ -167,48 +160,27 @@ namespace Exiv2 {
{"mino", "Minolta"},
{"sany", "Sanyo"},
{"ZORA", "Zoran Corporation"},
{ "niko", "Nikon" }
};
extern const TagVocabulary cameraByteOrderTags[] = {
{ "II", "Little-endian (Intel, II)" },
{ "MM", "Big-endian (Motorola, MM)" }
};
extern const TagDetails graphicsModetags[] = {
{ 0x0, "srcCopy" },
{ 0x1, "srcOr" },
{ 0x2, "srcXor" },
{ 0x3, "srcBic" },
{ 0x4, "notSrcCopy" },
{ 0x5, "notSrcOr" },
{ 0x6, "notSrcXor" },
{ 0x7, "notSrcBic" },
{ 0x8, "patCopy" },
{ 0x9, "patOr" },
{ 0xa, "patXor" },
{ 0xb, "patBic" },
{ 0xc, "notPatCopy" },
{ 0xd, "notPatOr" },
{ 0xe, "notPatXor" },
{ 0xf, "notPatBic" },
{ 0x20, "blend" },
{ 0x21, "addPin" },
{ 0x22, "addOver" },
{ 0x23, "subPin" },
{ 0x24, "transparent" },
{ 0x25, "addMax" },
{ 0x26, "subOver" },
{ 0x27, "addMin" },
{ 0x31, "grayishTextOr" },
{ 0x32, "hilite" },
{ 0x40, "ditherCopy" },
{ 0x100, "Alpha" },
{ 0x101, "White Alpha" },
{ 0x102, "Pre-multiplied Black Alpha" },
{ 0x110, "Component Alpha" }
};
{"niko", "Nikon"}};
extern const TagVocabulary cameraByteOrderTags[] = {{"II", "Little-endian (Intel, II)"},
{"MM", "Big-endian (Motorola, MM)"}};
extern const TagDetails graphicsModetags[] = {{0x0, "srcCopy"}, {0x1, "srcOr"},
{0x2, "srcXor"}, {0x3, "srcBic"},
{0x4, "notSrcCopy"}, {0x5, "notSrcOr"},
{0x6, "notSrcXor"}, {0x7, "notSrcBic"},
{0x8, "patCopy"}, {0x9, "patOr"},
{0xa, "patXor"}, {0xb, "patBic"},
{0xc, "notPatCopy"}, {0xd, "notPatOr"},
{0xe, "notPatXor"}, {0xf, "notPatBic"},
{0x20, "blend"}, {0x21, "addPin"},
{0x22, "addOver"}, {0x23, "subPin"},
{0x24, "transparent"}, {0x25, "addMax"},
{0x26, "subOver"}, {0x27, "addMin"},
{0x31, "grayishTextOr"}, {0x32, "hilite"},
{0x40, "ditherCopy"}, {0x100, "Alpha"},
{0x101, "White Alpha"}, {0x102, "Pre-multiplied Black Alpha"},
{0x110, "Component Alpha"}};
extern const TagVocabulary userDatatags[] = {
{"AllF", "PlayAllFrames"},
@ -359,12 +331,7 @@ namespace Exiv2 {
};
extern const TagVocabulary NikonGPS_Latitude_Longitude_ImgDirection_Reference[] = {
{ "N", "North" },
{ "S", "South" },
{ "E", "East" },
{ "W", "West" },
{ "M", "Magnetic North" },
{ "T", "True North" },
{"N", "North"}, {"S", "South"}, {"E", "East"}, {"W", "West"}, {"M", "Magnetic North"}, {"T", "True North"},
};
extern const TagDetails NikonGPSAltitudeRef[] = {
@ -385,14 +352,9 @@ namespace Exiv2 {
};
extern const TagDetails NikonMeteringMode[] = {
{ 0, "Unknown" },
{ 1, "Average" },
{ 2, "Center-weighted average" },
{ 3, "Spot" },
{ 4, "Multi-spot" },
{ 5, "Multi-segment" },
{ 6, "Partial" },
{ 255, "Other" },
{0, "Unknown"}, {1, "Average"}, {2, "Center-weighted average"},
{3, "Spot"}, {4, "Multi-spot"}, {5, "Multi-segment"},
{6, "Partial"}, {255, "Other"},
};
extern const TagDetails PictureControlAdjust[] = {
@ -402,91 +364,79 @@ namespace Exiv2 {
};
//! Contrast and Sharpness
extern const TagDetails NormalSoftHard[] = {
{ 0, "Normal" },
{ 1, "Soft" },
{ 2, "Hard" }
};
extern const TagDetails NormalSoftHard[] = {{0, "Normal"}, {1, "Soft"}, {2, "Hard"}};
//! Saturation
extern const TagDetails Saturation[] = {
{ 0, "Normal" },
{ 1, "Low" },
{ 2, "High" }
};
extern const TagDetails Saturation[] = {{0, "Normal"}, {1, "Low"}, {2, "High"}};
//! YesNo, used for DaylightSavings
extern const TagDetails YesNo[] = {
{ 0, "No" },
{ 1, "Yes" }
};
extern const TagDetails YesNo[] = {{0, "No"}, {1, "Yes"}};
//! DateDisplayFormat
extern const TagDetails DateDisplayFormat[] = {
{ 0, "Y/M/D" },
{ 1, "M/D/Y" },
{ 2, "D/M/Y" }
};
extern const TagDetails DateDisplayFormat[] = {{0, "Y/M/D"}, {1, "M/D/Y"}, {2, "D/M/Y"}};
extern const TagDetails FilterEffect[] = {
{ 0x80, "Off" },
{ 0x81, "Yellow" },
{ 0x82, "Orange" },
{ 0x83, "Red" },
{ 0x84, "Green" },
{ 0xff, "n/a" },
{0x80, "Off"}, {0x81, "Yellow"}, {0x82, "Orange"}, {0x83, "Red"}, {0x84, "Green"}, {0xff, "n/a"},
};
extern const TagDetails ToningEffect[] = {
{ 0x80, "B&W" },
{ 0x81, "Sepia" },
{ 0x82, "Cyanotype" },
{ 0x83, "Red" },
{ 0x84, "Yellow" },
{ 0x85, "Green" },
{ 0x86, "Blue-green" },
{ 0x87, "Blue" },
{ 0x88, "Purple-blue" },
{ 0x89, "Red-purple" },
{ 0xff, "n/a" },
{0x80, "B&W"}, {0x81, "Sepia"}, {0x82, "Cyanotype"}, {0x83, "Red"},
{0x84, "Yellow"}, {0x85, "Green"}, {0x86, "Blue-green"}, {0x87, "Blue"},
{0x88, "Purple-blue"}, {0x89, "Red-purple"}, {0xff, "n/a"},
};
extern const TagDetails whiteBalance[] = {
{ 0, "Auto" },
{ 1, "Daylight" },
{ 2, "Shade" },
{ 3, "Fluorescent" },
{ 4, "Tungsten" },
{ 5, "Manual" },
{0, "Auto"}, {1, "Daylight"}, {2, "Shade"}, {3, "Fluorescent"}, {4, "Tungsten"}, {5, "Manual"},
};
enum movieHeaderTags {
MovieHeaderVersion, CreateDate, ModifyDate, TimeScale, Duration, PreferredRate, PreferredVolume,
PreviewTime = 18, PreviewDuration,PosterTime, SelectionTime, SelectionDuration, CurrentTime, NextTrackID
MovieHeaderVersion,
CreateDate,
ModifyDate,
TimeScale,
Duration,
PreferredRate,
PreferredVolume,
PreviewTime = 18,
PreviewDuration,
PosterTime,
SelectionTime,
SelectionDuration,
CurrentTime,
NextTrackID
};
enum trackHeaderTags {
TrackHeaderVersion, TrackCreateDate, TrackModifyDate, TrackID, TrackDuration = 5, TrackLayer = 8,
TrackVolume, ImageWidth = 19, ImageHeight
TrackHeaderVersion,
TrackCreateDate,
TrackModifyDate,
TrackID,
TrackDuration = 5,
TrackLayer = 8,
TrackVolume,
ImageWidth = 19,
ImageHeight
};
enum mediaHeaderTags {
MediaHeaderVersion, MediaCreateDate, MediaModifyDate, MediaTimeScale, MediaDuration, MediaLanguageCode
};
enum handlerTags {
HandlerClass = 1, HandlerType, HandlerVendorID
};
enum videoHeaderTags {
GraphicsMode = 2, OpColor
};
enum stream {
Video, Audio, Hint, Null, GenMediaHeader
MediaHeaderVersion,
MediaCreateDate,
MediaModifyDate,
MediaTimeScale,
MediaDuration,
MediaLanguageCode
};
enum handlerTags { HandlerClass = 1, HandlerType, HandlerVendorID };
enum videoHeaderTags { GraphicsMode = 2, OpColor };
enum stream { Video, Audio, Hint, Null, GenMediaHeader };
enum imageDescTags {
codec, VendorID = 4, SourceImageWidth_Height = 7, XResolution,
YResolution, CompressorName = 10, BitDepth
};
enum audioDescTags {
AudioFormat, AudioVendorID = 4, AudioChannels, AudioSampleRate = 7, MOV_AudioFormat = 13
codec,
VendorID = 4,
SourceImageWidth_Height = 7,
XResolution,
YResolution,
CompressorName = 10,
BitDepth
};
enum audioDescTags { AudioFormat, AudioVendorID = 4, AudioChannels, AudioSampleRate = 7, MOV_AudioFormat = 13 };
/*!
@brief Function used to check equality of a Tags with a
@ -510,8 +460,7 @@ namespace Exiv2 {
*/
bool ignoreList(Exiv2::DataBuf& buf) {
const char ignoreList[13][5] = {
"mdat", "edts", "junk", "iods", "alis", "stsc", "stsz", "stco", "ctts", "stss",
"skip", "wide", "cmvd",
"mdat", "edts", "junk", "iods", "alis", "stsc", "stsz", "stco", "ctts", "stss", "skip", "wide", "cmvd",
};
for (int i = 0; i < 13; ++i)
@ -530,8 +479,7 @@ namespace Exiv2 {
*/
bool dataIgnoreList(Exiv2::DataBuf& buf) {
const char ignoreList[8][5] = {
"moov", "mdia", "minf", "dinf", "alis", "stbl", "cmov",
"meta",
"moov", "mdia", "minf", "dinf", "alis", "stbl", "cmov", "meta",
};
for (int i = 0; i < 8; ++i)
@ -577,35 +525,31 @@ namespace Exiv2 {
return temp;
}
}} // namespace Internal, Exiv2
} // namespace Internal
} // namespace Exiv2
namespace Exiv2 {
using namespace Exiv2::Internal;
QuickTimeVideo::QuickTimeVideo(BasicIo::UniquePtr io)
: Image(ImageType::qtime, mdNone, std::move(io))
, timeScale_(1)
{
QuickTimeVideo::QuickTimeVideo(BasicIo::UniquePtr io) : Image(ImageType::qtime, mdNone, std::move(io)), timeScale_(1) {
} // QuickTimeVideo::QuickTimeVideo
std::string QuickTimeVideo::mimeType() const
{
std::string QuickTimeVideo::mimeType() const {
return "video/quicktime";
}
void QuickTimeVideo::writeMetadata()
{
void QuickTimeVideo::writeMetadata() {
}
void QuickTimeVideo::readMetadata()
{
if (io_->open() != 0) throw Error(ErrorCode::kerDataSourceOpenFailed, io_->path(), strError());
void QuickTimeVideo::readMetadata() {
if (io_->open() != 0)
throw Error(ErrorCode::kerDataSourceOpenFailed, io_->path(), strError());
// Ensure that this is the correct image type
if (!isQTimeType(*io_, false)) {
if (io_->error() || io_->eof()) throw Error(ErrorCode::kerFailedToReadImageData);
if (io_->error() || io_->eof())
throw Error(ErrorCode::kerFailedToReadImageData);
throw Error(ErrorCode::kerNotAnImage, "QuickTime");
}
@ -617,19 +561,18 @@ namespace Exiv2 {
xmpData_["Xmp.video.FileSize"] = (double)io_->size() / (double)1048576;
xmpData_["Xmp.video.MimeType"] = mimeType();
while (continueTraversing_) decodeBlock();
while (continueTraversing_)
decodeBlock();
aspectRatio();
} // QuickTimeVideo::readMetadata
void QuickTimeVideo::decodeBlock()
{
void QuickTimeVideo::decodeBlock() {
const long bufMinSize = 4;
DataBuf buf(bufMinSize + 1);
uint64_t size = 0;
buf.data()[4] = '\0';
io_->read(buf.data(), 4);
if (io_->eof()) {
continueTraversing_ = false;
@ -653,8 +596,7 @@ namespace Exiv2 {
tagDecoder(buf, size - 8);
} // QuickTimeVideo::decodeBlock
void QuickTimeVideo::tagDecoder(Exiv2::DataBuf &buf, unsigned long size)
{
void QuickTimeVideo::tagDecoder(Exiv2::DataBuf& buf, uint64_t size) {
if (ignoreList(buf))
discard(size);
@ -735,14 +677,12 @@ namespace Exiv2 {
}
} // QuickTimeVideo::tagDecoder
void QuickTimeVideo::discard(unsigned long size)
{
void QuickTimeVideo::discard(uint64_t size) {
uint64_t cur_pos = io_->tell();
io_->seek(cur_pos + size, BasicIo::beg);
} // QuickTimeVideo::discard
void QuickTimeVideo::previewTagDecoder(unsigned long size)
{
void QuickTimeVideo::previewTagDecoder(uint64_t size) {
DataBuf buf(4);
uint64_t cur_pos = io_->tell();
io_->read(buf.data(), 4);
@ -759,8 +699,7 @@ namespace Exiv2 {
io_->seek(cur_pos + size, BasicIo::beg);
} // QuickTimeVideo::previewTagDecoder
void QuickTimeVideo::keysTagDecoder(unsigned long size)
{
void QuickTimeVideo::keysTagDecoder(uint64_t size) {
DataBuf buf(4);
uint64_t cur_pos = io_->tell();
io_->read(buf.data(), 4);
@ -777,50 +716,55 @@ namespace Exiv2 {
io_->seek(cur_pos + size, BasicIo::beg);
} // QuickTimeVideo::keysTagDecoder
void QuickTimeVideo::trackApertureTagDecoder(unsigned long size)
{
void QuickTimeVideo::trackApertureTagDecoder(uint64_t size) {
DataBuf buf(4), buf2(2);
uint64_t cur_pos = io_->tell();
byte n = 3;
while (n--) {
io_->seek(static_cast<long>(4), BasicIo::cur); io_->read(buf.data(), 4);
io_->seek(static_cast<long>(4), BasicIo::cur);
io_->read(buf.data(), 4);
if (equalsQTimeTag(buf, "clef")) {
io_->seek(static_cast<long>(4), BasicIo::cur);
io_->read(buf.data(), 2); io_->read(buf2.data(), 2);
xmpData_["Xmp.video.CleanApertureWidth"] = Exiv2::toString(getUShort(buf.data(), bigEndian))
+ "." + Exiv2::toString(getUShort(buf2.data(), bigEndian));
io_->read(buf.data(), 2); io_->read(buf2.data(), 2);
xmpData_["Xmp.video.CleanApertureHeight"] = Exiv2::toString(getUShort(buf.data(), bigEndian))
+ "." + Exiv2::toString(getUShort(buf2.data(), bigEndian));
io_->read(buf.data(), 2);
io_->read(buf2.data(), 2);
xmpData_["Xmp.video.CleanApertureWidth"] =
Exiv2::toString(getUShort(buf.data(), bigEndian)) + "." + Exiv2::toString(getUShort(buf2.data(), bigEndian));
io_->read(buf.data(), 2);
io_->read(buf2.data(), 2);
xmpData_["Xmp.video.CleanApertureHeight"] =
Exiv2::toString(getUShort(buf.data(), bigEndian)) + "." + Exiv2::toString(getUShort(buf2.data(), bigEndian));
}
else if (equalsQTimeTag(buf, "prof")) {
io_->seek(static_cast<long>(4), BasicIo::cur);
io_->read(buf.data(), 2); io_->read(buf2.data(), 2);
xmpData_["Xmp.video.ProductionApertureWidth"] = Exiv2::toString(getUShort(buf.data(), bigEndian))
+ "." + Exiv2::toString(getUShort(buf2.data(), bigEndian));
io_->read(buf.data(), 2); io_->read(buf2.data(), 2);
xmpData_["Xmp.video.ProductionApertureHeight"] = Exiv2::toString(getUShort(buf.data(), bigEndian))
+ "." + Exiv2::toString(getUShort(buf2.data(), bigEndian));
io_->read(buf.data(), 2);
io_->read(buf2.data(), 2);
xmpData_["Xmp.video.ProductionApertureWidth"] =
Exiv2::toString(getUShort(buf.data(), bigEndian)) + "." + Exiv2::toString(getUShort(buf2.data(), bigEndian));
io_->read(buf.data(), 2);
io_->read(buf2.data(), 2);
xmpData_["Xmp.video.ProductionApertureHeight"] =
Exiv2::toString(getUShort(buf.data(), bigEndian)) + "." + Exiv2::toString(getUShort(buf2.data(), bigEndian));
}
else if (equalsQTimeTag(buf, "enof")) {
io_->seek(static_cast<long>(4), BasicIo::cur);
io_->read(buf.data(), 2); io_->read(buf2.data(), 2);
xmpData_["Xmp.video.EncodedPixelsWidth"] = Exiv2::toString(getUShort(buf.data(), bigEndian))
+ "." + Exiv2::toString(getUShort(buf2.data(), bigEndian));
io_->read(buf.data(), 2); io_->read(buf2.data(), 2);
xmpData_["Xmp.video.EncodedPixelsHeight"] = Exiv2::toString(getUShort(buf.data(), bigEndian))
+ "." + Exiv2::toString(getUShort(buf2.data(), bigEndian));
io_->read(buf.data(), 2);
io_->read(buf2.data(), 2);
xmpData_["Xmp.video.EncodedPixelsWidth"] =
Exiv2::toString(getUShort(buf.data(), bigEndian)) + "." + Exiv2::toString(getUShort(buf2.data(), bigEndian));
io_->read(buf.data(), 2);
io_->read(buf2.data(), 2);
xmpData_["Xmp.video.EncodedPixelsHeight"] =
Exiv2::toString(getUShort(buf.data(), bigEndian)) + "." + Exiv2::toString(getUShort(buf2.data(), bigEndian));
}
}
io_->seek(static_cast<long>(cur_pos + size), BasicIo::beg);
} // QuickTimeVideo::trackApertureTagDecoder
void QuickTimeVideo::CameraTagsDecoder(unsigned long size_external)
{
void QuickTimeVideo::CameraTagsDecoder(uint64_t size_external) {
uint64_t cur_pos = io_->tell();
DataBuf buf(50), buf2(4);
const TagDetails* td;
@ -835,16 +779,22 @@ namespace Exiv2 {
xmpData_["Xmp.video.Model"] = Exiv2::toString(buf.data());
io_->read(buf.data(), 4);
xmpData_["Xmp.video.ExposureTime"] = "1/" + Exiv2::toString(ceil(getULong(buf.data(), littleEndian) / (double)10));
io_->read(buf.data(), 4); io_->read(buf2.data(), 4);
io_->read(buf.data(), 4);
io_->read(buf2.data(), 4);
xmpData_["Xmp.video.FNumber"] = getULong(buf.data(), littleEndian) / (double)getULong(buf2.data(), littleEndian);
io_->read(buf.data(), 4); io_->read(buf2.data(), 4);
xmpData_["Xmp.video.ExposureCompensation"] = getULong(buf.data(), littleEndian) / (double)getULong(buf2.data(), littleEndian) ;
io_->read(buf.data(), 10); io_->read(buf.data(), 4);
io_->read(buf.data(), 4);
io_->read(buf2.data(), 4);
xmpData_["Xmp.video.ExposureCompensation"] =
getULong(buf.data(), littleEndian) / (double)getULong(buf2.data(), littleEndian);
io_->read(buf.data(), 10);
io_->read(buf.data(), 4);
td = find(whiteBalance, getULong(buf.data(), littleEndian));
if (td)
xmpData_["Xmp.video.WhiteBalance"] = exvGettext(td->label_);
io_->read(buf.data(), 4); io_->read(buf2.data(), 4);
xmpData_["Xmp.video.FocalLength"] = getULong(buf.data(), littleEndian) / (double)getULong(buf2.data(), littleEndian) ;
io_->read(buf.data(), 4);
io_->read(buf2.data(), 4);
xmpData_["Xmp.video.FocalLength"] =
getULong(buf.data(), littleEndian) / (double)getULong(buf2.data(), littleEndian);
io_->seek(static_cast<long>(95), BasicIo::cur);
io_->read(buf.data(), 48);
xmpData_["Xmp.video.Software"] = Exiv2::toString(buf.data());
@ -855,8 +805,7 @@ namespace Exiv2 {
io_->seek(cur_pos + size_external, BasicIo::beg);
} // QuickTimeVideo::CameraTagsDecoder
void QuickTimeVideo::userDataDecoder(unsigned long size_external)
{
void QuickTimeVideo::userDataDecoder(uint64_t size_external) {
uint64_t cur_pos = io_->tell();
const TagVocabulary* td;
const TagVocabulary *tv, *tv_internal;
@ -867,7 +816,6 @@ namespace Exiv2 {
std::memset(buf.data(), 0x0, buf.size());
while ((size_internal / 4 != 0) && (size_internal > 0)) {
buf.data()[4] = '\0';
io_->read(buf.data(), 4);
size = Exiv2::getULong(buf.data(), bigEndian);
@ -894,9 +842,8 @@ namespace Exiv2 {
else if (equalsQTimeTag(buf, "TAGS"))
CameraTagsDecoder(size - 8);
else if(equalsQTimeTag(buf, "CNCV") || equalsQTimeTag(buf, "CNFV")
|| equalsQTimeTag(buf, "CNMN") || equalsQTimeTag(buf, "NCHD")
|| equalsQTimeTag(buf, "FFMV")) {
else if (equalsQTimeTag(buf, "CNCV") || equalsQTimeTag(buf, "CNFV") || equalsQTimeTag(buf, "CNMN") ||
equalsQTimeTag(buf, "NCHD") || equalsQTimeTag(buf, "FFMV")) {
io_->read(buf.data(), size - 8);
xmpData_[exvGettext(tv->label_)] = Exiv2::toString(buf.data());
}
@ -925,8 +872,7 @@ namespace Exiv2 {
io_->seek(cur_pos + size_external, BasicIo::beg);
} // QuickTimeVideo::userDataDecoder
void QuickTimeVideo::NikonTagsDecoder(unsigned long size_external)
{
void QuickTimeVideo::NikonTagsDecoder(uint64_t size_external) {
uint64_t cur_pos = io_->tell();
DataBuf buf(200), buf2(4 + 1);
unsigned long TagID = 0;
@ -949,10 +895,14 @@ namespace Exiv2 {
dataLength = Exiv2::getUShort(buf.data(), bigEndian);
std::memset(buf.data(), 0x0, buf.size());
io_->read(buf.data(), 4); xmpData_["Xmp.video.PictureControlVersion"] = Exiv2::toString(buf.data());
io_->read(buf.data(), 20); xmpData_["Xmp.video.PictureControlName"] = Exiv2::toString(buf.data());
io_->read(buf.data(), 20); xmpData_["Xmp.video.PictureControlBase"] = Exiv2::toString(buf.data());
io_->read(buf.data(), 4); std::memset(buf.data(), 0x0, buf.size());
io_->read(buf.data(), 4);
xmpData_["Xmp.video.PictureControlVersion"] = Exiv2::toString(buf.data());
io_->read(buf.data(), 20);
xmpData_["Xmp.video.PictureControlName"] = Exiv2::toString(buf.data());
io_->read(buf.data(), 20);
xmpData_["Xmp.video.PictureControlBase"] = Exiv2::toString(buf.data());
io_->read(buf.data(), 4);
std::memset(buf.data(), 0x0, buf.size());
io_->read(buf.data(), 1);
td2 = find(PictureControlAdjust, (int)buf.data()[0] & 7);
@ -1011,7 +961,8 @@ namespace Exiv2 {
else
xmpData_["Xmp.video.ToningEffect"] = (int)buf.data()[0];
io_->read(buf.data(), 1); xmpData_["Xmp.video.ToningSaturation"] = (int)buf.data()[0];
io_->read(buf.data(), 1);
xmpData_["Xmp.video.ToningSaturation"] = (int)buf.data()[0];
io_->seek(local_pos + dataLength, BasicIo::beg);
}
@ -1021,7 +972,8 @@ namespace Exiv2 {
dataLength = Exiv2::getUShort(buf.data(), bigEndian);
std::memset(buf.data(), 0x0, buf.size());
io_->read(buf.data(), 2); xmpData_["Xmp.video.TimeZone"] = Exiv2::getShort(buf.data(), bigEndian);
io_->read(buf.data(), 2);
xmpData_["Xmp.video.TimeZone"] = Exiv2::getShort(buf.data(), bigEndian);
io_->read(buf.data(), 1);
td2 = find(YesNo, (int)buf.data()[0]);
if (td2)
@ -1053,8 +1005,7 @@ namespace Exiv2 {
if (td) {
xmpData_[exvGettext(td->label_)] = Exiv2::toString(buf.data());
}
}
else if(dataType == 4) {
} else if (dataType == 4) {
dataLength = Exiv2::getUShort(buf.data(), bigEndian) * 4;
std::memset(buf.data(), 0x0, buf.size());
io_->read(buf.data(), 4);
@ -1068,11 +1019,9 @@ namespace Exiv2 {
<< " Entries considered invalid. Not Processed.\n";
#endif
io_->seek(io_->tell() + dataLength - 4, BasicIo::beg);
}
else
} else
io_->read(buf.data(), dataLength - 4);
}
else if(dataType == 3) {
} else if (dataType == 3) {
dataLength = Exiv2::getUShort(buf.data(), bigEndian) * 2;
std::memset(buf.data(), 0x0, buf.size());
io_->read(buf.data(), 2);
@ -1086,17 +1035,16 @@ namespace Exiv2 {
<< " Entries considered invalid. Not Processed.\n";
#endif
io_->seek(io_->tell() + dataLength - 2, BasicIo::beg);
}
else
} else
io_->read(buf.data(), dataLength - 2);
}
else if(dataType == 5) {
} else if (dataType == 5) {
dataLength = Exiv2::getUShort(buf.data(), bigEndian) * 8;
std::memset(buf.data(), 0x0, buf.size());
io_->read(buf.data(), 4);
io_->read(buf2.data(), 4);
if (td)
xmpData_[exvGettext(td->label_)] = Exiv2::toString((double)Exiv2::getULong( buf.data(), bigEndian) / (double)Exiv2::getULong( buf2.data(), bigEndian));
xmpData_[exvGettext(td->label_)] = Exiv2::toString((double)Exiv2::getULong(buf.data(), bigEndian) /
(double)Exiv2::getULong(buf2.data(), bigEndian));
// Sanity check with an "unreasonably" large number
if (dataLength > 200 || dataLength < 8) {
@ -1105,17 +1053,16 @@ namespace Exiv2 {
<< " Entries considered invalid. Not Processed.\n";
#endif
io_->seek(io_->tell() + dataLength - 8, BasicIo::beg);
}
else
} else
io_->read(buf.data(), dataLength - 8);
}
else if(dataType == 8) {
} else if (dataType == 8) {
dataLength = Exiv2::getUShort(buf.data(), bigEndian) * 2;
std::memset(buf.data(), 0x0, buf.size());
io_->read(buf.data(), 2);
io_->read(buf2.data(), 2);
if (td)
xmpData_[exvGettext(td->label_)] = Exiv2::toString(Exiv2::getUShort( buf.data(), bigEndian) ) + " " + Exiv2::toString(Exiv2::getUShort( buf2.data(), bigEndian));
xmpData_[exvGettext(td->label_)] = Exiv2::toString(Exiv2::getUShort(buf.data(), bigEndian)) + " " +
Exiv2::toString(Exiv2::getUShort(buf2.data(), bigEndian));
// Sanity check with an "unreasonably" large number
if (dataLength > 200 || dataLength < 4) {
@ -1124,8 +1071,7 @@ namespace Exiv2 {
<< " Entries considered invalid. Not Processed.\n";
#endif
io_->seek(io_->tell() + dataLength - 4, BasicIo::beg);
}
else
} else
io_->read(buf.data(), dataLength - 4);
}
}
@ -1133,8 +1079,7 @@ namespace Exiv2 {
io_->seek(cur_pos + size_external, BasicIo::beg);
} // QuickTimeVideo::NikonTagsDecoder
void QuickTimeVideo::setMediaStream()
{
void QuickTimeVideo::setMediaStream() {
uint64_t current_position = io_->tell();
DataBuf buf(4 + 1);
@ -1160,8 +1105,7 @@ namespace Exiv2 {
io_->seek(current_position, BasicIo::beg);
} // QuickTimeVideo::setMediaStream
void QuickTimeVideo::timeToSampleDecoder()
{
void QuickTimeVideo::timeToSampleDecoder() {
DataBuf buf(4 + 1);
io_->read(buf.data(), 4);
io_->read(buf.data(), 4);
@ -1180,8 +1124,7 @@ namespace Exiv2 {
xmpData_["Xmp.video.FrameRate"] = (double)totalframes * (double)timeScale_ / (double)timeOfFrames;
} // QuickTimeVideo::timeToSampleDecoder
void QuickTimeVideo::sampleDesc(unsigned long size)
{
void QuickTimeVideo::sampleDesc(uint64_t size) {
DataBuf buf(100);
uint64_t cur_pos = io_->tell();
io_->read(buf.data(), 4);
@ -1198,8 +1141,7 @@ namespace Exiv2 {
io_->seek(cur_pos + size, BasicIo::beg);
} // QuickTimeVideo::sampleDesc
void QuickTimeVideo::audioDescDecoder()
{
void QuickTimeVideo::audioDescDecoder() {
DataBuf buf(40);
std::memset(buf.data(), 0x0, buf.size());
buf.data()[4] = '\0';
@ -1237,8 +1179,7 @@ namespace Exiv2 {
io_->read(buf.data(), static_cast<long>(size % 4)); // cause size is so small, this cast should be right.
} // QuickTimeVideo::audioDescDecoder
void QuickTimeVideo::imageDescDecoder()
{
void QuickTimeVideo::imageDescDecoder() {
DataBuf buf(40);
std::memset(buf.data(), 0x0, buf.size());
buf.data()[4] = '\0';
@ -1272,10 +1213,12 @@ namespace Exiv2 {
break;
case YResolution:
xmpData_["Xmp.video.YResolution"] = returnBufValue(buf, 2) + ((buf.data()[2] * 256 + buf.data()[3]) * 0.01);
io_->read(buf.data(), 3); size -= 3;
io_->read(buf.data(), 3);
size -= 3;
break;
case CompressorName:
io_->read(buf.data(), 32); size -= 32;
io_->read(buf.data(), 32);
size -= 32;
xmpData_["Xmp.video.Compressor"] = Exiv2::toString(buf.data());
break;
default:
@ -1286,8 +1229,7 @@ namespace Exiv2 {
xmpData_["Xmp.video.BitDepth"] = returnBufValue(buf, 1);
} // QuickTimeVideo::imageDescDecoder
void QuickTimeVideo::multipleEntriesDecoder()
{
void QuickTimeVideo::multipleEntriesDecoder() {
DataBuf buf(4 + 1);
io_->read(buf.data(), 4);
io_->read(buf.data(), 4);
@ -1299,7 +1241,7 @@ namespace Exiv2 {
decodeBlock();
} // QuickTimeVideo::multipleEntriesDecoder
void QuickTimeVideo::videoHeaderDecoder(unsigned long size) {
void QuickTimeVideo::videoHeaderDecoder(uint64_t size) {
DataBuf buf(3);
std::memset(buf.data(), 0x0, buf.size());
buf.data()[2] = '\0';
@ -1326,8 +1268,7 @@ namespace Exiv2 {
io_->read(buf.data(), size % 2);
} // QuickTimeVideo::videoHeaderDecoder
void QuickTimeVideo::handlerDecoder(unsigned long size)
{
void QuickTimeVideo::handlerDecoder(uint64_t size) {
uint64_t cur_pos = io_->tell();
DataBuf buf(100);
std::memset(buf.data(), 0x0, buf.size());
@ -1371,7 +1312,7 @@ namespace Exiv2 {
io_->seek(cur_pos + size, BasicIo::beg);
} // QuickTimeVideo::handlerDecoder
void QuickTimeVideo::fileTypeDecoder(unsigned long size) {
void QuickTimeVideo::fileTypeDecoder(uint64_t size) {
DataBuf buf(5);
std::memset(buf.data(), 0x0, buf.size());
buf.data()[4] = '\0';
@ -1402,7 +1343,7 @@ namespace Exiv2 {
io_->read(buf.data(), size % 4);
} // QuickTimeVideo::fileTypeDecoder
void QuickTimeVideo::mediaHeaderDecoder(unsigned long size) {
void QuickTimeVideo::mediaHeaderDecoder(uint64_t size) {
DataBuf buf(5);
std::memset(buf.data(), 0x0, buf.size());
buf.data()[4] = '\0';
@ -1461,7 +1402,7 @@ namespace Exiv2 {
io_->read(buf.data(), size % 4);
} // QuickTimeVideo::mediaHeaderDecoder
void QuickTimeVideo::trackHeaderDecoder(unsigned long size) {
void QuickTimeVideo::trackHeaderDecoder(uint64_t size) {
DataBuf buf(5);
std::memset(buf.data(), 0x0, buf.size());
buf.data()[4] = '\0';
@ -1536,7 +1477,7 @@ namespace Exiv2 {
io_->read(buf.data(), size % 4);
} // QuickTimeVideo::trackHeaderDecoder
void QuickTimeVideo::movieHeaderDecoder(unsigned long size) {
void QuickTimeVideo::movieHeaderDecoder(uint64_t size) {
DataBuf buf(5);
std::memset(buf.data(), 0x0, buf.size());
buf.data()[4] = '\0';
@ -1546,17 +1487,21 @@ namespace Exiv2 {
switch (i) {
case MovieHeaderVersion:
xmpData_["Xmp.video.MovieHeaderVersion"] = returnBufValue(buf,1); break;
xmpData_["Xmp.video.MovieHeaderVersion"] = returnBufValue(buf, 1);
break;
case CreateDate:
// A 32-bit integer that specifies (in seconds since midnight, January 1, 1904) when the movie atom was created.
xmpData_["Xmp.video.DateUTC"] = returnUnsignedBufValue(buf); break;
xmpData_["Xmp.video.DateUTC"] = returnUnsignedBufValue(buf);
break;
case ModifyDate:
// A 32-bit integer that specifies (in seconds since midnight, January 1, 1904) when the movie atom was created.
xmpData_["Xmp.video.ModificationDate"] = returnUnsignedBufValue(buf); break;
xmpData_["Xmp.video.ModificationDate"] = returnUnsignedBufValue(buf);
break;
case TimeScale:
xmpData_["Xmp.video.TimeScale"] = returnBufValue(buf);
timeScale_ = returnBufValue(buf);
if (timeScale_ <= 0) timeScale_ = 1;
if (timeScale_ <= 0)
timeScale_ = 1;
break;
case Duration:
if (timeScale_ != 0) { // To prevent division by zero
@ -1564,23 +1509,32 @@ namespace Exiv2 {
}
break;
case PreferredRate:
xmpData_["Xmp.video.PreferredRate"] = returnBufValue(buf, 2) + ((buf.data()[2] * 256 + buf.data()[3]) * 0.01); break;
xmpData_["Xmp.video.PreferredRate"] = returnBufValue(buf, 2) + ((buf.data()[2] * 256 + buf.data()[3]) * 0.01);
break;
case PreferredVolume:
xmpData_["Xmp.video.PreferredVolume"] = (returnBufValue(buf, 1) + (buf.data()[2] * 0.1)) * 100; break;
xmpData_["Xmp.video.PreferredVolume"] = (returnBufValue(buf, 1) + (buf.data()[2] * 0.1)) * 100;
break;
case PreviewTime:
xmpData_["Xmp.video.PreviewTime"] = returnBufValue(buf); break;
xmpData_["Xmp.video.PreviewTime"] = returnBufValue(buf);
break;
case PreviewDuration:
xmpData_["Xmp.video.PreviewDuration"] = returnBufValue(buf); break;
xmpData_["Xmp.video.PreviewDuration"] = returnBufValue(buf);
break;
case PosterTime:
xmpData_["Xmp.video.PosterTime"] = returnBufValue(buf); break;
xmpData_["Xmp.video.PosterTime"] = returnBufValue(buf);
break;
case SelectionTime:
xmpData_["Xmp.video.SelectionTime"] = returnBufValue(buf); break;
xmpData_["Xmp.video.SelectionTime"] = returnBufValue(buf);
break;
case SelectionDuration:
xmpData_["Xmp.video.SelectionDuration"] = returnBufValue(buf); break;
xmpData_["Xmp.video.SelectionDuration"] = returnBufValue(buf);
break;
case CurrentTime:
xmpData_["Xmp.video.CurrentTime"] = returnBufValue(buf); break;
xmpData_["Xmp.video.CurrentTime"] = returnBufValue(buf);
break;
case NextTrackID:
xmpData_["Xmp.video.NextTrackID"] = returnBufValue(buf); break;
xmpData_["Xmp.video.NextTrackID"] = returnBufValue(buf);
break;
default:
break;
}
@ -1588,8 +1542,7 @@ namespace Exiv2 {
io_->read(buf.data(), size % 4);
} // QuickTimeVideo::movieHeaderDecoder
void QuickTimeVideo::aspectRatio()
{
void QuickTimeVideo::aspectRatio() {
// TODO - Make a better unified method to handle all cases of Aspect Ratio
double aspectRatio = (double)width_ / (double)height_;
@ -1599,18 +1552,33 @@ namespace Exiv2 {
int aR = (int)((aspectRatio * 10.0) + 0.1);
switch (aR) {
case 13 : xmpData_["Xmp.video.AspectRatio"] = "4:3" ; break;
case 17 : xmpData_["Xmp.video.AspectRatio"] = "16:9" ; break;
case 10 : xmpData_["Xmp.video.AspectRatio"] = "1:1" ; break;
case 16 : xmpData_["Xmp.video.AspectRatio"] = "16:10" ; break;
case 22 : xmpData_["Xmp.video.AspectRatio"] = "2.21:1" ; break;
case 23 : xmpData_["Xmp.video.AspectRatio"] = "2.35:1" ; break;
case 12 : xmpData_["Xmp.video.AspectRatio"] = "5:4" ; break;
default : xmpData_["Xmp.video.AspectRatio"] = aspectRatio;break;
case 13:
xmpData_["Xmp.video.AspectRatio"] = "4:3";
break;
case 17:
xmpData_["Xmp.video.AspectRatio"] = "16:9";
break;
case 10:
xmpData_["Xmp.video.AspectRatio"] = "1:1";
break;
case 16:
xmpData_["Xmp.video.AspectRatio"] = "16:10";
break;
case 22:
xmpData_["Xmp.video.AspectRatio"] = "2.21:1";
break;
case 23:
xmpData_["Xmp.video.AspectRatio"] = "2.35:1";
break;
case 12:
xmpData_["Xmp.video.AspectRatio"] = "5:4";
break;
default:
xmpData_["Xmp.video.AspectRatio"] = aspectRatio;
break;
}
} // QuickTimeVideo::aspectRatio
Image::UniquePtr newQTimeInstance(BasicIo::UniquePtr io, bool /*create*/) {
Image::UniquePtr image(new QuickTimeVideo(std::move(io)));
if (!image->good()) {
@ -1625,8 +1593,7 @@ namespace Exiv2 {
if (iIo.error() || iIo.eof()) {
return false;
}
auto qTimeTags =
std::array{"PICT", "free", "ftyp", "junk", "mdat", "moov", "pict", "pnot", "skip", "uuid", "wide"};
auto qTimeTags = std::array{"PICT", "free", "ftyp", "junk", "mdat", "moov", "pict", "pnot", "skip", "uuid", "wide"};
bool matched = false;

Loading…
Cancel
Save