2020-07-29 18:33:53 +00:00
|
|
|
// Copyright 2020 Google LLC
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
|
|
|
#include "ImfNamespace.h"
|
|
|
|
#include <ImfBoxAttribute.h>
|
|
|
|
#include <ImfChannelListAttribute.h>
|
|
|
|
#include <ImfChromaticitiesAttribute.h>
|
|
|
|
#include <ImfCompressionAttribute.h>
|
|
|
|
#include <ImfDoubleAttribute.h>
|
|
|
|
#include <ImfEnvmapAttribute.h>
|
|
|
|
#include <ImfFloatAttribute.h>
|
2020-08-07 18:40:34 +00:00
|
|
|
#include <ImfHeader.h>
|
2020-07-29 18:33:53 +00:00
|
|
|
#include <ImfIntAttribute.h>
|
|
|
|
#include <ImfKeyCodeAttribute.h>
|
|
|
|
#include <ImfLineOrderAttribute.h>
|
|
|
|
#include <ImfMatrixAttribute.h>
|
2020-08-07 18:40:34 +00:00
|
|
|
#include <ImfMultiPartInputFile.h>
|
2020-07-29 18:33:53 +00:00
|
|
|
#include <ImfPreviewImageAttribute.h>
|
|
|
|
#include <ImfRationalAttribute.h>
|
2020-08-07 18:40:34 +00:00
|
|
|
#include <ImfStdIO.h>
|
2020-07-29 18:33:53 +00:00
|
|
|
#include <ImfStringAttribute.h>
|
|
|
|
#include <ImfStringVectorAttribute.h>
|
|
|
|
#include <ImfTileDescriptionAttribute.h>
|
|
|
|
#include <ImfTimeCodeAttribute.h>
|
|
|
|
#include <ImfVecAttribute.h>
|
|
|
|
#include <ImfVersion.h>
|
|
|
|
|
|
|
|
#include <iomanip>
|
2020-08-07 18:40:34 +00:00
|
|
|
#include <iostream>
|
2020-07-29 18:33:53 +00:00
|
|
|
|
|
|
|
using namespace OPENEXR_IMF_NAMESPACE;
|
|
|
|
using namespace std;
|
|
|
|
|
2020-08-07 18:40:34 +00:00
|
|
|
void dumpTimeCode(TimeCode tc) {
|
|
|
|
tc.hours();
|
|
|
|
tc.minutes();
|
|
|
|
tc.seconds();
|
|
|
|
tc.frame();
|
|
|
|
|
|
|
|
tc.dropFrame();
|
|
|
|
tc.colorFrame();
|
|
|
|
tc.fieldPhase();
|
|
|
|
tc.bgf0();
|
|
|
|
tc.bgf1();
|
|
|
|
tc.bgf2();
|
|
|
|
tc.userData();
|
2020-07-29 18:33:53 +00:00
|
|
|
}
|
|
|
|
|
2020-08-07 18:40:34 +00:00
|
|
|
void dumpChannelList(const ChannelList &cl) {
|
|
|
|
for (ChannelList::ConstIterator i = cl.begin(); i != cl.end(); ++i) {
|
|
|
|
i.name();
|
|
|
|
i.channel();
|
|
|
|
}
|
2020-07-29 18:33:53 +00:00
|
|
|
}
|
|
|
|
|
2020-08-07 18:40:34 +00:00
|
|
|
void dumpInfo(IStream &is) {
|
|
|
|
MultiPartInputFile in(is, 0);
|
|
|
|
int parts = in.parts();
|
2020-07-29 18:33:53 +00:00
|
|
|
|
2020-08-07 18:40:34 +00:00
|
|
|
getVersion(in.version());
|
|
|
|
getFlags(in.version());
|
2020-07-29 18:33:53 +00:00
|
|
|
|
2020-08-07 18:40:34 +00:00
|
|
|
for (int p = 0; p < parts; ++p) {
|
|
|
|
const Header &h = in.header(p);
|
2020-07-29 18:33:53 +00:00
|
|
|
|
2020-08-07 18:40:34 +00:00
|
|
|
if (parts != 1) {
|
|
|
|
in.partComplete(p);
|
|
|
|
}
|
2020-07-29 18:33:53 +00:00
|
|
|
|
2020-08-07 18:40:34 +00:00
|
|
|
for (Header::ConstIterator i = h.begin(); i != h.end(); ++i) {
|
|
|
|
const Attribute *a = &i.attribute();
|
|
|
|
i.name();
|
|
|
|
a->typeName();
|
|
|
|
|
|
|
|
if (const Box2iAttribute *ta = dynamic_cast<const Box2iAttribute *>(a)) {
|
|
|
|
ta->value();
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (const Box2fAttribute *ta =
|
|
|
|
dynamic_cast<const Box2fAttribute *>(a)) {
|
|
|
|
ta->value();
|
|
|
|
} else if (const ChannelListAttribute *ta =
|
|
|
|
dynamic_cast<const ChannelListAttribute *>(a)) {
|
|
|
|
dumpChannelList(ta->value());
|
|
|
|
} else if (const ChromaticitiesAttribute *ta =
|
|
|
|
dynamic_cast<const ChromaticitiesAttribute *>(a)) {
|
|
|
|
ta->value();
|
|
|
|
} else if (const DoubleAttribute *ta =
|
|
|
|
dynamic_cast<const DoubleAttribute *>(a)) {
|
|
|
|
ta->value();
|
|
|
|
} else if (const FloatAttribute *ta =
|
|
|
|
dynamic_cast<const FloatAttribute *>(a)) {
|
|
|
|
ta->value();
|
|
|
|
} else if (const IntAttribute *ta =
|
|
|
|
dynamic_cast<const IntAttribute *>(a)) {
|
|
|
|
ta->value();
|
|
|
|
} else if (const KeyCodeAttribute *ta =
|
|
|
|
dynamic_cast<const KeyCodeAttribute *>(a)) {
|
|
|
|
ta->value().filmMfcCode();
|
|
|
|
ta->value().filmType();
|
|
|
|
ta->value().prefix();
|
|
|
|
ta->value().count();
|
|
|
|
ta->value().perfOffset();
|
|
|
|
ta->value().perfsPerFrame();
|
|
|
|
ta->value().perfsPerCount();
|
|
|
|
} else if (const M33fAttribute *ta =
|
|
|
|
dynamic_cast<const M33fAttribute *>(a)) {
|
|
|
|
ta->value();
|
|
|
|
} else if (const M44fAttribute *ta =
|
|
|
|
dynamic_cast<const M44fAttribute *>(a)) {
|
|
|
|
ta->value();
|
|
|
|
} else if (const PreviewImageAttribute *ta =
|
|
|
|
dynamic_cast<const PreviewImageAttribute *>(a)) {
|
|
|
|
ta->value().width();
|
|
|
|
ta->value().height();
|
|
|
|
} else if (const StringAttribute *ta =
|
|
|
|
dynamic_cast<const StringAttribute *>(a)) {
|
|
|
|
ta->value();
|
|
|
|
} else if (const StringVectorAttribute *ta =
|
|
|
|
dynamic_cast<const StringVectorAttribute *>(a)) {
|
|
|
|
for (StringVector::const_iterator i = ta->value().begin();
|
|
|
|
i != ta->value().end(); ++i) {
|
|
|
|
*i;
|
2020-07-29 18:33:53 +00:00
|
|
|
}
|
2020-08-07 18:40:34 +00:00
|
|
|
} else if (const RationalAttribute *ta =
|
|
|
|
dynamic_cast<const RationalAttribute *>(a)) {
|
|
|
|
ta->value();
|
|
|
|
} else if (const TileDescriptionAttribute *ta =
|
|
|
|
dynamic_cast<const TileDescriptionAttribute *>(a)) {
|
|
|
|
ta->value();
|
|
|
|
|
|
|
|
} else if (const TimeCodeAttribute *ta =
|
|
|
|
dynamic_cast<const TimeCodeAttribute *>(a)) {
|
|
|
|
dumpTimeCode(ta->value());
|
|
|
|
} else if (const V2iAttribute *ta =
|
|
|
|
dynamic_cast<const V2iAttribute *>(a)) {
|
|
|
|
ta->value();
|
|
|
|
} else if (const V2fAttribute *ta =
|
|
|
|
dynamic_cast<const V2fAttribute *>(a)) {
|
|
|
|
ta->value();
|
|
|
|
} else if (const V3iAttribute *ta =
|
|
|
|
dynamic_cast<const V3iAttribute *>(a)) {
|
|
|
|
ta->value();
|
|
|
|
} else if (const V3fAttribute *ta =
|
|
|
|
dynamic_cast<const V3fAttribute *>(a)) {
|
|
|
|
ta->value();
|
|
|
|
}
|
2020-07-29 18:33:53 +00:00
|
|
|
}
|
2020-08-07 18:40:34 +00:00
|
|
|
}
|
2020-07-29 18:33:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
|
|
|
|
2020-08-07 18:40:34 +00:00
|
|
|
const std::string s(reinterpret_cast<const char *>(data), size);
|
2020-07-29 18:33:53 +00:00
|
|
|
StdISStream is;
|
|
|
|
is.str(s);
|
|
|
|
|
|
|
|
try {
|
|
|
|
dumpInfo(is);
|
2020-08-06 13:10:51 +00:00
|
|
|
} catch (...) {
|
2020-07-29 18:33:53 +00:00
|
|
|
;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|