|
Packit |
0d464f |
///////////////////////////////////////////////////////////////////////////
|
|
Packit |
0d464f |
//
|
|
Packit |
0d464f |
// Copyright (c) 2011, Industrial Light & Magic, a division of Lucas
|
|
Packit |
0d464f |
// Digital Ltd. LLC
|
|
Packit |
0d464f |
//
|
|
Packit |
0d464f |
// All rights reserved.
|
|
Packit |
0d464f |
//
|
|
Packit |
0d464f |
// Redistribution and use in source and binary forms, with or without
|
|
Packit |
0d464f |
// modification, are permitted provided that the following conditions are
|
|
Packit |
0d464f |
// met:
|
|
Packit |
0d464f |
// * Redistributions of source code must retain the above copyright
|
|
Packit |
0d464f |
// notice, this list of conditions and the following disclaimer.
|
|
Packit |
0d464f |
// * Redistributions in binary form must reproduce the above
|
|
Packit |
0d464f |
// copyright notice, this list of conditions and the following disclaimer
|
|
Packit |
0d464f |
// in the documentation and/or other materials provided with the
|
|
Packit |
0d464f |
// distribution.
|
|
Packit |
0d464f |
// * Neither the name of Industrial Light & Magic nor the names of
|
|
Packit |
0d464f |
// its contributors may be used to endorse or promote products derived
|
|
Packit |
0d464f |
// from this software without specific prior written permission.
|
|
Packit |
0d464f |
//
|
|
Packit |
0d464f |
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
Packit |
0d464f |
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
Packit |
0d464f |
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
Packit |
0d464f |
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
Packit |
0d464f |
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
Packit |
0d464f |
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
Packit |
0d464f |
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
Packit |
0d464f |
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
Packit |
0d464f |
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
Packit |
0d464f |
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
Packit |
0d464f |
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
Packit |
0d464f |
//
|
|
Packit |
0d464f |
///////////////////////////////////////////////////////////////////////////
|
|
Packit |
0d464f |
|
|
Packit |
0d464f |
#include "ImfGenericOutputFile.h"
|
|
Packit |
0d464f |
|
|
Packit |
0d464f |
#include <ImfBoxAttribute.h>
|
|
Packit |
0d464f |
#include <ImfFloatAttribute.h>
|
|
Packit |
0d464f |
#include <ImfTimeCodeAttribute.h>
|
|
Packit |
0d464f |
#include <ImfChromaticitiesAttribute.h>
|
|
Packit |
0d464f |
|
|
Packit |
0d464f |
#include <ImfMisc.h>
|
|
Packit |
0d464f |
#include <ImfPartType.h>
|
|
Packit |
0d464f |
|
|
Packit |
0d464f |
#include "ImfNamespace.h"
|
|
Packit |
0d464f |
|
|
Packit |
0d464f |
|
|
Packit |
0d464f |
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_ENTER
|
|
Packit |
0d464f |
|
|
Packit |
0d464f |
|
|
Packit |
0d464f |
using namespace std;
|
|
Packit |
0d464f |
|
|
Packit |
0d464f |
|
|
Packit |
0d464f |
|
|
Packit |
0d464f |
void
|
|
Packit |
0d464f |
GenericOutputFile::writeMagicNumberAndVersionField (OPENEXR_IMF_INTERNAL_NAMESPACE::OStream& os,
|
|
Packit |
0d464f |
const Header& header)
|
|
Packit |
0d464f |
{
|
|
Packit |
0d464f |
OPENEXR_IMF_INTERNAL_NAMESPACE::Xdr::write <OPENEXR_IMF_INTERNAL_NAMESPACE::StreamIO> (os, MAGIC);
|
|
Packit |
0d464f |
|
|
Packit |
0d464f |
int version = EXR_VERSION;
|
|
Packit |
0d464f |
|
|
Packit |
0d464f |
if (header.hasType() && isDeepData(header.type()))
|
|
Packit |
0d464f |
{
|
|
Packit |
0d464f |
version |= NON_IMAGE_FLAG;
|
|
Packit |
0d464f |
}
|
|
Packit |
0d464f |
else
|
|
Packit |
0d464f |
{
|
|
Packit |
0d464f |
// (TODO) we may want to check something else in function signature
|
|
Packit |
0d464f |
// instead of hasTileDescription()?
|
|
Packit |
0d464f |
if (header.hasTileDescription())
|
|
Packit |
0d464f |
version |= TILED_FLAG;
|
|
Packit |
0d464f |
}
|
|
Packit |
0d464f |
|
|
Packit |
0d464f |
if (usesLongNames (header))
|
|
Packit |
0d464f |
version |= LONG_NAMES_FLAG;
|
|
Packit |
0d464f |
|
|
Packit |
0d464f |
OPENEXR_IMF_INTERNAL_NAMESPACE::Xdr::write <OPENEXR_IMF_INTERNAL_NAMESPACE::StreamIO> (os, version);
|
|
Packit |
0d464f |
}
|
|
Packit |
0d464f |
|
|
Packit |
0d464f |
void
|
|
Packit |
0d464f |
GenericOutputFile::writeMagicNumberAndVersionField (OPENEXR_IMF_INTERNAL_NAMESPACE::OStream& os,
|
|
Packit |
0d464f |
const Header * headers,
|
|
Packit |
0d464f |
int parts)
|
|
Packit |
0d464f |
{
|
|
Packit |
0d464f |
OPENEXR_IMF_INTERNAL_NAMESPACE::Xdr::write <OPENEXR_IMF_INTERNAL_NAMESPACE::StreamIO> (os, MAGIC);
|
|
Packit |
0d464f |
|
|
Packit |
0d464f |
int version = EXR_VERSION;
|
|
Packit |
0d464f |
|
|
Packit |
0d464f |
if (parts == 1)
|
|
Packit |
0d464f |
{
|
|
Packit |
0d464f |
if (headers[0].type() == TILEDIMAGE)
|
|
Packit |
0d464f |
version |= TILED_FLAG;
|
|
Packit |
0d464f |
}
|
|
Packit |
0d464f |
else
|
|
Packit |
0d464f |
{
|
|
Packit |
0d464f |
version |= MULTI_PART_FILE_FLAG;
|
|
Packit |
0d464f |
}
|
|
Packit |
0d464f |
|
|
Packit |
0d464f |
for (int i = 0; i < parts; i++)
|
|
Packit |
0d464f |
{
|
|
Packit |
0d464f |
if (usesLongNames (headers[i]))
|
|
Packit |
0d464f |
version |= LONG_NAMES_FLAG;
|
|
Packit |
0d464f |
|
|
Packit |
0d464f |
if (headers[i].hasType() && isImage(headers[i].type()) == false)
|
|
Packit |
0d464f |
version |= NON_IMAGE_FLAG;
|
|
Packit |
0d464f |
}
|
|
Packit |
0d464f |
|
|
Packit |
0d464f |
OPENEXR_IMF_INTERNAL_NAMESPACE::Xdr::write <OPENEXR_IMF_INTERNAL_NAMESPACE::StreamIO> (os, version);
|
|
Packit |
0d464f |
}
|
|
Packit |
0d464f |
|
|
Packit |
0d464f |
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_EXIT
|