commit
11b020b9f9
327 changed files with 46339 additions and 13384 deletions
@ -1,164 +0,0 @@ |
|||||||
///////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
|
|
||||||
// Digital Ltd. LLC
|
|
||||||
//
|
|
||||||
// All rights reserved.
|
|
||||||
//
|
|
||||||
// Redistribution and use in source and binary forms, with or without
|
|
||||||
// modification, are permitted provided that the following conditions are
|
|
||||||
// met:
|
|
||||||
// * Redistributions of source code must retain the above copyright
|
|
||||||
// notice, this list of conditions and the following disclaimer.
|
|
||||||
// * Redistributions in binary form must reproduce the above
|
|
||||||
// copyright notice, this list of conditions and the following disclaimer
|
|
||||||
// in the documentation and/or other materials provided with the
|
|
||||||
// distribution.
|
|
||||||
// * Neither the name of Industrial Light & Magic nor the names of
|
|
||||||
// its contributors may be used to endorse or promote products derived
|
|
||||||
// from this software without specific prior written permission.
|
|
||||||
//
|
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
//
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// toFloat
|
|
||||||
//
|
|
||||||
// A program to generate the lookup table for half-to-float
|
|
||||||
// conversion needed by class half.
|
|
||||||
// The program loops over all 65536 possible half numbers,
|
|
||||||
// converts each of them to a float, and prints the result.
|
|
||||||
//
|
|
||||||
//---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
|
|
||||||
#include <iostream> |
|
||||||
#include <iomanip> |
|
||||||
|
|
||||||
using namespace std; |
|
||||||
|
|
||||||
//---------------------------------------------------
|
|
||||||
// Interpret an unsigned short bit pattern as a half,
|
|
||||||
// and convert that half to the corresponding float's
|
|
||||||
// bit pattern.
|
|
||||||
//---------------------------------------------------
|
|
||||||
|
|
||||||
unsigned int |
|
||||||
halfToFloat (unsigned short y) |
|
||||||
{ |
|
||||||
|
|
||||||
int s = (y >> 15) & 0x00000001; |
|
||||||
int e = (y >> 10) & 0x0000001f; |
|
||||||
int m = y & 0x000003ff; |
|
||||||
|
|
||||||
if (e == 0) |
|
||||||
{ |
|
||||||
if (m == 0) |
|
||||||
{ |
|
||||||
//
|
|
||||||
// Plus or minus zero
|
|
||||||
//
|
|
||||||
|
|
||||||
return s << 31; |
|
||||||
} |
|
||||||
else |
|
||||||
{ |
|
||||||
//
|
|
||||||
// Denormalized number -- renormalize it
|
|
||||||
//
|
|
||||||
|
|
||||||
while (!(m & 0x00000400)) |
|
||||||
{ |
|
||||||
m <<= 1; |
|
||||||
e -= 1; |
|
||||||
} |
|
||||||
|
|
||||||
e += 1; |
|
||||||
m &= ~0x00000400; |
|
||||||
} |
|
||||||
} |
|
||||||
else if (e == 31) |
|
||||||
{ |
|
||||||
if (m == 0) |
|
||||||
{ |
|
||||||
//
|
|
||||||
// Positive or negative infinity
|
|
||||||
//
|
|
||||||
|
|
||||||
return (s << 31) | 0x7f800000; |
|
||||||
} |
|
||||||
else |
|
||||||
{ |
|
||||||
//
|
|
||||||
// Nan -- preserve sign and significand bits
|
|
||||||
//
|
|
||||||
|
|
||||||
return (s << 31) | 0x7f800000 | (m << 13); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
//
|
|
||||||
// Normalized number
|
|
||||||
//
|
|
||||||
|
|
||||||
e = e + (127 - 15); |
|
||||||
m = m << 13; |
|
||||||
|
|
||||||
//
|
|
||||||
// Assemble s, e and m.
|
|
||||||
//
|
|
||||||
|
|
||||||
return (s << 31) | (e << 23) | m; |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
//---------------------------------------------
|
|
||||||
// Main - prints the half-to-float lookup table
|
|
||||||
//---------------------------------------------
|
|
||||||
|
|
||||||
int |
|
||||||
main () |
|
||||||
{ |
|
||||||
cout.precision (9); |
|
||||||
cout.setf (ios_base::hex, ios_base::basefield); |
|
||||||
|
|
||||||
cout << "//\n" |
|
||||||
"// This is an automatically generated file.\n" |
|
||||||
"// Do not edit.\n" |
|
||||||
"//\n\n"; |
|
||||||
|
|
||||||
cout << "{\n "; |
|
||||||
|
|
||||||
const int iMax = (1 << 16); |
|
||||||
|
|
||||||
for (int i = 0; i < iMax; i++) |
|
||||||
{ |
|
||||||
cout << "{0x" << setfill ('0') << setw (8) << halfToFloat (i) << "}, "; |
|
||||||
|
|
||||||
if (i % 4 == 3) |
|
||||||
{ |
|
||||||
cout << "\n"; |
|
||||||
|
|
||||||
if (i < iMax - 1) |
|
||||||
cout << " "; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
cout << "};\n"; |
|
||||||
return 0; |
|
||||||
} |
|
@ -0,0 +1,51 @@ |
|||||||
|
#ifndef IEXEXPORT_H |
||||||
|
#define IEXEXPORT_H |
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Copyright (c) 2012, Industrial Light & Magic, a division of Lucas
|
||||||
|
// Digital Ltd. LLC
|
||||||
|
//
|
||||||
|
// All rights reserved.
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without
|
||||||
|
// modification, are permitted provided that the following conditions are
|
||||||
|
// met:
|
||||||
|
// * Redistributions of source code must retain the above copyright
|
||||||
|
// notice, this list of conditions and the following disclaimer.
|
||||||
|
// * Redistributions in binary form must reproduce the above
|
||||||
|
// copyright notice, this list of conditions and the following disclaimer
|
||||||
|
// in the documentation and/or other materials provided with the
|
||||||
|
// distribution.
|
||||||
|
// * Neither the name of Industrial Light & Magic nor the names of
|
||||||
|
// its contributors may be used to endorse or promote products derived
|
||||||
|
// from this software without specific prior written permission.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
//
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#if defined(OPENEXR_DLL) |
||||||
|
#if defined(IEX_EXPORTS) |
||||||
|
#define IEX_EXPORT __declspec(dllexport) |
||||||
|
#else |
||||||
|
#define IEX_EXPORT __declspec(dllimport) |
||||||
|
#endif |
||||||
|
#define IEX_EXPORT_CONST |
||||||
|
#else |
||||||
|
#define IEX_EXPORT |
||||||
|
#define IEX_EXPORT_CONST const |
||||||
|
#endif |
||||||
|
|
||||||
|
#endif // #ifndef IEXEXPORT_H
|
||||||
|
|
@ -0,0 +1,229 @@ |
|||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Copyright (c) 2012, Industrial Light & Magic, a division of Lucas
|
||||||
|
// Digital Ltd. LLC
|
||||||
|
//
|
||||||
|
// All rights reserved.
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without
|
||||||
|
// modification, are permitted provided that the following conditions are
|
||||||
|
// met:
|
||||||
|
// * Redistributions of source code must retain the above copyright
|
||||||
|
// notice, this list of conditions and the following disclaimer.
|
||||||
|
// * Redistributions in binary form must reproduce the above
|
||||||
|
// copyright notice, this list of conditions and the following disclaimer
|
||||||
|
// in the documentation and/or other materials provided with the
|
||||||
|
// distribution.
|
||||||
|
// * Neither the name of Industrial Light & Magic nor the names of
|
||||||
|
// its contributors may be used to endorse or promote products derived
|
||||||
|
// from this software without specific prior written permission.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
//
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifndef INCLUDED_IEXFORWARD_H |
||||||
|
#define INCLUDED_IEXFORWARD_H |
||||||
|
|
||||||
|
#include "IexNamespace.h" |
||||||
|
|
||||||
|
IEX_INTERNAL_NAMESPACE_HEADER_ENTER |
||||||
|
|
||||||
|
//
|
||||||
|
// Base exceptions.
|
||||||
|
//
|
||||||
|
|
||||||
|
class BaseExc; |
||||||
|
class ArgExc; |
||||||
|
class LogicExc; |
||||||
|
class InputExc; |
||||||
|
class IoExc; |
||||||
|
class MathExc; |
||||||
|
class ErrnoExc; |
||||||
|
class NoImplExc; |
||||||
|
class NullExc; |
||||||
|
class TypeExc; |
||||||
|
|
||||||
|
//
|
||||||
|
// Math exceptions.
|
||||||
|
//
|
||||||
|
|
||||||
|
class OverflowExc; |
||||||
|
class UnderflowExc; |
||||||
|
class DivzeroExc; |
||||||
|
class InexactExc; |
||||||
|
class InvalidFpOpExc; |
||||||
|
|
||||||
|
//
|
||||||
|
// Errno exceptions.
|
||||||
|
//
|
||||||
|
|
||||||
|
class EpermExc; |
||||||
|
class EnoentExc; |
||||||
|
class EsrchExc; |
||||||
|
class EintrExc; |
||||||
|
class EioExc; |
||||||
|
class EnxioExc; |
||||||
|
class E2bigExc; |
||||||
|
class EnoexecExc; |
||||||
|
class EbadfExc; |
||||||
|
class EchildExc; |
||||||
|
class EagainExc; |
||||||
|
class EnomemExc; |
||||||
|
class EaccesExc; |
||||||
|
class EfaultExc; |
||||||
|
class EnotblkExc; |
||||||
|
class EbusyExc; |
||||||
|
class EexistExc; |
||||||
|
class ExdevExc; |
||||||
|
class EnodevExc; |
||||||
|
class EnotdirExc; |
||||||
|
class EisdirExc; |
||||||
|
class EinvalExc; |
||||||
|
class EnfileExc; |
||||||
|
class EmfileExc; |
||||||
|
class EnottyExc; |
||||||
|
class EtxtbsyExc; |
||||||
|
class EfbigExc; |
||||||
|
class EnospcExc; |
||||||
|
class EspipeExc; |
||||||
|
class ErofsExc; |
||||||
|
class EmlinkExc; |
||||||
|
class EpipeExc; |
||||||
|
class EdomExc; |
||||||
|
class ErangeExc; |
||||||
|
class EnomsgExc; |
||||||
|
class EidrmExc; |
||||||
|
class EchrngExc; |
||||||
|
class El2nsyncExc; |
||||||
|
class El3hltExc; |
||||||
|
class El3rstExc; |
||||||
|
class ElnrngExc; |
||||||
|
class EunatchExc; |
||||||
|
class EnocsiExc; |
||||||
|
class El2hltExc; |
||||||
|
class EdeadlkExc; |
||||||
|
class EnolckExc; |
||||||
|
class EbadeExc; |
||||||
|
class EbadrExc; |
||||||
|
class ExfullExc; |
||||||
|
class EnoanoExc; |
||||||
|
class EbadrqcExc; |
||||||
|
class EbadsltExc; |
||||||
|
class EdeadlockExc; |
||||||
|
class EbfontExc; |
||||||
|
class EnostrExc; |
||||||
|
class EnodataExc; |
||||||
|
class EtimeExc; |
||||||
|
class EnosrExc; |
||||||
|
class EnonetExc; |
||||||
|
class EnopkgExc; |
||||||
|
class EremoteExc; |
||||||
|
class EnolinkExc; |
||||||
|
class EadvExc; |
||||||
|
class EsrmntExc; |
||||||
|
class EcommExc; |
||||||
|
class EprotoExc; |
||||||
|
class EmultihopExc; |
||||||
|
class EbadmsgExc; |
||||||
|
class EnametoolongExc; |
||||||
|
class EoverflowExc; |
||||||
|
class EnotuniqExc; |
||||||
|
class EbadfdExc; |
||||||
|
class EremchgExc; |
||||||
|
class ElibaccExc; |
||||||
|
class ElibbadExc; |
||||||
|
class ElibscnExc; |
||||||
|
class ElibmaxExc; |
||||||
|
class ElibexecExc; |
||||||
|
class EilseqExc; |
||||||
|
class EnosysExc; |
||||||
|
class EloopExc; |
||||||
|
class ErestartExc; |
||||||
|
class EstrpipeExc; |
||||||
|
class EnotemptyExc; |
||||||
|
class EusersExc; |
||||||
|
class EnotsockExc; |
||||||
|
class EdestaddrreqExc; |
||||||
|
class EmsgsizeExc; |
||||||
|
class EprototypeExc; |
||||||
|
class EnoprotooptExc; |
||||||
|
class EprotonosupportExc; |
||||||
|
class EsocktnosupportExc; |
||||||
|
class EopnotsuppExc; |
||||||
|
class EpfnosupportExc; |
||||||
|
class EafnosupportExc; |
||||||
|
class EaddrinuseExc; |
||||||
|
class EaddrnotavailExc; |
||||||
|
class EnetdownExc; |
||||||
|
class EnetunreachExc; |
||||||
|
class EnetresetExc; |
||||||
|
class EconnabortedExc; |
||||||
|
class EconnresetExc; |
||||||
|
class EnobufsExc; |
||||||
|
class EisconnExc; |
||||||
|
class EnotconnExc; |
||||||
|
class EshutdownExc; |
||||||
|
class EtoomanyrefsExc; |
||||||
|
class EtimedoutExc; |
||||||
|
class EconnrefusedExc; |
||||||
|
class EhostdownExc; |
||||||
|
class EhostunreachExc; |
||||||
|
class EalreadyExc; |
||||||
|
class EinprogressExc; |
||||||
|
class EstaleExc; |
||||||
|
class EioresidExc; |
||||||
|
class EucleanExc; |
||||||
|
class EnotnamExc; |
||||||
|
class EnavailExc; |
||||||
|
class EisnamExc; |
||||||
|
class EremoteioExc; |
||||||
|
class EinitExc; |
||||||
|
class EremdevExc; |
||||||
|
class EcanceledExc; |
||||||
|
class EnolimfileExc; |
||||||
|
class EproclimExc; |
||||||
|
class EdisjointExc; |
||||||
|
class EnologinExc; |
||||||
|
class EloginlimExc; |
||||||
|
class EgrouploopExc; |
||||||
|
class EnoattachExc; |
||||||
|
class EnotsupExc; |
||||||
|
class EnoattrExc; |
||||||
|
class EdircorruptedExc; |
||||||
|
class EdquotExc; |
||||||
|
class EnfsremoteExc; |
||||||
|
class EcontrollerExc; |
||||||
|
class EnotcontrollerExc; |
||||||
|
class EenqueuedExc; |
||||||
|
class EnotenqueuedExc; |
||||||
|
class EjoinedExc; |
||||||
|
class EnotjoinedExc; |
||||||
|
class EnoprocExc; |
||||||
|
class EmustrunExc; |
||||||
|
class EnotstoppedExc; |
||||||
|
class EclockcpuExc; |
||||||
|
class EinvalstateExc; |
||||||
|
class EnoexistExc; |
||||||
|
class EendofminorExc; |
||||||
|
class EbufsizeExc; |
||||||
|
class EemptyExc; |
||||||
|
class EnointrgroupExc; |
||||||
|
class EinvalmodeExc; |
||||||
|
class EcantextentExc; |
||||||
|
class EinvaltimeExc; |
||||||
|
class EdestroyedExc; |
||||||
|
|
||||||
|
IEX_INTERNAL_NAMESPACE_HEADER_EXIT |
||||||
|
|
||||||
|
#endif // INCLUDED_IEXFORWARD_H
|
@ -0,0 +1,112 @@ |
|||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Copyright (c) 2012, Industrial Light & Magic, a division of Lucas
|
||||||
|
// Digital Ltd. LLC
|
||||||
|
//
|
||||||
|
// All rights reserved.
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without
|
||||||
|
// modification, are permitted provided that the following conditions are
|
||||||
|
// met:
|
||||||
|
// * Redistributions of source code must retain the above copyright
|
||||||
|
// notice, this list of conditions and the following disclaimer.
|
||||||
|
// * Redistributions in binary form must reproduce the above
|
||||||
|
// copyright notice, this list of conditions and the following disclaimer
|
||||||
|
// in the documentation and/or other materials provided with the
|
||||||
|
// distribution.
|
||||||
|
// * Neither the name of Industrial Light & Magic nor the names of
|
||||||
|
// its contributors may be used to endorse or promote products derived
|
||||||
|
// from this software without specific prior written permission.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
//
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifndef INCLUDED_IEXNAMESPACE_H |
||||||
|
#define INCLUDED_IEXNAMESPACE_H |
||||||
|
|
||||||
|
//
|
||||||
|
// The purpose of this file is to make it possible to specify an
|
||||||
|
// IEX_INTERNAL_NAMESPACE as a preprocessor definition and have all of the
|
||||||
|
// Iex symbols defined within that namespace rather than the standard
|
||||||
|
// Iex namespace. Those symbols are made available to client code through
|
||||||
|
// the IEX_NAMESPACE in addition to the IEX_INTERNAL_NAMESPACE.
|
||||||
|
//
|
||||||
|
// To ensure source code compatibility, the IEX_NAMESPACE defaults to Iex
|
||||||
|
// and then "using namespace IEX_INTERNAL_NAMESPACE;" brings all of the
|
||||||
|
// declarations from the IEX_INTERNAL_NAMESPACE into the IEX_NAMESPACE. This
|
||||||
|
// means that client code can continue to use syntax like Iex::BaseExc, but
|
||||||
|
// at link time it will resolve to a mangled symbol based on the
|
||||||
|
// IEX_INTERNAL_NAMESPACE.
|
||||||
|
//
|
||||||
|
// As an example, if one needed to build against a newer version of Iex and
|
||||||
|
// have it run alongside an older version in the same application, it is now
|
||||||
|
// possible to use an internal namespace to prevent collisions between the
|
||||||
|
// older versions of Iex symbols and the newer ones. To do this, the
|
||||||
|
// following could be defined at build time:
|
||||||
|
//
|
||||||
|
// IEX_INTERNAL_NAMESPACE = Iex_v2
|
||||||
|
//
|
||||||
|
// This means that declarations inside Iex headers look like this (after the
|
||||||
|
// preprocessor has done its work):
|
||||||
|
//
|
||||||
|
// namespace Iex_v2 {
|
||||||
|
// ...
|
||||||
|
// class declarations
|
||||||
|
// ...
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// namespace Iex {
|
||||||
|
// using namespace Iex_v2;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
|
||||||
|
//
|
||||||
|
// Open Source version of this file pulls in the IlmBaseConfig.h file
|
||||||
|
// for the configure time options.
|
||||||
|
//
|
||||||
|
#include "IlmBaseConfig.h" |
||||||
|
|
||||||
|
#ifndef IEX_NAMESPACE |
||||||
|
#define IEX_NAMESPACE Iex |
||||||
|
#endif |
||||||
|
|
||||||
|
#ifndef IEX_INTERNAL_NAMESPACE |
||||||
|
#define IEX_INTERNAL_NAMESPACE IEX_NAMESPACE |
||||||
|
#endif |
||||||
|
|
||||||
|
//
|
||||||
|
// We need to be sure that we import the internal namespace into the public one.
|
||||||
|
// To do this, we use the small bit of code below which initially defines
|
||||||
|
// IEX_INTERNAL_NAMESPACE (so it can be referenced) and then defines
|
||||||
|
// IEX_NAMESPACE and pulls the internal symbols into the public namespace.
|
||||||
|
//
|
||||||
|
|
||||||
|
namespace IEX_INTERNAL_NAMESPACE {} |
||||||
|
namespace IEX_NAMESPACE { |
||||||
|
using namespace IEX_INTERNAL_NAMESPACE; |
||||||
|
} |
||||||
|
|
||||||
|
//
|
||||||
|
// There are identical pairs of HEADER/SOURCE ENTER/EXIT macros so that
|
||||||
|
// future extension to the namespace mechanism is possible without changing
|
||||||
|
// project source code.
|
||||||
|
//
|
||||||
|
|
||||||
|
#define IEX_INTERNAL_NAMESPACE_HEADER_ENTER namespace IEX_INTERNAL_NAMESPACE { |
||||||
|
#define IEX_INTERNAL_NAMESPACE_HEADER_EXIT } |
||||||
|
|
||||||
|
#define IEX_INTERNAL_NAMESPACE_SOURCE_ENTER namespace IEX_INTERNAL_NAMESPACE { |
||||||
|
#define IEX_INTERNAL_NAMESPACE_SOURCE_EXIT } |
||||||
|
|
||||||
|
#endif // INCLUDED_IEXNAMESPACE_H
|
@ -0,0 +1,591 @@ |
|||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Copyright (c) 2012, Weta Digital Ltd
|
||||||
|
//
|
||||||
|
// All rights reserved.
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without
|
||||||
|
// modification, are permitted provided that the following conditions are
|
||||||
|
// met:
|
||||||
|
// * Redistributions of source code must retain the above copyright
|
||||||
|
// notice, this list of conditions and the following disclaimer.
|
||||||
|
// * Redistributions in binary form must reproduce the above
|
||||||
|
// copyright notice, this list of conditions and the following disclaimer
|
||||||
|
// in the documentation and/or other materials provided with the
|
||||||
|
// distribution.
|
||||||
|
// * Neither the name of Weta Digital nor the names of
|
||||||
|
// its contributors may be used to endorse or promote products derived
|
||||||
|
// from this software without specific prior written permission.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
//
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
#include "ImfCompositeDeepScanLine.h" |
||||||
|
#include "ImfDeepScanLineInputPart.h" |
||||||
|
#include "ImfDeepScanLineInputFile.h" |
||||||
|
#include "ImfChannelList.h" |
||||||
|
#include "ImfFrameBuffer.h" |
||||||
|
#include "ImfDeepFrameBuffer.h" |
||||||
|
#include "ImfDeepCompositing.h" |
||||||
|
#include "ImfPixelType.h" |
||||||
|
#include "IlmThreadPool.h" |
||||||
|
|
||||||
|
#include <Iex.h> |
||||||
|
#include <vector> |
||||||
|
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_ENTER |
||||||
|
|
||||||
|
using std::vector; |
||||||
|
using std::string; |
||||||
|
using IMATH_NAMESPACE::Box2i; |
||||||
|
using ILMTHREAD_NAMESPACE::Task; |
||||||
|
using ILMTHREAD_NAMESPACE::TaskGroup; |
||||||
|
using ILMTHREAD_NAMESPACE::ThreadPool; |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
struct CompositeDeepScanLine::Data{ |
||||||
|
public : |
||||||
|
vector<DeepScanLineInputFile *> _file; // array of files
|
||||||
|
vector<DeepScanLineInputPart *> _part; // array of parts
|
||||||
|
FrameBuffer _outputFrameBuffer; // output frame buffer provided
|
||||||
|
bool _zback; // true if we are using zback (otherwise channel 1 = channel 0)
|
||||||
|
vector< vector<float> > _channeldata; // pixel values, read from the input, one array per channel
|
||||||
|
vector< int > _sampleCounts; // total per-pixel sample counts,
|
||||||
|
Box2i _dataWindow; // data window of combined inputs
|
||||||
|
DeepCompositing * _comp; // user-provided compositor
|
||||||
|
vector<string> _channels; // names of channels that will be composited
|
||||||
|
vector<int> _bufferMap; // entry _outputFrameBuffer[n].name() == _channels[ _bufferMap[n] ].name()
|
||||||
|
|
||||||
|
void check_valid(const Header & header); // check newly added part/file is OK; on first good call, set _zback/_dataWindow
|
||||||
|
|
||||||
|
//
|
||||||
|
// set up the given deep frame buffer to contain the required channels
|
||||||
|
// resize counts and pointers to the width of _dataWindow
|
||||||
|
// zero-out all counts, since the datawindow may be smaller than/not include this part
|
||||||
|
//
|
||||||
|
|
||||||
|
void handleDeepFrameBuffer (DeepFrameBuffer & buf, |
||||||
|
vector<unsigned int> & counts, //per-pixel counts
|
||||||
|
vector< vector<float *> > & pointers, //per-channel-per-pixel pointers to data
|
||||||
|
const Header & header, |
||||||
|
int start, |
||||||
|
int end); |
||||||
|
|
||||||
|
Data(); |
||||||
|
}; |
||||||
|
|
||||||
|
CompositeDeepScanLine::Data::Data() : _zback(false) , _comp(NULL) {} |
||||||
|
|
||||||
|
CompositeDeepScanLine::CompositeDeepScanLine() : _Data(new Data) {} |
||||||
|
|
||||||
|
CompositeDeepScanLine::~CompositeDeepScanLine() |
||||||
|
{ |
||||||
|
delete _Data; |
||||||
|
} |
||||||
|
|
||||||
|
void |
||||||
|
CompositeDeepScanLine::addSource(DeepScanLineInputPart* part) |
||||||
|
{ |
||||||
|
_Data->check_valid(part->header()); |
||||||
|
_Data->_part.push_back(part); |
||||||
|
} |
||||||
|
|
||||||
|
void |
||||||
|
CompositeDeepScanLine::addSource(DeepScanLineInputFile* file) |
||||||
|
{ |
||||||
|
_Data->check_valid(file->header()); |
||||||
|
_Data->_file.push_back(file); |
||||||
|
} |
||||||
|
|
||||||
|
int
|
||||||
|
CompositeDeepScanLine::sources() const |
||||||
|
{ |
||||||
|
return int(_Data->_part.size())+int(_Data->_file.size()); |
||||||
|
} |
||||||
|
|
||||||
|
void |
||||||
|
CompositeDeepScanLine::Data::check_valid(const Header & header) |
||||||
|
{ |
||||||
|
|
||||||
|
bool has_z=false; |
||||||
|
bool has_alpha=false; |
||||||
|
// check good channel names
|
||||||
|
for( ChannelList::ConstIterator i=header.channels().begin();i!=header.channels().end();++i) |
||||||
|
{ |
||||||
|
std::string n(i.name());
|
||||||
|
if(n=="ZBack") |
||||||
|
{ |
||||||
|
_zback=true; |
||||||
|
} |
||||||
|
else if(n=="Z") |
||||||
|
{ |
||||||
|
has_z=true; |
||||||
|
} |
||||||
|
else if(n=="A") |
||||||
|
{ |
||||||
|
has_alpha=true; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
if(!has_z) |
||||||
|
{ |
||||||
|
throw IEX_NAMESPACE::ArgExc("Deep data provided to CompositeDeepScanLine is missing a Z channel"); |
||||||
|
} |
||||||
|
|
||||||
|
if(!has_alpha) |
||||||
|
{ |
||||||
|
throw IEX_NAMESPACE::ArgExc("Deep data provided to CompositeDeepScanLine is missing an alpha channel"); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
if(_part.size()==0 && _file.size()==0) |
||||||
|
{ |
||||||
|
// first in - update and return
|
||||||
|
|
||||||
|
_dataWindow = header.dataWindow(); |
||||||
|
|
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
const Header * const match_header = _part.size()>0 ? &_part[0]->header() : &_file[0]->header(); |
||||||
|
|
||||||
|
// check the sizes match
|
||||||
|
if(match_header->displayWindow() != header.displayWindow()) |
||||||
|
{ |
||||||
|
throw IEX_NAMESPACE::ArgExc("Deep data provided to CompositeDeepScanLine has a different displayWindow to previously provided data"); |
||||||
|
} |
||||||
|
|
||||||
|
_dataWindow.extendBy(header.dataWindow()); |
||||||
|
|
||||||
|
} |
||||||
|
void
|
||||||
|
CompositeDeepScanLine::Data::handleDeepFrameBuffer (DeepFrameBuffer& buf, |
||||||
|
std::vector< unsigned int > & counts, |
||||||
|
vector< std::vector< float* > > & pointers, |
||||||
|
const Header& header, |
||||||
|
int start, |
||||||
|
int end) |
||||||
|
{ |
||||||
|
int width=_dataWindow.size().x+1; |
||||||
|
size_t pixelcount = width * (end-start+1); |
||||||
|
pointers.resize(_channels.size()); |
||||||
|
counts.resize(pixelcount); |
||||||
|
buf.insertSampleCountSlice (Slice (OPENEXR_IMF_INTERNAL_NAMESPACE::UINT, |
||||||
|
(char *) (&counts[0]-_dataWindow.min.x-start*width), |
||||||
|
sizeof(unsigned int), |
||||||
|
sizeof(unsigned int)*width)); |
||||||
|
|
||||||
|
pointers[0].resize(pixelcount); |
||||||
|
buf.insert ("Z", DeepSlice (OPENEXR_IMF_INTERNAL_NAMESPACE::FLOAT, |
||||||
|
(char *)(&pointers[0][0]-_dataWindow.min.x-start*width), |
||||||
|
sizeof(float *), |
||||||
|
sizeof(float *)*width, |
||||||
|
sizeof(float) )); |
||||||
|
|
||||||
|
if(_zback) |
||||||
|
{ |
||||||
|
pointers[1].resize(pixelcount); |
||||||
|
buf.insert ("ZBack", DeepSlice (OPENEXR_IMF_INTERNAL_NAMESPACE::FLOAT, |
||||||
|
(char *)(&pointers[1][0]-_dataWindow.min.x-start*width), |
||||||
|
sizeof(float *), |
||||||
|
sizeof(float *)*width, |
||||||
|
sizeof(float) )); |
||||||
|
} |
||||||
|
|
||||||
|
pointers[2].resize(pixelcount); |
||||||
|
buf.insert ("A", DeepSlice (OPENEXR_IMF_INTERNAL_NAMESPACE::FLOAT, |
||||||
|
(char *)(&pointers[2][0]-_dataWindow.min.x-start*width), |
||||||
|
sizeof(float *), |
||||||
|
sizeof(float *)*width, |
||||||
|
sizeof(float) )); |
||||||
|
|
||||||
|
|
||||||
|
size_t i =0; |
||||||
|
for(FrameBuffer::ConstIterator qt = _outputFrameBuffer.begin(); |
||||||
|
qt != _outputFrameBuffer.end(); |
||||||
|
qt++) |
||||||
|
{ |
||||||
|
int channel_in_source = _bufferMap[i]; |
||||||
|
if(channel_in_source>2) |
||||||
|
{ |
||||||
|
// not dealt with yet (0,1,2 previously inserted)
|
||||||
|
pointers[channel_in_source].resize(pixelcount); |
||||||
|
buf.insert (qt.name(), |
||||||
|
DeepSlice (OPENEXR_IMF_INTERNAL_NAMESPACE::FLOAT, |
||||||
|
(char *)(&pointers[channel_in_source][0]-_dataWindow.min.x-start*width), |
||||||
|
sizeof(float *), |
||||||
|
sizeof(float *)*width, |
||||||
|
sizeof(float) )); |
||||||
|
} |
||||||
|
|
||||||
|
i++; |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
void |
||||||
|
CompositeDeepScanLine::setCompositing(DeepCompositing* c) |
||||||
|
{ |
||||||
|
_Data->_comp=c; |
||||||
|
} |
||||||
|
|
||||||
|
const IMATH_NAMESPACE::Box2i& CompositeDeepScanLine::dataWindow() const |
||||||
|
{ |
||||||
|
return _Data->_dataWindow; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
void |
||||||
|
CompositeDeepScanLine::setFrameBuffer(const FrameBuffer& fr) |
||||||
|
{ |
||||||
|
|
||||||
|
//
|
||||||
|
// count channels; build map between channels in frame buffer
|
||||||
|
// and channels in internal buffers
|
||||||
|
//
|
||||||
|
|
||||||
|
_Data->_channels.resize(3); |
||||||
|
_Data->_channels[0]="Z"; |
||||||
|
_Data->_channels[1]=_Data->_zback ? "ZBack" : "Z"; |
||||||
|
_Data->_channels[2]="A"; |
||||||
|
_Data->_bufferMap.resize(0); |
||||||
|
|
||||||
|
for(FrameBuffer::ConstIterator q=fr.begin();q!=fr.end();q++) |
||||||
|
{ |
||||||
|
string name(q.name()); |
||||||
|
if(name=="ZBack") |
||||||
|
{ |
||||||
|
_Data->_bufferMap.push_back(1); |
||||||
|
}else if(name=="Z") |
||||||
|
{ |
||||||
|
_Data->_bufferMap.push_back(0); |
||||||
|
}else if(name=="A") |
||||||
|
{ |
||||||
|
_Data->_bufferMap.push_back(2); |
||||||
|
}else{ |
||||||
|
_Data->_bufferMap.push_back(_Data->_channels.size()); |
||||||
|
_Data->_channels.push_back(name); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
_Data->_outputFrameBuffer=fr; |
||||||
|
} |
||||||
|
|
||||||
|
namespace
|
||||||
|
{ |
||||||
|
|
||||||
|
class LineCompositeTask : public Task |
||||||
|
{ |
||||||
|
public: |
||||||
|
|
||||||
|
LineCompositeTask ( TaskGroup* group , |
||||||
|
CompositeDeepScanLine::Data * data, |
||||||
|
int y, |
||||||
|
int start, |
||||||
|
vector<const char*>* names, |
||||||
|
vector<vector< vector<float *> > >* pointers, |
||||||
|
vector<unsigned int>* total_sizes, |
||||||
|
vector<unsigned int>* num_sources |
||||||
|
) : Task(group) , |
||||||
|
_Data(data), |
||||||
|
_y(y), |
||||||
|
_start(start), |
||||||
|
_names(names), |
||||||
|
_pointers(pointers), |
||||||
|
_total_sizes(total_sizes), |
||||||
|
_num_sources(num_sources) |
||||||
|
{} |
||||||
|
|
||||||
|
virtual ~LineCompositeTask () {} |
||||||
|
|
||||||
|
virtual void execute (); |
||||||
|
CompositeDeepScanLine::Data* _Data; |
||||||
|
int _y; |
||||||
|
int _start; |
||||||
|
vector<const char *>* _names; |
||||||
|
vector<vector< vector<float *> > >* _pointers; |
||||||
|
vector<unsigned int>* _total_sizes; |
||||||
|
vector<unsigned int>* _num_sources; |
||||||
|
|
||||||
|
}; |
||||||
|
|
||||||
|
|
||||||
|
void |
||||||
|
composite_line(int y, |
||||||
|
int start, |
||||||
|
CompositeDeepScanLine::Data * _Data, |
||||||
|
vector<const char *> & names, |
||||||
|
const vector<vector< vector<float *> > > & pointers, |
||||||
|
const vector<unsigned int> & total_sizes, |
||||||
|
const vector<unsigned int> & num_sources |
||||||
|
) |
||||||
|
{ |
||||||
|
vector<float> output_pixel(names.size()); //the pixel we'll output to
|
||||||
|
vector<const float *> inputs(names.size()); |
||||||
|
DeepCompositing d; // fallback compositing engine
|
||||||
|
DeepCompositing * comp= _Data->_comp ? _Data->_comp : &d; |
||||||
|
|
||||||
|
int pixel = (y-start)*(_Data->_dataWindow.max.x+1-_Data->_dataWindow.min.x); |
||||||
|
|
||||||
|
for(int x=_Data->_dataWindow.min.x;x<=_Data->_dataWindow.max.x;x++) |
||||||
|
{ |
||||||
|
// set inputs[] to point to the first sample of the first part of each channel
|
||||||
|
// if there's a zback, set all channel independently...
|
||||||
|
|
||||||
|
if(_Data->_zback) |
||||||
|
{ |
||||||
|
|
||||||
|
for(size_t channel=0;channel<names.size();channel++) |
||||||
|
{ |
||||||
|
inputs[channel]=pointers[0][channel][pixel]; |
||||||
|
} |
||||||
|
|
||||||
|
}else{ |
||||||
|
|
||||||
|
// otherwise, set 0 and 1 to point to Z
|
||||||
|
|
||||||
|
|
||||||
|
inputs[0]=pointers[0][0][pixel]; |
||||||
|
inputs[1]=pointers[0][0][pixel]; |
||||||
|
for(size_t channel=2;channel<names.size();channel++) |
||||||
|
{ |
||||||
|
inputs[channel]=pointers[0][channel][pixel]; |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
comp->composite_pixel(&output_pixel[0], |
||||||
|
&inputs[0], |
||||||
|
&names[0], |
||||||
|
names.size(), |
||||||
|
total_sizes[pixel], |
||||||
|
num_sources[pixel] |
||||||
|
); |
||||||
|
|
||||||
|
|
||||||
|
size_t channel_number=0; |
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// write out composited value into internal frame buffer
|
||||||
|
//
|
||||||
|
for(FrameBuffer::Iterator it = _Data->_outputFrameBuffer.begin();it !=_Data->_outputFrameBuffer.end();it++) |
||||||
|
{ |
||||||
|
|
||||||
|
float value = output_pixel[ _Data->_bufferMap[channel_number] ]; // value to write
|
||||||
|
|
||||||
|
|
||||||
|
// cast to half float if necessary
|
||||||
|
if(it.slice().type==OPENEXR_IMF_INTERNAL_NAMESPACE::FLOAT) |
||||||
|
{ |
||||||
|
* (float *)(it.slice().base + y*it.slice().yStride + x*it.slice().xStride) = value; |
||||||
|
} |
||||||
|
else if(it.slice().type==HALF) |
||||||
|
{ |
||||||
|
* (half *)(it.slice().base + y*it.slice().yStride + x*it.slice().xStride) = half(value); |
||||||
|
} |
||||||
|
|
||||||
|
channel_number++; |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
pixel++; |
||||||
|
|
||||||
|
}// next pixel on row
|
||||||
|
} |
||||||
|
|
||||||
|
void LineCompositeTask::execute() |
||||||
|
{ |
||||||
|
composite_line(_y,_start,_Data,*_names,*_pointers,*_total_sizes,*_num_sources); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
void |
||||||
|
CompositeDeepScanLine::readPixels(int start, int end) |
||||||
|
{ |
||||||
|
size_t parts = _Data->_file.size() + _Data->_part.size(); // total of files+parts
|
||||||
|
|
||||||
|
vector<DeepFrameBuffer> framebuffers(parts); |
||||||
|
vector< vector<unsigned int> > counts(parts); |
||||||
|
|
||||||
|
//
|
||||||
|
// for each part, a pointer to an array of channels
|
||||||
|
//
|
||||||
|
vector<vector< vector<float *> > > pointers(parts); |
||||||
|
vector<const Header *> headers(parts); |
||||||
|
|
||||||
|
{ |
||||||
|
size_t i; |
||||||
|
for(i=0;i<_Data->_file.size();i++) |
||||||
|
{ |
||||||
|
headers[i] = &_Data->_file[i]->header(); |
||||||
|
} |
||||||
|
|
||||||
|
for(size_t j=0;j<_Data->_part.size();j++) |
||||||
|
{ |
||||||
|
headers[i+j] = &_Data->_part[j]->header(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
for(size_t i=0;i<parts;i++) |
||||||
|
{ |
||||||
|
_Data->handleDeepFrameBuffer(framebuffers[i],counts[i],pointers[i],*headers[i],start,end); |
||||||
|
} |
||||||
|
|
||||||
|
//
|
||||||
|
// set frame buffers and read scanlines from all parts
|
||||||
|
// TODO what happens if SCANLINE not in data window?
|
||||||
|
//
|
||||||
|
|
||||||
|
{ |
||||||
|
size_t i=0; |
||||||
|
for(i=0;i<_Data->_file.size();i++) |
||||||
|
{ |
||||||
|
_Data->_file[i]->setFrameBuffer(framebuffers[i]); |
||||||
|
_Data->_file[i]->readPixelSampleCounts(start,end); |
||||||
|
} |
||||||
|
for(size_t j=0;j<_Data->_part.size();j++) |
||||||
|
{ |
||||||
|
_Data->_part[j]->setFrameBuffer(framebuffers[i+j]); |
||||||
|
_Data->_part[j]->readPixelSampleCounts(start,end);
|
||||||
|
} |
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// total width
|
||||||
|
//
|
||||||
|
|
||||||
|
size_t total_width = _Data->_dataWindow.size().x+1; |
||||||
|
size_t total_pixels = total_width*(end-start+1); |
||||||
|
vector<unsigned int> total_sizes(total_pixels); |
||||||
|
vector<unsigned int> num_sources(total_pixels); //number of parts with non-zero sample count
|
||||||
|
|
||||||
|
size_t overall_sample_count=0; // sum of all samples in all images between start and end
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// accumulate pixel counts
|
||||||
|
//
|
||||||
|
for(size_t ptr=0;ptr<total_pixels;ptr++) |
||||||
|
{ |
||||||
|
total_sizes[ptr]=0; |
||||||
|
num_sources[ptr]=0; |
||||||
|
for(size_t j=0;j<parts;j++) |
||||||
|
{ |
||||||
|
total_sizes[ptr]+=counts[j][ptr]; |
||||||
|
if(counts[j][ptr]>0) num_sources[ptr]++; |
||||||
|
} |
||||||
|
overall_sample_count+=total_sizes[ptr]; |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// allocate arrays for pixel data
|
||||||
|
// samples array accessed as in pixels[channel][sample]
|
||||||
|
//
|
||||||
|
|
||||||
|
vector<vector<float> > samples( _Data->_channels.size() ); |
||||||
|
|
||||||
|
for(size_t channel=0;channel<_Data->_channels.size();channel++) |
||||||
|
{ |
||||||
|
if( channel!=1 || _Data->_zback) |
||||||
|
{
|
||||||
|
samples[channel].resize(overall_sample_count); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
for(size_t channel=0;channel<samples.size();channel++) |
||||||
|
{ |
||||||
|
|
||||||
|
if( channel!=1 || _Data->_zback) |
||||||
|
{ |
||||||
|
|
||||||
|
samples[channel].resize(overall_sample_count); |
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// allocate pointers for channel data
|
||||||
|
//
|
||||||
|
|
||||||
|
size_t offset=0; |
||||||
|
|
||||||
|
for(size_t pixel=0;pixel<total_pixels;pixel++) |
||||||
|
{ |
||||||
|
for(size_t part=0 ; part<parts && offset<overall_sample_count ; part++ ) |
||||||
|
{ |
||||||
|
pointers[part][channel][pixel]=&samples[channel][offset];
|
||||||
|
offset+=counts[part][pixel]; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
//
|
||||||
|
// read data
|
||||||
|
//
|
||||||
|
|
||||||
|
for(size_t i=0;i<_Data->_file.size();i++) |
||||||
|
{ |
||||||
|
_Data->_file[i]->readPixels(start,end); |
||||||
|
} |
||||||
|
for(size_t j=0;j<_Data->_part.size();j++) |
||||||
|
{ |
||||||
|
_Data->_part[j]->readPixels(start,end);
|
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// composite pixels and write back to framebuffer
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
// turn vector of strings into array of char *
|
||||||
|
// and make sure 'ZBack' channel is correct
|
||||||
|
vector<const char *> names(_Data->_channels.size()); |
||||||
|
for(size_t i=0;i<names.size();i++) |
||||||
|
{ |
||||||
|
names[i]=_Data->_channels[i].c_str(); |
||||||
|
} |
||||||
|
|
||||||
|
if(!_Data->_zback) names[1]=names[0]; // no zback channel, so make it point to z
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
TaskGroup g; |
||||||
|
for(int y=start;y<=end;y++) |
||||||
|
{ |
||||||
|
ThreadPool::addGlobalTask(new LineCompositeTask(&g,_Data,y,start,&names,&pointers,&total_sizes,&num_sources)); |
||||||
|
}//next row
|
||||||
|
}
|
||||||
|
|
||||||
|
const FrameBuffer&
|
||||||
|
CompositeDeepScanLine::frameBuffer() const |
||||||
|
{ |
||||||
|
return _Data->_outputFrameBuffer; |
||||||
|
} |
||||||
|
|
||||||
|
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_EXIT |
@ -0,0 +1,152 @@ |
|||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Copyright (c) 2012, Weta Digital Ltd
|
||||||
|
//
|
||||||
|
// All rights reserved.
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without
|
||||||
|
// modification, are permitted provided that the following conditions are
|
||||||
|
// met:
|
||||||
|
// * Redistributions of source code must retain the above copyright
|
||||||
|
// notice, this list of conditions and the following disclaimer.
|
||||||
|
// * Redistributions in binary form must reproduce the above
|
||||||
|
// copyright notice, this list of conditions and the following disclaimer
|
||||||
|
// in the documentation and/or other materials provided with the
|
||||||
|
// distribution.
|
||||||
|
// * Neither the name of Weta Digital nor the names of
|
||||||
|
// its contributors may be used to endorse or promote products derived
|
||||||
|
// from this software without specific prior written permission.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
//
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef INCLUDED_IMF_COMPOSITEDEEPSCANLINE_H |
||||||
|
#define INCLUDED_IMF_COMPOSITEDEEPSCANLINE_H |
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Class to composite deep samples into a frame buffer
|
||||||
|
// Initialise with a deep input part or deep inputfile
|
||||||
|
// (also supports multiple files and parts, and will
|
||||||
|
// composite them together, as long as their sizes and channelmaps agree)
|
||||||
|
//
|
||||||
|
// Then call setFrameBuffer, and readPixels, exactly as for reading
|
||||||
|
// regular scanline images.
|
||||||
|
//
|
||||||
|
// Restrictions - source file(s) must contain at least Z and alpha channels
|
||||||
|
// - if multiple files/parts are provided, sizes must match
|
||||||
|
// - all requested channels will be composited as premultiplied
|
||||||
|
// - only half and float channels can be requested
|
||||||
|
//
|
||||||
|
// This object should not be considered threadsafe
|
||||||
|
//
|
||||||
|
// The default compositing engine will give spurious results with overlapping
|
||||||
|
// volumetric samples - you may derive from DeepCompositing class, override the
|
||||||
|
// sort_pixel() and composite_pixel() functions, and pass an instance to
|
||||||
|
// setCompositing().
|
||||||
|
//
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#include "ImfForward.h" |
||||||
|
#include "ImfNamespace.h" |
||||||
|
#include "ImfExport.h" |
||||||
|
#include <ImathBox.h> |
||||||
|
|
||||||
|
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER |
||||||
|
|
||||||
|
class CompositeDeepScanLine |
||||||
|
{ |
||||||
|
public: |
||||||
|
IMF_EXPORT |
||||||
|
CompositeDeepScanLine(); |
||||||
|
IMF_EXPORT |
||||||
|
virtual ~CompositeDeepScanLine(); |
||||||
|
|
||||||
|
/// set the source data as a part
|
||||||
|
///@note all parts must remain valid until after last interaction with DeepComp
|
||||||
|
IMF_EXPORT |
||||||
|
void addSource(DeepScanLineInputPart * part); |
||||||
|
|
||||||
|
/// set the source data as a file
|
||||||
|
///@note all file must remain valid until after last interaction with DeepComp
|
||||||
|
IMF_EXPORT |
||||||
|
void addSource(DeepScanLineInputFile * file); |
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// set the frame buffer for output values
|
||||||
|
// the buffers specified must be large enough
|
||||||
|
// to handle the dataWindow()
|
||||||
|
//
|
||||||
|
/////////////////////////////////////////
|
||||||
|
IMF_EXPORT |
||||||
|
void setFrameBuffer(const FrameBuffer & fr); |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// retrieve frameBuffer
|
||||||
|
//
|
||||||
|
////////////////////////////////////////
|
||||||
|
IMF_EXPORT |
||||||
|
const FrameBuffer & frameBuffer() const; |
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// read scanlines start to end from the source(s)
|
||||||
|
// storing the result in the frame buffer provided
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////////
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
void readPixels(int start,int end); |
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
int sources() const; // return number of sources
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// retrieve the datawindow
|
||||||
|
// If multiple parts are specified, this will
|
||||||
|
// be the union of the dataWindow of all parts
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
const IMATH_NAMESPACE::Box2i & dataWindow() const; |
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// override default sorting/compositing operation
|
||||||
|
// (otherwise an instance of the base class will be used)
|
||||||
|
//
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
void setCompositing(DeepCompositing *); |
||||||
|
|
||||||
|
struct Data;
|
||||||
|
private :
|
||||||
|
struct Data *_Data; |
||||||
|
|
||||||
|
CompositeDeepScanLine(const CompositeDeepScanLine &); // not implemented
|
||||||
|
const CompositeDeepScanLine & operator=(const CompositeDeepScanLine &); // not implemented
|
||||||
|
}; |
||||||
|
|
||||||
|
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT |
||||||
|
|
||||||
|
#endif |
@ -0,0 +1,110 @@ |
|||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Copyright (c) 2012, Weta Digital Ltd
|
||||||
|
//
|
||||||
|
// All rights reserved.
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without
|
||||||
|
// modification, are permitted provided that the following conditions are
|
||||||
|
// met:
|
||||||
|
// * Redistributions of source code must retain the above copyright
|
||||||
|
// notice, this list of conditions and the following disclaimer.
|
||||||
|
// * Redistributions in binary form must reproduce the above
|
||||||
|
// copyright notice, this list of conditions and the following disclaimer
|
||||||
|
// in the documentation and/or other materials provided with the
|
||||||
|
// distribution.
|
||||||
|
// * Neither the name of Weta Digital nor the names of
|
||||||
|
// its contributors may be used to endorse or promote products derived
|
||||||
|
// from this software without specific prior written permission.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
//
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include "ImfDeepCompositing.h" |
||||||
|
|
||||||
|
#include "ImfNamespace.h" |
||||||
|
#include <algorithm> |
||||||
|
#include <vector> |
||||||
|
|
||||||
|
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_ENTER |
||||||
|
|
||||||
|
using std::sort; |
||||||
|
using std::vector; |
||||||
|
DeepCompositing::DeepCompositing() |
||||||
|
{ |
||||||
|
} |
||||||
|
|
||||||
|
DeepCompositing::~DeepCompositing() |
||||||
|
{ |
||||||
|
} |
||||||
|
|
||||||
|
void
|
||||||
|
DeepCompositing::composite_pixel (float outputs[], |
||||||
|
const float* inputs[], |
||||||
|
const char*channel_names[], |
||||||
|
int num_channels, |
||||||
|
int num_samples, |
||||||
|
int sources) |
||||||
|
{ |
||||||
|
for(int i=0;i<num_channels;i++) outputs[i]=0.0; |
||||||
|
// no samples? do nothing
|
||||||
|
if(num_samples==0) |
||||||
|
{ |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
vector<int> sort_order; |
||||||
|
if(sources>1) |
||||||
|
{ |
||||||
|
sort_order.resize(num_samples); |
||||||
|
for(int i=0;i<num_samples;i++) sort_order[i]=i; |
||||||
|
sort(&sort_order[0],inputs,channel_names,num_channels,num_samples,sources); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
for(int i=0;i<num_samples;i++) |
||||||
|
{ |
||||||
|
int s=(sources>1) ? sort_order[i] : i; |
||||||
|
float alpha=outputs[2];
|
||||||
|
if(alpha>=1.0) return; |
||||||
|
|
||||||
|
for(int c=0;c<num_channels;c++) |
||||||
|
{ |
||||||
|
outputs[c]+=(1.0-alpha)*inputs[c][s]; |
||||||
|
} |
||||||
|
}
|
||||||
|
} |
||||||
|
|
||||||
|
struct sort_helper |
||||||
|
{ |
||||||
|
const float ** inputs; |
||||||
|
bool operator() (int a,int b)
|
||||||
|
{ |
||||||
|
if(inputs[0][a] < inputs[0][b]) return true; |
||||||
|
if(inputs[0][a] > inputs[0][b]) return false; |
||||||
|
if(inputs[1][a] < inputs[1][b]) return true; |
||||||
|
if(inputs[1][a] > inputs[1][b]) return false; |
||||||
|
return a<b; |
||||||
|
} |
||||||
|
sort_helper(const float ** i) : inputs(i) {} |
||||||
|
}; |
||||||
|
|
||||||
|
void |
||||||
|
DeepCompositing::sort(int order[], const float* inputs[], const char* channel_names[], int num_channels, int num_samples, int sources) |
||||||
|
{ |
||||||
|
std::sort(order+0,order+num_samples,sort_helper(inputs)); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_EXIT |
@ -0,0 +1,136 @@ |
|||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Copyright (c) 2012, Weta Digital Ltd
|
||||||
|
//
|
||||||
|
// All rights reserved.
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without
|
||||||
|
// modification, are permitted provided that the following conditions are
|
||||||
|
// met:
|
||||||
|
// * Redistributions of source code must retain the above copyright
|
||||||
|
// notice, this list of conditions and the following disclaimer.
|
||||||
|
// * Redistributions in binary form must reproduce the above
|
||||||
|
// copyright notice, this list of conditions and the following disclaimer
|
||||||
|
// in the documentation and/or other materials provided with the
|
||||||
|
// distribution.
|
||||||
|
// * Neither the name of Weta Digital nor the names of
|
||||||
|
// its contributors may be used to endorse or promote products derived
|
||||||
|
// from this software without specific prior written permission.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
//
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef INCLUDED_IMF_DEEPCOMPOSITING_H |
||||||
|
#define INCLUDED_IMF_DEEPCOMPOSITING_H |
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Class to sort and composite deep samples into a frame buffer
|
||||||
|
// You may derive from this class to change the way that CompositeDeepScanLine
|
||||||
|
// and CompositeDeepTile combine samples together - pass an instance of your derived
|
||||||
|
// class to the compositing engine
|
||||||
|
//
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#include "ImfForward.h" |
||||||
|
#include "ImfNamespace.h" |
||||||
|
#include "ImfExport.h" |
||||||
|
|
||||||
|
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER |
||||||
|
|
||||||
|
class DeepCompositing |
||||||
|
{ |
||||||
|
public: |
||||||
|
IMF_EXPORT |
||||||
|
DeepCompositing(); |
||||||
|
IMF_EXPORT |
||||||
|
virtual ~DeepCompositing(); |
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////////////
|
||||||
|
///
|
||||||
|
/// composite together the given channels
|
||||||
|
///
|
||||||
|
/// @param outputs - return array of pixel values -
|
||||||
|
/// @param inputs - arrays of input sample
|
||||||
|
/// @param channel_names - array of channel names for corresponding channels
|
||||||
|
/// @param num_channels - number of active channels (3 or greater)
|
||||||
|
/// @param num_samples - number of values in all input arrays
|
||||||
|
/// @param sources - number of different sources
|
||||||
|
///
|
||||||
|
/// each array input has num_channels entries: outputs[n] should be the composited
|
||||||
|
/// values in array inputs[n], whose name will be given by channel_names[n]
|
||||||
|
///
|
||||||
|
/// The channel ordering shall be as follows:
|
||||||
|
/// Position Channel
|
||||||
|
/// 0 Z
|
||||||
|
/// 1 ZBack (if no ZBack, then inputs[1]==inputs[0] and channel_names[1]==channel_names[0])
|
||||||
|
/// 2 A (alpha channel)
|
||||||
|
/// 3-n other channels - only channels in the frame buffer will appear here
|
||||||
|
///
|
||||||
|
/// since a Z and Alpha channel is required, and channel[1] is ZBack or another copy of Z
|
||||||
|
/// there will always be 3 or more channels.
|
||||||
|
///
|
||||||
|
/// The default implementation calls sort() if and only if more than one source is active,
|
||||||
|
/// composites all samples together using the Over operator from front to back,
|
||||||
|
/// stopping as soon as a sample with alpha=1 is found
|
||||||
|
/// It also blanks all outputs if num_samples==0
|
||||||
|
///
|
||||||
|
/// note - multiple threads may call composite_pixel simultaneously for different pixels
|
||||||
|
///
|
||||||
|
///
|
||||||
|
//////////////////////////////////////////////
|
||||||
|
IMF_EXPORT |
||||||
|
virtual void composite_pixel(float outputs[], |
||||||
|
const float * inputs[], |
||||||
|
const char * channel_names[], |
||||||
|
int num_channels, |
||||||
|
int num_samples, |
||||||
|
int sources |
||||||
|
); |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////
|
||||||
|
///
|
||||||
|
/// find the depth order for samples with given channel values
|
||||||
|
/// does not sort the values in-place. Instead it populates
|
||||||
|
/// array 'order' with the desired sorting order
|
||||||
|
///
|
||||||
|
/// the default operation sorts samples from front to back according to their Z channel
|
||||||
|
///
|
||||||
|
/// @param order - required output order. order[n] shall be the nth closest sample
|
||||||
|
/// @param inputs - arrays of input samples, one array per channel_name
|
||||||
|
/// @param channel_names - array of channel names for corresponding channels
|
||||||
|
/// @param num_channels - number of channels (3 or greater)
|
||||||
|
/// @param num_samples - number of samples in each array
|
||||||
|
/// @param sources - number of different sources the data arises from
|
||||||
|
///
|
||||||
|
/// the channel layout is identical to composite_pixel()
|
||||||
|
///
|
||||||
|
///////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
virtual void sort(int order[], |
||||||
|
const float * inputs[], |
||||||
|
const char * channel_names[], |
||||||
|
int num_channels, |
||||||
|
int num_samples, |
||||||
|
int sources); |
||||||
|
}; |
||||||
|
|
||||||
|
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT |
||||||
|
|
||||||
|
#endif |
@ -0,0 +1,230 @@ |
|||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Copyright (c) 2011, Industrial Light & Magic, a division of Lucas
|
||||||
|
// Digital Ltd. LLC
|
||||||
|
//
|
||||||
|
// All rights reserved.
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without
|
||||||
|
// modification, are permitted provided that the following conditions are
|
||||||
|
// met:
|
||||||
|
// * Redistributions of source code must retain the above copyright
|
||||||
|
// notice, this list of conditions and the following disclaimer.
|
||||||
|
// * Redistributions in binary form must reproduce the above
|
||||||
|
// copyright notice, this list of conditions and the following disclaimer
|
||||||
|
// in the documentation and/or other materials provided with the
|
||||||
|
// distribution.
|
||||||
|
// * Neither the name of Industrial Light & Magic nor the names of
|
||||||
|
// its contributors may be used to endorse or promote products derived
|
||||||
|
// from this software without specific prior written permission.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
//
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include "ImfDeepFrameBuffer.h" |
||||||
|
#include "Iex.h" |
||||||
|
|
||||||
|
|
||||||
|
using namespace std; |
||||||
|
#include "ImfNamespace.h" |
||||||
|
|
||||||
|
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_ENTER |
||||||
|
|
||||||
|
DeepSlice::DeepSlice (PixelType t, |
||||||
|
char *b, |
||||||
|
size_t xst, |
||||||
|
size_t yst, |
||||||
|
size_t spst, |
||||||
|
int xsm, |
||||||
|
int ysm, |
||||||
|
double fv, |
||||||
|
bool xtc, |
||||||
|
bool ytc) |
||||||
|
: |
||||||
|
Slice (t, b, xst, yst, xsm, ysm, fv, xtc, ytc), |
||||||
|
sampleStride (spst) |
||||||
|
{ |
||||||
|
// empty
|
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
void |
||||||
|
DeepFrameBuffer::insert (const char name[], const DeepSlice &slice) |
||||||
|
{ |
||||||
|
if (name[0] == 0) |
||||||
|
{ |
||||||
|
THROW (IEX_NAMESPACE::ArgExc, |
||||||
|
"Frame buffer slice name cannot be an empty string."); |
||||||
|
} |
||||||
|
|
||||||
|
_map[name] = slice; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
void |
||||||
|
DeepFrameBuffer::insert (const string &name, const DeepSlice &slice) |
||||||
|
{ |
||||||
|
insert (name.c_str(), slice); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
DeepSlice & |
||||||
|
DeepFrameBuffer::operator [] (const char name[]) |
||||||
|
{ |
||||||
|
SliceMap::iterator i = _map.find (name); |
||||||
|
|
||||||
|
if (i == _map.end()) |
||||||
|
{ |
||||||
|
THROW (IEX_NAMESPACE::ArgExc, |
||||||
|
"Cannot find frame buffer slice \"" << name << "\"."); |
||||||
|
} |
||||||
|
|
||||||
|
return i->second; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
const DeepSlice & |
||||||
|
DeepFrameBuffer::operator [] (const char name[]) const |
||||||
|
{ |
||||||
|
SliceMap::const_iterator i = _map.find (name); |
||||||
|
|
||||||
|
if (i == _map.end()) |
||||||
|
{ |
||||||
|
THROW (IEX_NAMESPACE::ArgExc, |
||||||
|
"Cannot find frame buffer slice \"" << name << "\"."); |
||||||
|
} |
||||||
|
|
||||||
|
return i->second; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
DeepSlice & |
||||||
|
DeepFrameBuffer::operator [] (const string &name) |
||||||
|
{ |
||||||
|
return this->operator[] (name.c_str()); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
const DeepSlice & |
||||||
|
DeepFrameBuffer::operator [] (const string &name) const |
||||||
|
{ |
||||||
|
return this->operator[] (name.c_str()); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
DeepSlice * |
||||||
|
DeepFrameBuffer::findSlice (const char name[]) |
||||||
|
{ |
||||||
|
SliceMap::iterator i = _map.find (name); |
||||||
|
return (i == _map.end())? 0: &i->second; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
const DeepSlice * |
||||||
|
DeepFrameBuffer::findSlice (const char name[]) const |
||||||
|
{ |
||||||
|
SliceMap::const_iterator i = _map.find (name); |
||||||
|
return (i == _map.end())? 0: &i->second; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
DeepSlice * |
||||||
|
DeepFrameBuffer::findSlice (const string &name) |
||||||
|
{ |
||||||
|
return findSlice (name.c_str()); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
const DeepSlice * |
||||||
|
DeepFrameBuffer::findSlice (const string &name) const |
||||||
|
{ |
||||||
|
return findSlice (name.c_str()); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
DeepFrameBuffer::Iterator |
||||||
|
DeepFrameBuffer::begin () |
||||||
|
{ |
||||||
|
return _map.begin(); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
DeepFrameBuffer::ConstIterator |
||||||
|
DeepFrameBuffer::begin () const |
||||||
|
{ |
||||||
|
return _map.begin(); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
DeepFrameBuffer::Iterator |
||||||
|
DeepFrameBuffer::end () |
||||||
|
{ |
||||||
|
return _map.end(); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
DeepFrameBuffer::ConstIterator |
||||||
|
DeepFrameBuffer::end () const |
||||||
|
{ |
||||||
|
return _map.end(); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
DeepFrameBuffer::Iterator |
||||||
|
DeepFrameBuffer::find (const char name[]) |
||||||
|
{ |
||||||
|
return _map.find (name); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
DeepFrameBuffer::ConstIterator |
||||||
|
DeepFrameBuffer::find (const char name[]) const |
||||||
|
{ |
||||||
|
return _map.find (name); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
DeepFrameBuffer::Iterator |
||||||
|
DeepFrameBuffer::find (const string &name) |
||||||
|
{ |
||||||
|
return find (name.c_str()); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
DeepFrameBuffer::ConstIterator |
||||||
|
DeepFrameBuffer::find (const string &name) const |
||||||
|
{ |
||||||
|
return find (name.c_str()); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
void |
||||||
|
DeepFrameBuffer::insertSampleCountSlice(const Slice & slice) |
||||||
|
{ |
||||||
|
if (slice.type != UINT) |
||||||
|
{ |
||||||
|
throw IEX_NAMESPACE::ArgExc("The type of sample count slice should be UINT."); |
||||||
|
} |
||||||
|
|
||||||
|
_sampleCounts = slice; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
const Slice & |
||||||
|
DeepFrameBuffer::getSampleCountSlice() const |
||||||
|
{ |
||||||
|
return _sampleCounts; |
||||||
|
} |
||||||
|
|
||||||
|
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_EXIT |
@ -0,0 +1,373 @@ |
|||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Copyright (c) 2011, Industrial Light & Magic, a division of Lucas
|
||||||
|
// Digital Ltd. LLC
|
||||||
|
//
|
||||||
|
// All rights reserved.
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without
|
||||||
|
// modification, are permitted provided that the following conditions are
|
||||||
|
// met:
|
||||||
|
// * Redistributions of source code must retain the above copyright
|
||||||
|
// notice, this list of conditions and the following disclaimer.
|
||||||
|
// * Redistributions in binary form must reproduce the above
|
||||||
|
// copyright notice, this list of conditions and the following disclaimer
|
||||||
|
// in the documentation and/or other materials provided with the
|
||||||
|
// distribution.
|
||||||
|
// * Neither the name of Industrial Light & Magic nor the names of
|
||||||
|
// its contributors may be used to endorse or promote products derived
|
||||||
|
// from this software without specific prior written permission.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
//
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifndef IMFDEEPFRAMEBUFFER_H_ |
||||||
|
#define IMFDEEPFRAMEBUFFER_H_ |
||||||
|
|
||||||
|
#include "ImfFrameBuffer.h" |
||||||
|
#include "ImfNamespace.h" |
||||||
|
#include "ImfExport.h" |
||||||
|
|
||||||
|
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER |
||||||
|
|
||||||
|
//--------------------------------------------------------
|
||||||
|
// Description of a single deep slice of the frame buffer:
|
||||||
|
//--------------------------------------------------------
|
||||||
|
|
||||||
|
struct DeepSlice : public Slice |
||||||
|
{ |
||||||
|
//---------------------------------------------------------------------
|
||||||
|
// The stride for each sample in this slice.
|
||||||
|
//
|
||||||
|
// Memory layout: The address of sample i in pixel (x, y) is
|
||||||
|
//
|
||||||
|
// base + (xp / xSampling) * xStride + (yp / ySampling) * yStride
|
||||||
|
// + i * sampleStride
|
||||||
|
//
|
||||||
|
// where xp and yp are computed as follows:
|
||||||
|
//
|
||||||
|
// * If we are reading or writing a scanline-based file:
|
||||||
|
//
|
||||||
|
// xp = x
|
||||||
|
// yp = y
|
||||||
|
//
|
||||||
|
// * If we are reading a tile whose upper left coorner is at (xt, yt):
|
||||||
|
//
|
||||||
|
// if xTileCoords is true then xp = x - xt, else xp = x
|
||||||
|
// if yTileCoords is true then yp = y - yt, else yp = y
|
||||||
|
//
|
||||||
|
//---------------------------------------------------------------------
|
||||||
|
|
||||||
|
int sampleStride; |
||||||
|
|
||||||
|
//------------
|
||||||
|
// Constructor
|
||||||
|
//------------
|
||||||
|
IMF_EXPORT |
||||||
|
DeepSlice (PixelType type = HALF, |
||||||
|
char * base = 0, |
||||||
|
size_t xStride = 0, |
||||||
|
size_t yStride = 0, |
||||||
|
size_t sampleStride = 0, |
||||||
|
int xSampling = 1, |
||||||
|
int ySampling = 1, |
||||||
|
double fillValue = 0.0, |
||||||
|
bool xTileCoords = false, |
||||||
|
bool yTileCoords = false); |
||||||
|
}; |
||||||
|
|
||||||
|
//-----------------
|
||||||
|
// DeepFrameBuffer.
|
||||||
|
//-----------------
|
||||||
|
|
||||||
|
class DeepFrameBuffer |
||||||
|
{ |
||||||
|
public: |
||||||
|
|
||||||
|
|
||||||
|
//------------
|
||||||
|
// Add a slice
|
||||||
|
//------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
void insert (const char name[], |
||||||
|
const DeepSlice &slice); |
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
void insert (const std::string &name, |
||||||
|
const DeepSlice &slice); |
||||||
|
|
||||||
|
//----------------------------------------------------------------
|
||||||
|
// Access to existing slices:
|
||||||
|
//
|
||||||
|
// [n] Returns a reference to the slice with name n.
|
||||||
|
// If no slice with name n exists, an IEX_NAMESPACE::ArgExc
|
||||||
|
// is thrown.
|
||||||
|
//
|
||||||
|
// findSlice(n) Returns a pointer to the slice with name n,
|
||||||
|
// or 0 if no slice with name n exists.
|
||||||
|
//
|
||||||
|
//----------------------------------------------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
DeepSlice & operator [] (const char name[]); |
||||||
|
IMF_EXPORT |
||||||
|
const DeepSlice & operator [] (const char name[]) const; |
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
DeepSlice & operator [] (const std::string &name); |
||||||
|
IMF_EXPORT |
||||||
|
const DeepSlice & operator [] (const std::string &name) const; |
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
DeepSlice * findSlice (const char name[]); |
||||||
|
IMF_EXPORT |
||||||
|
const DeepSlice * findSlice (const char name[]) const; |
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
DeepSlice * findSlice (const std::string &name); |
||||||
|
IMF_EXPORT |
||||||
|
const DeepSlice * findSlice (const std::string &name) const; |
||||||
|
|
||||||
|
|
||||||
|
//-----------------------------------------
|
||||||
|
// Iterator-style access to existing slices
|
||||||
|
//-----------------------------------------
|
||||||
|
|
||||||
|
typedef std::map <Name, DeepSlice> SliceMap; |
||||||
|
|
||||||
|
class Iterator; |
||||||
|
class ConstIterator; |
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
Iterator begin (); |
||||||
|
IMF_EXPORT |
||||||
|
ConstIterator begin () const; |
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
Iterator end (); |
||||||
|
IMF_EXPORT |
||||||
|
ConstIterator end () const; |
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
Iterator find (const char name[]); |
||||||
|
IMF_EXPORT |
||||||
|
ConstIterator find (const char name[]) const; |
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
Iterator find (const std::string &name); |
||||||
|
IMF_EXPORT |
||||||
|
ConstIterator find (const std::string &name) const; |
||||||
|
|
||||||
|
//----------------------------------------------------
|
||||||
|
// Public function for accessing a sample count slice.
|
||||||
|
//----------------------------------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
void insertSampleCountSlice(const Slice & slice); |
||||||
|
IMF_EXPORT |
||||||
|
const Slice & getSampleCountSlice() const; |
||||||
|
|
||||||
|
private: |
||||||
|
|
||||||
|
SliceMap _map; |
||||||
|
Slice _sampleCounts; |
||||||
|
}; |
||||||
|
|
||||||
|
//----------
|
||||||
|
// Iterators
|
||||||
|
//----------
|
||||||
|
|
||||||
|
class DeepFrameBuffer::Iterator |
||||||
|
{ |
||||||
|
public: |
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
Iterator (); |
||||||
|
IMF_EXPORT |
||||||
|
Iterator (const DeepFrameBuffer::SliceMap::iterator &i); |
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
Iterator & operator ++ (); |
||||||
|
IMF_EXPORT |
||||||
|
Iterator operator ++ (int); |
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
const char * name () const; |
||||||
|
IMF_EXPORT |
||||||
|
DeepSlice & slice () const; |
||||||
|
|
||||||
|
private: |
||||||
|
|
||||||
|
friend class DeepFrameBuffer::ConstIterator; |
||||||
|
|
||||||
|
DeepFrameBuffer::SliceMap::iterator _i; |
||||||
|
}; |
||||||
|
|
||||||
|
|
||||||
|
class DeepFrameBuffer::ConstIterator |
||||||
|
{ |
||||||
|
public: |
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
ConstIterator (); |
||||||
|
IMF_EXPORT |
||||||
|
ConstIterator (const DeepFrameBuffer::SliceMap::const_iterator &i); |
||||||
|
IMF_EXPORT |
||||||
|
ConstIterator (const DeepFrameBuffer::Iterator &other); |
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
ConstIterator & operator ++ (); |
||||||
|
IMF_EXPORT |
||||||
|
ConstIterator operator ++ (int); |
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
const char * name () const; |
||||||
|
IMF_EXPORT |
||||||
|
const DeepSlice & slice () const; |
||||||
|
|
||||||
|
private: |
||||||
|
|
||||||
|
friend bool operator == (const ConstIterator &, const ConstIterator &); |
||||||
|
friend bool operator != (const ConstIterator &, const ConstIterator &); |
||||||
|
|
||||||
|
DeepFrameBuffer::SliceMap::const_iterator _i; |
||||||
|
}; |
||||||
|
|
||||||
|
|
||||||
|
//-----------------
|
||||||
|
// Inline Functions
|
||||||
|
//-----------------
|
||||||
|
|
||||||
|
inline |
||||||
|
DeepFrameBuffer::Iterator::Iterator (): _i() |
||||||
|
{ |
||||||
|
// empty
|
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
inline |
||||||
|
DeepFrameBuffer::Iterator::Iterator (const DeepFrameBuffer::SliceMap::iterator &i): |
||||||
|
_i (i) |
||||||
|
{ |
||||||
|
// empty
|
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
inline DeepFrameBuffer::Iterator & |
||||||
|
DeepFrameBuffer::Iterator::operator ++ () |
||||||
|
{ |
||||||
|
++_i; |
||||||
|
return *this; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
inline DeepFrameBuffer::Iterator |
||||||
|
DeepFrameBuffer::Iterator::operator ++ (int) |
||||||
|
{ |
||||||
|
Iterator tmp = *this; |
||||||
|
++_i; |
||||||
|
return tmp; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
inline const char * |
||||||
|
DeepFrameBuffer::Iterator::name () const |
||||||
|
{ |
||||||
|
return *_i->first; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
inline DeepSlice & |
||||||
|
DeepFrameBuffer::Iterator::slice () const |
||||||
|
{ |
||||||
|
return _i->second; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
inline |
||||||
|
DeepFrameBuffer::ConstIterator::ConstIterator (): _i() |
||||||
|
{ |
||||||
|
// empty
|
||||||
|
} |
||||||
|
|
||||||
|
inline |
||||||
|
DeepFrameBuffer::ConstIterator::ConstIterator |
||||||
|
(const DeepFrameBuffer::SliceMap::const_iterator &i): _i (i) |
||||||
|
{ |
||||||
|
// empty
|
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
inline |
||||||
|
DeepFrameBuffer::ConstIterator::ConstIterator (const DeepFrameBuffer::Iterator &other): |
||||||
|
_i (other._i) |
||||||
|
{ |
||||||
|
// empty
|
||||||
|
} |
||||||
|
|
||||||
|
inline DeepFrameBuffer::ConstIterator & |
||||||
|
DeepFrameBuffer::ConstIterator::operator ++ () |
||||||
|
{ |
||||||
|
++_i; |
||||||
|
return *this; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
inline DeepFrameBuffer::ConstIterator |
||||||
|
DeepFrameBuffer::ConstIterator::operator ++ (int) |
||||||
|
{ |
||||||
|
ConstIterator tmp = *this; |
||||||
|
++_i; |
||||||
|
return tmp; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
inline const char * |
||||||
|
DeepFrameBuffer::ConstIterator::name () const |
||||||
|
{ |
||||||
|
return *_i->first; |
||||||
|
} |
||||||
|
|
||||||
|
inline const DeepSlice & |
||||||
|
DeepFrameBuffer::ConstIterator::slice () const |
||||||
|
{ |
||||||
|
return _i->second; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
inline bool |
||||||
|
operator == (const DeepFrameBuffer::ConstIterator &x, |
||||||
|
const DeepFrameBuffer::ConstIterator &y) |
||||||
|
{ |
||||||
|
return x._i == y._i; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
inline bool |
||||||
|
operator != (const DeepFrameBuffer::ConstIterator &x, |
||||||
|
const DeepFrameBuffer::ConstIterator &y) |
||||||
|
{ |
||||||
|
return !(x == y); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* IMFDEEPFRAMEBUFFER_H_ */ |
@ -0,0 +1,96 @@ |
|||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Copyright (c) 2013, Industrial Light & Magic, a division of Lucas
|
||||||
|
// Digital Ltd. LLC
|
||||||
|
//
|
||||||
|
// All rights reserved.
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without
|
||||||
|
// modification, are permitted provided that the following conditions are
|
||||||
|
// met:
|
||||||
|
// * Redistributions of source code must retain the above copyright
|
||||||
|
// notice, this list of conditions and the following disclaimer.
|
||||||
|
// * Redistributions in binary form must reproduce the above
|
||||||
|
// copyright notice, this list of conditions and the following disclaimer
|
||||||
|
// in the documentation and/or other materials provided with the
|
||||||
|
// distribution.
|
||||||
|
// * Neither the name of Industrial Light & Magic nor the names of
|
||||||
|
// its contributors may be used to endorse or promote products derived
|
||||||
|
// from this software without specific prior written permission.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
//
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef INCLUDED_IMF_DEEPIMAGESTATE_H |
||||||
|
#define INCLUDED_IMF_DEEPIMAGESTATE_H |
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// enum DeepImageState -- describes how orderly the pixel data
|
||||||
|
// in a deep image are
|
||||||
|
//
|
||||||
|
// The samples in a deep image pixel may be sorted according to
|
||||||
|
// depth, and the sample depths or depth ranges may or may not
|
||||||
|
// overlap each other. A pixel is
|
||||||
|
//
|
||||||
|
// - SORTED if for every i and j with i < j
|
||||||
|
//
|
||||||
|
// (Z[i] < Z[j]) || (Z[i] == Z[j] && ZBack[i] < ZBack[j]),
|
||||||
|
//
|
||||||
|
// - NON_OVERLAPPING if for every i and j with i != j
|
||||||
|
//
|
||||||
|
// (Z[i] < Z[j] && ZBack[i] <= Z[j]) ||
|
||||||
|
// (Z[j] < Z[i] && ZBack[j] <= Z[i]) ||
|
||||||
|
// (Z[i] == Z[j] && ZBack[i] <= Z[i] & ZBack[j] > Z[j]) ||
|
||||||
|
// (Z[i] == Z[j] && ZBack[j] <= Z[j] & ZBack[i] > Z[i]),
|
||||||
|
//
|
||||||
|
// - TIDY if it is SORTED and NON_OVERLAPPING,
|
||||||
|
//
|
||||||
|
// - MESSY if it is neither SORTED nor NON_OVERLAPPING.
|
||||||
|
//
|
||||||
|
// A deep image is
|
||||||
|
//
|
||||||
|
// - MESSY if at least one of its pixels is MESSY,
|
||||||
|
// - SORTED if all of its pixels are SORTED,
|
||||||
|
// - NON_OVERLAPPING if all of its pixels are NON_OVERLAPPING,
|
||||||
|
// - TIDY if all of its pixels are TIDY.
|
||||||
|
//
|
||||||
|
// Note: the rather complicated definition of NON_OVERLAPPING prohibits
|
||||||
|
// overlapping volume samples, coincident point samples and point samples
|
||||||
|
// in the middle of a volume sample, but it does allow point samples at
|
||||||
|
// the front or back of a volume sample.
|
||||||
|
//
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#include "ImfNamespace.h" |
||||||
|
#include "ImfExport.h" |
||||||
|
|
||||||
|
|
||||||
|
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER |
||||||
|
|
||||||
|
enum DeepImageState |
||||||
|
{ |
||||||
|
DIS_MESSY = 0, |
||||||
|
DIS_SORTED = 1, |
||||||
|
DIS_NON_OVERLAPPING = 2, |
||||||
|
DIS_TIDY = 3, |
||||||
|
|
||||||
|
DIS_NUMSTATES // Number of different image states
|
||||||
|
}; |
||||||
|
|
||||||
|
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT |
||||||
|
|
||||||
|
|
||||||
|
#endif |
@ -0,0 +1,78 @@ |
|||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Copyright (c) 2013, Industrial Light & Magic, a division of Lucas
|
||||||
|
// Digital Ltd. LLC
|
||||||
|
//
|
||||||
|
// All rights reserved.
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without
|
||||||
|
// modification, are permitted provided that the following conditions are
|
||||||
|
// met:
|
||||||
|
// * Redistributions of source code must retain the above copyright
|
||||||
|
// notice, this list of conditions and the following disclaimer.
|
||||||
|
// * Redistributions in binary form must reproduce the above
|
||||||
|
// copyright notice, this list of conditions and the following disclaimer
|
||||||
|
// in the documentation and/or other materials provided with the
|
||||||
|
// distribution.
|
||||||
|
// * Neither the name of Industrial Light & Magic nor the names of
|
||||||
|
// its contributors may be used to endorse or promote products derived
|
||||||
|
// from this software without specific prior written permission.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
//
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// class DeepImageStateAttribute
|
||||||
|
//
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#include <ImfDeepImageStateAttribute.h> |
||||||
|
|
||||||
|
|
||||||
|
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_ENTER |
||||||
|
|
||||||
|
using namespace OPENEXR_IMF_INTERNAL_NAMESPACE; |
||||||
|
|
||||||
|
template <> |
||||||
|
const char * |
||||||
|
DeepImageStateAttribute::staticTypeName () |
||||||
|
{ |
||||||
|
return "deepImageState"; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
template <> |
||||||
|
void |
||||||
|
DeepImageStateAttribute::writeValueTo |
||||||
|
(OPENEXR_IMF_INTERNAL_NAMESPACE::OStream &os, int version) const |
||||||
|
{ |
||||||
|
unsigned char tmp = _value; |
||||||
|
Xdr::write <StreamIO> (os, tmp); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
template <> |
||||||
|
void |
||||||
|
DeepImageStateAttribute::readValueFrom |
||||||
|
(OPENEXR_IMF_INTERNAL_NAMESPACE::IStream &is, int size, int version) |
||||||
|
{ |
||||||
|
unsigned char tmp; |
||||||
|
Xdr::read <StreamIO> (is, tmp); |
||||||
|
_value = DeepImageState (tmp); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_EXIT
|
@ -0,0 +1,68 @@ |
|||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Copyright (c) 2013, Industrial Light & Magic, a division of Lucas
|
||||||
|
// Digital Ltd. LLC
|
||||||
|
//
|
||||||
|
// All rights reserved.
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without
|
||||||
|
// modification, are permitted provided that the following conditions are
|
||||||
|
// met:
|
||||||
|
// * Redistributions of source code must retain the above copyright
|
||||||
|
// notice, this list of conditions and the following disclaimer.
|
||||||
|
// * Redistributions in binary form must reproduce the above
|
||||||
|
// copyright notice, this list of conditions and the following disclaimer
|
||||||
|
// in the documentation and/or other materials provided with the
|
||||||
|
// distribution.
|
||||||
|
// * Neither the name of Industrial Light & Magic nor the names of
|
||||||
|
// its contributors may be used to endorse or promote products derived
|
||||||
|
// from this software without specific prior written permission.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
//
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifndef INCLUDED_IMF_DEEPIMAGESTATE_ATTRIBUTE_H |
||||||
|
#define INCLUDED_IMF_DEEPIMAGESTATE_ATTRIBUTE_H |
||||||
|
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// class DeepImageStateAttribute
|
||||||
|
//
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#include "ImfAttribute.h" |
||||||
|
#include "ImfDeepImageState.h" |
||||||
|
#include "ImfExport.h" |
||||||
|
|
||||||
|
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER |
||||||
|
|
||||||
|
|
||||||
|
typedef TypedAttribute<OPENEXR_IMF_INTERNAL_NAMESPACE::DeepImageState> |
||||||
|
DeepImageStateAttribute; |
||||||
|
|
||||||
|
template <> IMF_EXPORT const char *DeepImageStateAttribute::staticTypeName (); |
||||||
|
|
||||||
|
template <> IMF_EXPORT |
||||||
|
void DeepImageStateAttribute::writeValueTo |
||||||
|
(OPENEXR_IMF_INTERNAL_NAMESPACE::OStream &, int) const; |
||||||
|
|
||||||
|
template <> IMF_EXPORT |
||||||
|
void DeepImageStateAttribute::readValueFrom |
||||||
|
(OPENEXR_IMF_INTERNAL_NAMESPACE::IStream &, int, int); |
||||||
|
|
||||||
|
|
||||||
|
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT |
||||||
|
|
||||||
|
#endif |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,294 @@ |
|||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Copyright (c) 2011, Industrial Light & Magic, a division of Lucas
|
||||||
|
// Digital Ltd. LLC
|
||||||
|
//
|
||||||
|
// All rights reserved.
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without
|
||||||
|
// modification, are permitted provided that the following conditions are
|
||||||
|
// met:
|
||||||
|
// * Redistributions of source code must retain the above copyright
|
||||||
|
// notice, this list of conditions and the following disclaimer.
|
||||||
|
// * Redistributions in binary form must reproduce the above
|
||||||
|
// copyright notice, this list of conditions and the following disclaimer
|
||||||
|
// in the documentation and/or other materials provided with the
|
||||||
|
// distribution.
|
||||||
|
// * Neither the name of Industrial Light & Magic nor the names of
|
||||||
|
// its contributors may be used to endorse or promote products derived
|
||||||
|
// from this software without specific prior written permission.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
//
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef INCLUDED_IMF_DEEP_SCAN_LINE_INPUT_FILE_H |
||||||
|
#define INCLUDED_IMF_DEEP_SCAN_LINE_INPUT_FILE_H |
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// class DeepScanLineInputFile
|
||||||
|
//
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#include "ImfThreading.h" |
||||||
|
#include "ImfGenericInputFile.h" |
||||||
|
#include "ImfNamespace.h" |
||||||
|
#include "ImfForward.h" |
||||||
|
#include "ImfExport.h" |
||||||
|
#include "ImfDeepScanLineOutputFile.h" |
||||||
|
|
||||||
|
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER |
||||||
|
|
||||||
|
|
||||||
|
class DeepScanLineInputFile : public GenericInputFile |
||||||
|
{ |
||||||
|
public: |
||||||
|
|
||||||
|
//------------
|
||||||
|
// Constructor
|
||||||
|
//------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
DeepScanLineInputFile (const char fileName[], |
||||||
|
int numThreads = globalThreadCount()); |
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
DeepScanLineInputFile (const Header &header, OPENEXR_IMF_INTERNAL_NAMESPACE::IStream *is, |
||||||
|
int version, /*version field from file*/ |
||||||
|
int numThreads = globalThreadCount()); |
||||||
|
|
||||||
|
|
||||||
|
//-----------------------------------------
|
||||||
|
// Destructor -- deallocates internal data
|
||||||
|
// structures, but does not close the file.
|
||||||
|
//-----------------------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
virtual ~DeepScanLineInputFile (); |
||||||
|
|
||||||
|
|
||||||
|
//------------------------
|
||||||
|
// Access to the file name
|
||||||
|
//------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
const char * fileName () const; |
||||||
|
|
||||||
|
|
||||||
|
//--------------------------
|
||||||
|
// Access to the file header
|
||||||
|
//--------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
const Header & header () const; |
||||||
|
|
||||||
|
|
||||||
|
//----------------------------------
|
||||||
|
// Access to the file format version
|
||||||
|
//----------------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
int version () const; |
||||||
|
|
||||||
|
|
||||||
|
//-----------------------------------------------------------
|
||||||
|
// Set the current frame buffer -- copies the FrameBuffer
|
||||||
|
// object into the InputFile object.
|
||||||
|
//
|
||||||
|
// The current frame buffer is the destination for the pixel
|
||||||
|
// data read from the file. The current frame buffer must be
|
||||||
|
// set at least once before readPixels() is called.
|
||||||
|
// The current frame buffer can be changed after each call
|
||||||
|
// to readPixels().
|
||||||
|
//-----------------------------------------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
void setFrameBuffer (const DeepFrameBuffer &frameBuffer); |
||||||
|
|
||||||
|
|
||||||
|
//-----------------------------------
|
||||||
|
// Access to the current frame buffer
|
||||||
|
//-----------------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
const DeepFrameBuffer & frameBuffer () const; |
||||||
|
|
||||||
|
|
||||||
|
//---------------------------------------------------------------
|
||||||
|
// Check if the file is complete:
|
||||||
|
//
|
||||||
|
// isComplete() returns true if all pixels in the data window are
|
||||||
|
// present in the input file, or false if any pixels are missing.
|
||||||
|
// (Another program may still be busy writing the file, or file
|
||||||
|
// writing may have been aborted prematurely.)
|
||||||
|
//---------------------------------------------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
bool isComplete () const; |
||||||
|
|
||||||
|
|
||||||
|
//---------------------------------------------------------------
|
||||||
|
// Read pixel data:
|
||||||
|
//
|
||||||
|
// readPixels(s1,s2) reads all scan lines with y coordinates
|
||||||
|
// in the interval [min (s1, s2), max (s1, s2)] from the file,
|
||||||
|
// and stores them in the current frame buffer.
|
||||||
|
//
|
||||||
|
// Both s1 and s2 must be within the interval
|
||||||
|
// [header().dataWindow().min.y, header.dataWindow().max.y]
|
||||||
|
//
|
||||||
|
// The scan lines can be read from the file in random order, and
|
||||||
|
// individual scan lines may be skipped or read multiple times.
|
||||||
|
// For maximum efficiency, the scan lines should be read in the
|
||||||
|
// order in which they were written to the file.
|
||||||
|
//
|
||||||
|
// readPixels(s) calls readPixels(s,s).
|
||||||
|
//
|
||||||
|
// If threading is enabled, readPixels (s1, s2) tries to perform
|
||||||
|
// decopmression of multiple scanlines in parallel.
|
||||||
|
//
|
||||||
|
//---------------------------------------------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
void readPixels (int scanLine1, int scanLine2); |
||||||
|
IMF_EXPORT |
||||||
|
void readPixels (int scanLine); |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//---------------------------------------------------------------
|
||||||
|
// Extract pixel data from pre-read block
|
||||||
|
//
|
||||||
|
// readPixels(rawPixelData,frameBuffer,s1,s2) reads all scan lines with y coordinates
|
||||||
|
// in the interval [min (s1, s2), max (s1, s2)] from the data provided and
|
||||||
|
// stores them in the provided frameBuffer.
|
||||||
|
// the data can be obtained from a call to rawPixelData()
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Both s1 and s2 must be within the data specified
|
||||||
|
//
|
||||||
|
// you must provide a frameBuffer with a samplecountslice, which must have been read
|
||||||
|
// and the data valid - readPixels uses your sample count buffer to compute
|
||||||
|
// offsets to the data it needs
|
||||||
|
//
|
||||||
|
// This call does not block, and is thread safe for clients with an existing
|
||||||
|
// threading model. The InputFile's frameBuffer is not used in this call.
|
||||||
|
//
|
||||||
|
// This call is only provided for clients which have an existing threading model in place
|
||||||
|
// and unpredictable access patterns to the data.
|
||||||
|
// The fastest way to read an entire image is to enable threading,use setFrameBuffer then
|
||||||
|
// readPixels(header().dataWindow().min.y, header.dataWindow().max.y)
|
||||||
|
//
|
||||||
|
//---------------------------------------------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
void readPixels (const char * rawPixelData, |
||||||
|
const DeepFrameBuffer & frameBuffer, |
||||||
|
int scanLine1, |
||||||
|
int scanLine2) const; |
||||||
|
|
||||||
|
//----------------------------------------------
|
||||||
|
// Read a block of raw pixel data from the file,
|
||||||
|
// without uncompressing it (this function is
|
||||||
|
// used to implement OutputFile::copyPixels()).
|
||||||
|
// note: returns the entire payload of the relevant chunk of data, not including part number
|
||||||
|
// including compressed and uncompressed sizes
|
||||||
|
// on entry, if pixelDataSize is insufficiently large, no bytes are read (pixelData can safely be NULL)
|
||||||
|
// on exit, pixelDataSize is the number of bytes required to read the chunk
|
||||||
|
//
|
||||||
|
//----------------------------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
void rawPixelData (int firstScanLine, |
||||||
|
char * pixelData, |
||||||
|
Int64 &pixelDataSize); |
||||||
|
|
||||||
|
|
||||||
|
//-------------------------------------------------
|
||||||
|
// firstScanLineInChunk() returns the row number of the first row that's stored in the
|
||||||
|
// same chunk as scanline y. Depending on the compression mode, this may not be the same as y
|
||||||
|
//
|
||||||
|
// lastScanLineInChunk() returns the row number of the last row that's stored in the same
|
||||||
|
// chunk as scanline y. Depending on the compression mode, this may not be the same as y.
|
||||||
|
// The last chunk in the file may be smaller than all the others
|
||||||
|
//
|
||||||
|
//------------------------------------------------
|
||||||
|
IMF_EXPORT |
||||||
|
int firstScanLineInChunk(int y) const; |
||||||
|
IMF_EXPORT |
||||||
|
int lastScanLineInChunk (int y) const; |
||||||
|
|
||||||
|
//-----------------------------------------------------------
|
||||||
|
// Read pixel sample counts into a slice in the frame buffer.
|
||||||
|
//
|
||||||
|
// readPixelSampleCounts(s1, s2) reads all the counts of
|
||||||
|
// pixel samples with y coordinates in the interval
|
||||||
|
// [min (s1, s2), max (s1, s2)] from the file, and stores
|
||||||
|
// them in the slice naming "sample count".
|
||||||
|
//
|
||||||
|
// Both s1 and s2 must be within the interval
|
||||||
|
// [header().dataWindow().min.y, header.dataWindow().max.y]
|
||||||
|
//
|
||||||
|
// readPixelSampleCounts(s) calls readPixelSampleCounts(s,s).
|
||||||
|
//
|
||||||
|
//-----------------------------------------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
void readPixelSampleCounts (int scanline1, |
||||||
|
int scanline2); |
||||||
|
IMF_EXPORT |
||||||
|
void readPixelSampleCounts (int scanline); |
||||||
|
|
||||||
|
|
||||||
|
//----------------------------------------------------------
|
||||||
|
// Read pixel sample counts into the provided frameBuffer
|
||||||
|
// using a block read of data read by rawPixelData
|
||||||
|
// for multi-scanline compression schemes, you must decode the entire block
|
||||||
|
// so scanline1=firstScanLineInChunk(y) and scanline2=lastScanLineInChunk(y)
|
||||||
|
//
|
||||||
|
// This call does not block, and is thread safe for clients with an existing
|
||||||
|
// threading model. The InputFile's frameBuffer is not used in this call.
|
||||||
|
//
|
||||||
|
// The fastest way to read an entire image is to enable threading in OpenEXR, use setFrameBuffer then
|
||||||
|
// readPixelSampleCounts(header().dataWindow().min.y, header.dataWindow().max.y)
|
||||||
|
//
|
||||||
|
//----------------------------------------------------------
|
||||||
|
IMF_EXPORT |
||||||
|
void readPixelSampleCounts (const char * rawdata ,
|
||||||
|
const DeepFrameBuffer & frameBuffer, |
||||||
|
int scanLine1 ,
|
||||||
|
int scanLine2) const; |
||||||
|
|
||||||
|
struct Data; |
||||||
|
|
||||||
|
private: |
||||||
|
|
||||||
|
Data * _data; |
||||||
|
|
||||||
|
DeepScanLineInputFile (InputPartData* part); |
||||||
|
|
||||||
|
void initialize(const Header& header); |
||||||
|
void compatibilityInitialize(OPENEXR_IMF_INTERNAL_NAMESPACE::IStream & is); |
||||||
|
void multiPartInitialize(InputPartData* part); |
||||||
|
|
||||||
|
friend class InputFile; |
||||||
|
friend class MultiPartInputFile; |
||||||
|
friend void DeepScanLineOutputFile::copyPixels(DeepScanLineInputFile &); |
||||||
|
}; |
||||||
|
|
||||||
|
|
||||||
|
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT |
||||||
|
|
||||||
|
#endif |
@ -0,0 +1,149 @@ |
|||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Copyright (c) 2004, Industrial Light & Magic, a division of Lucas
|
||||||
|
// Digital Ltd. LLC
|
||||||
|
//
|
||||||
|
// All rights reserved.
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without
|
||||||
|
// modification, are permitted provided that the following conditions are
|
||||||
|
// met:
|
||||||
|
// * Redistributions of source code must retain the above copyright
|
||||||
|
// notice, this list of conditions and the following disclaimer.
|
||||||
|
// * Redistributions in binary form must reproduce the above
|
||||||
|
// copyright notice, this list of conditions and the following disclaimer
|
||||||
|
// in the documentation and/or other materials provided with the
|
||||||
|
// distribution.
|
||||||
|
// * Neither the name of Industrial Light & Magic nor the names of
|
||||||
|
// its contributors may be used to endorse or promote products derived
|
||||||
|
// from this software without specific prior written permission.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
//
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
#include "ImfDeepScanLineInputPart.h" |
||||||
|
#include "ImfNamespace.h" |
||||||
|
|
||||||
|
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_ENTER |
||||||
|
|
||||||
|
DeepScanLineInputPart::DeepScanLineInputPart(MultiPartInputFile& multiPartFile, int partNumber) |
||||||
|
{ |
||||||
|
file = multiPartFile.getInputPart<DeepScanLineInputFile>(partNumber); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
const char * |
||||||
|
DeepScanLineInputPart::fileName () const |
||||||
|
{ |
||||||
|
return file->fileName(); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
const Header & |
||||||
|
DeepScanLineInputPart::header () const |
||||||
|
{ |
||||||
|
return file->header(); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
int |
||||||
|
DeepScanLineInputPart::version () const |
||||||
|
{ |
||||||
|
return file->version(); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
void |
||||||
|
DeepScanLineInputPart::setFrameBuffer (const DeepFrameBuffer &frameBuffer) |
||||||
|
{ |
||||||
|
file->setFrameBuffer(frameBuffer); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
const DeepFrameBuffer & |
||||||
|
DeepScanLineInputPart::frameBuffer () const |
||||||
|
{ |
||||||
|
return file->frameBuffer(); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
bool |
||||||
|
DeepScanLineInputPart::isComplete () const |
||||||
|
{ |
||||||
|
return file->isComplete(); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
void |
||||||
|
DeepScanLineInputPart::readPixels (int scanLine1, int scanLine2) |
||||||
|
{ |
||||||
|
file->readPixels(scanLine1, scanLine2); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
void |
||||||
|
DeepScanLineInputPart::readPixels (int scanLine) |
||||||
|
{ |
||||||
|
file->readPixels(scanLine); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
void |
||||||
|
DeepScanLineInputPart::rawPixelData (int firstScanLine, |
||||||
|
char *pixelData, |
||||||
|
Int64 &pixelDataSize) |
||||||
|
{ |
||||||
|
file->rawPixelData(firstScanLine, pixelData, pixelDataSize); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
void |
||||||
|
DeepScanLineInputPart::readPixelSampleCounts(int scanline1, |
||||||
|
int scanline2) |
||||||
|
{ |
||||||
|
file->readPixelSampleCounts(scanline1, scanline2); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
void |
||||||
|
DeepScanLineInputPart::readPixelSampleCounts(int scanline) |
||||||
|
{ |
||||||
|
file->readPixelSampleCounts(scanline); |
||||||
|
} |
||||||
|
|
||||||
|
int
|
||||||
|
DeepScanLineInputPart::firstScanLineInChunk(int y) const |
||||||
|
{ |
||||||
|
return file->firstScanLineInChunk(y); |
||||||
|
} |
||||||
|
|
||||||
|
int
|
||||||
|
DeepScanLineInputPart::lastScanLineInChunk(int y) const |
||||||
|
{ |
||||||
|
return file->lastScanLineInChunk(y); |
||||||
|
} |
||||||
|
|
||||||
|
void
|
||||||
|
DeepScanLineInputPart::readPixels(const char* rawPixelData, const DeepFrameBuffer& frameBuffer, int scanLine1, int scanLine2) const |
||||||
|
{ |
||||||
|
return file->readPixels(rawPixelData,frameBuffer,scanLine1,scanLine2); |
||||||
|
} |
||||||
|
void
|
||||||
|
DeepScanLineInputPart::readPixelSampleCounts(const char* rawdata, const DeepFrameBuffer& frameBuffer, int scanLine1, int scanLine2) const |
||||||
|
{ |
||||||
|
return file->readPixelSampleCounts(rawdata,frameBuffer,scanLine1,scanLine2); |
||||||
|
} |
||||||
|
|
||||||
|
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_EXIT |
@ -0,0 +1,197 @@ |
|||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Copyright (c) 2011, Industrial Light & Magic, a division of Lucas
|
||||||
|
// Digital Ltd. LLC
|
||||||
|
//
|
||||||
|
// All rights reserved.
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without
|
||||||
|
// modification, are permitted provided that the following conditions are
|
||||||
|
// met:
|
||||||
|
// * Redistributions of source code must retain the above copyright
|
||||||
|
// notice, this list of conditions and the following disclaimer.
|
||||||
|
// * Redistributions in binary form must reproduce the above
|
||||||
|
// copyright notice, this list of conditions and the following disclaimer
|
||||||
|
// in the documentation and/or other materials provided with the
|
||||||
|
// distribution.
|
||||||
|
// * Neither the name of Industrial Light & Magic nor the names of
|
||||||
|
// its contributors may be used to endorse or promote products derived
|
||||||
|
// from this software without specific prior written permission.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
//
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef IMFDEEPSCANLINEINPUTPART_H_ |
||||||
|
#define IMFDEEPSCANLINEINPUTPART_H_ |
||||||
|
|
||||||
|
#include "ImfMultiPartInputFile.h" |
||||||
|
#include "ImfDeepScanLineInputFile.h" |
||||||
|
#include "ImfDeepScanLineOutputFile.h" |
||||||
|
#include "ImfNamespace.h" |
||||||
|
#include "ImfExport.h" |
||||||
|
|
||||||
|
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER |
||||||
|
|
||||||
|
class DeepScanLineInputPart |
||||||
|
{ |
||||||
|
public: |
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
DeepScanLineInputPart(MultiPartInputFile& file, int partNumber); |
||||||
|
|
||||||
|
//------------------------
|
||||||
|
// Access to the file name
|
||||||
|
//------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
const char * fileName () const; |
||||||
|
|
||||||
|
|
||||||
|
//--------------------------
|
||||||
|
// Access to the file header
|
||||||
|
//--------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
const Header & header () const; |
||||||
|
|
||||||
|
|
||||||
|
//----------------------------------
|
||||||
|
// Access to the file format version
|
||||||
|
//----------------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
int version () const; |
||||||
|
|
||||||
|
|
||||||
|
//-----------------------------------------------------------
|
||||||
|
// Set the current frame buffer -- copies the FrameBuffer
|
||||||
|
// object into the InputFile object.
|
||||||
|
//
|
||||||
|
// The current frame buffer is the destination for the pixel
|
||||||
|
// data read from the file. The current frame buffer must be
|
||||||
|
// set at least once before readPixels() is called.
|
||||||
|
// The current frame buffer can be changed after each call
|
||||||
|
// to readPixels().
|
||||||
|
//-----------------------------------------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
void setFrameBuffer (const DeepFrameBuffer &frameBuffer); |
||||||
|
|
||||||
|
|
||||||
|
//-----------------------------------
|
||||||
|
// Access to the current frame buffer
|
||||||
|
//-----------------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
const DeepFrameBuffer & frameBuffer () const; |
||||||
|
|
||||||
|
|
||||||
|
//---------------------------------------------------------------
|
||||||
|
// Check if the file is complete:
|
||||||
|
//
|
||||||
|
// isComplete() returns true if all pixels in the data window are
|
||||||
|
// present in the input file, or false if any pixels are missing.
|
||||||
|
// (Another program may still be busy writing the file, or file
|
||||||
|
// writing may have been aborted prematurely.)
|
||||||
|
//---------------------------------------------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
bool isComplete () const; |
||||||
|
|
||||||
|
|
||||||
|
//---------------------------------------------------------------
|
||||||
|
// Read pixel data:
|
||||||
|
//
|
||||||
|
// readPixels(s1,s2) reads all scan lines with y coordinates
|
||||||
|
// in the interval [min (s1, s2), max (s1, s2)] from the file,
|
||||||
|
// and stores them in the current frame buffer.
|
||||||
|
//
|
||||||
|
// Both s1 and s2 must be within the interval
|
||||||
|
// [header().dataWindow().min.y, header.dataWindow().max.y]
|
||||||
|
//
|
||||||
|
// The scan lines can be read from the file in random order, and
|
||||||
|
// individual scan lines may be skipped or read multiple times.
|
||||||
|
// For maximum efficiency, the scan lines should be read in the
|
||||||
|
// order in which they were written to the file.
|
||||||
|
//
|
||||||
|
// readPixels(s) calls readPixels(s,s).
|
||||||
|
//
|
||||||
|
// If threading is enabled, readPixels (s1, s2) tries to perform
|
||||||
|
// decopmression of multiple scanlines in parallel.
|
||||||
|
//
|
||||||
|
//---------------------------------------------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
void readPixels (int scanLine1, int scanLine2); |
||||||
|
IMF_EXPORT |
||||||
|
void readPixels (int scanLine); |
||||||
|
IMF_EXPORT |
||||||
|
void readPixels (const char * rawPixelData,const DeepFrameBuffer & frameBuffer, |
||||||
|
int scanLine1,int scanLine2) const; |
||||||
|
|
||||||
|
//----------------------------------------------
|
||||||
|
// Read a block of raw pixel data from the file,
|
||||||
|
// without uncompressing it (this function is
|
||||||
|
// used to implement OutputFile::copyPixels()).
|
||||||
|
//----------------------------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
void rawPixelData (int firstScanLine, |
||||||
|
char * pixelData, |
||||||
|
Int64 &pixelDataSize); |
||||||
|
|
||||||
|
|
||||||
|
//-----------------------------------------------------------
|
||||||
|
// Read pixel sample counts into a slice in the frame buffer.
|
||||||
|
//
|
||||||
|
// readPixelSampleCounts(s1, s2) reads all the counts of
|
||||||
|
// pixel samples with y coordinates in the interval
|
||||||
|
// [min (s1, s2), max (s1, s2)] from the file, and stores
|
||||||
|
// them in the slice naming "sample count".
|
||||||
|
//
|
||||||
|
// Both s1 and s2 must be within the interval
|
||||||
|
// [header().dataWindow().min.y, header.dataWindow().max.y]
|
||||||
|
//
|
||||||
|
// readPixelSampleCounts(s) calls readPixelSampleCounts(s,s).
|
||||||
|
//-----------------------------------------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
void readPixelSampleCounts(int scanline1, |
||||||
|
int scanline2); |
||||||
|
IMF_EXPORT |
||||||
|
void readPixelSampleCounts(int scanline); |
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
void readPixelSampleCounts( const char * rawdata , const DeepFrameBuffer & frameBuffer, |
||||||
|
int scanLine1 , int scanLine2) const; |
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
int firstScanLineInChunk(int y) const; |
||||||
|
IMF_EXPORT |
||||||
|
int lastScanLineInChunk (int y) const; |
||||||
|
private: |
||||||
|
DeepScanLineInputFile *file; |
||||||
|
|
||||||
|
// needed for copyPixels
|
||||||
|
friend void DeepScanLineOutputFile::copyPixels(DeepScanLineInputPart &); |
||||||
|
}; |
||||||
|
|
||||||
|
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* IMFDEEPSCANLINEINPUTPART_H_ */ |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,256 @@ |
|||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Copyright (c) 2011, Industrial Light & Magic, a division of Lucas
|
||||||
|
// Digital Ltd. LLC
|
||||||
|
//
|
||||||
|
// All rights reserved.
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without
|
||||||
|
// modification, are permitted provided that the following conditions are
|
||||||
|
// met:
|
||||||
|
// * Redistributions of source code must retain the above copyright
|
||||||
|
// notice, this list of conditions and the following disclaimer.
|
||||||
|
// * Redistributions in binary form must reproduce the above
|
||||||
|
// copyright notice, this list of conditions and the following disclaimer
|
||||||
|
// in the documentation and/or other materials provided with the
|
||||||
|
// distribution.
|
||||||
|
// * Neither the name of Industrial Light & Magic nor the names of
|
||||||
|
// its contributors may be used to endorse or promote products derived
|
||||||
|
// from this software without specific prior written permission.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
//
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef INCLUDED_IMF_DEEP_SCAN_LINE_OUTPUT_FILE_H |
||||||
|
#define INCLUDED_IMF_DEEP_SCAN_LINE_OUTPUT_FILE_H |
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// class DeepScanLineOutputFile
|
||||||
|
//
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#include "ImfHeader.h" |
||||||
|
#include "ImfFrameBuffer.h" |
||||||
|
#include "ImfThreading.h" |
||||||
|
#include "ImfGenericOutputFile.h" |
||||||
|
#include "ImfNamespace.h" |
||||||
|
#include "ImfForward.h" |
||||||
|
#include "ImfExport.h" |
||||||
|
|
||||||
|
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER |
||||||
|
|
||||||
|
|
||||||
|
struct PreviewRgba; |
||||||
|
|
||||||
|
class DeepScanLineOutputFile : public GenericOutputFile |
||||||
|
{ |
||||||
|
public: |
||||||
|
|
||||||
|
//-----------------------------------------------------------
|
||||||
|
// Constructor -- opens the file and writes the file header.
|
||||||
|
// The file header is also copied into the DeepScanLineOutputFile
|
||||||
|
// object, and can later be accessed via the header() method.
|
||||||
|
// Destroying this DeepScanLineOutputFile object automatically closes
|
||||||
|
// the file.
|
||||||
|
//
|
||||||
|
// numThreads determines the number of threads that will be
|
||||||
|
// used to write the file (see ImfThreading.h).
|
||||||
|
//-----------------------------------------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
DeepScanLineOutputFile (const char fileName[], const Header &header, |
||||||
|
int numThreads = globalThreadCount()); |
||||||
|
|
||||||
|
|
||||||
|
//------------------------------------------------------------
|
||||||
|
// Constructor -- attaches the new DeepScanLineOutputFile object
|
||||||
|
// to a file that has already been opened, and writes the file header.
|
||||||
|
// The file header is also copied into the DeepScanLineOutputFile
|
||||||
|
// object, and can later be accessed via the header() method.
|
||||||
|
// Destroying this DeepScanLineOutputFile object does not automatically
|
||||||
|
// close the file.
|
||||||
|
//
|
||||||
|
// numThreads determines the number of threads that will be
|
||||||
|
// used to write the file (see ImfThreading.h).
|
||||||
|
//------------------------------------------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
DeepScanLineOutputFile (OPENEXR_IMF_INTERNAL_NAMESPACE::OStream &os, const Header &header, |
||||||
|
int numThreads = globalThreadCount()); |
||||||
|
|
||||||
|
|
||||||
|
//-------------------------------------------------
|
||||||
|
// Destructor
|
||||||
|
//
|
||||||
|
// Destroying the DeepScanLineOutputFile object
|
||||||
|
// before writing all scan lines within the data
|
||||||
|
// window results in an incomplete file.
|
||||||
|
//-------------------------------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
virtual ~DeepScanLineOutputFile (); |
||||||
|
|
||||||
|
|
||||||
|
//------------------------
|
||||||
|
// Access to the file name
|
||||||
|
//------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
const char * fileName () const; |
||||||
|
|
||||||
|
|
||||||
|
//--------------------------
|
||||||
|
// Access to the file header
|
||||||
|
//--------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
const Header & header () const; |
||||||
|
|
||||||
|
|
||||||
|
//-------------------------------------------------------
|
||||||
|
// Set the current frame buffer -- copies the FrameBuffer
|
||||||
|
// object into the OutputFile object.
|
||||||
|
//
|
||||||
|
// The current frame buffer is the source of the pixel
|
||||||
|
// data written to the file. The current frame buffer
|
||||||
|
// must be set at least once before writePixels() is
|
||||||
|
// called. The current frame buffer can be changed
|
||||||
|
// after each call to writePixels.
|
||||||
|
//-------------------------------------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
void setFrameBuffer (const DeepFrameBuffer &frameBuffer); |
||||||
|
|
||||||
|
|
||||||
|
//-----------------------------------
|
||||||
|
// Access to the current frame buffer
|
||||||
|
//-----------------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
const DeepFrameBuffer & frameBuffer () const; |
||||||
|
|
||||||
|
|
||||||
|
//-------------------------------------------------------------------
|
||||||
|
// Write pixel data:
|
||||||
|
//
|
||||||
|
// writePixels(n) retrieves the next n scan lines worth of data from
|
||||||
|
// the current frame buffer, starting with the scan line indicated by
|
||||||
|
// currentScanLine(), and stores the data in the output file, and
|
||||||
|
// progressing in the direction indicated by header.lineOrder().
|
||||||
|
//
|
||||||
|
// To produce a complete and correct file, exactly m scan lines must
|
||||||
|
// be written, where m is equal to
|
||||||
|
// header().dataWindow().max.y - header().dataWindow().min.y + 1.
|
||||||
|
//-------------------------------------------------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
void writePixels (int numScanLines = 1); |
||||||
|
|
||||||
|
|
||||||
|
//------------------------------------------------------------------
|
||||||
|
// Access to the current scan line:
|
||||||
|
//
|
||||||
|
// currentScanLine() returns the y coordinate of the first scan line
|
||||||
|
// that will be read from the current frame buffer during the next
|
||||||
|
// call to writePixels().
|
||||||
|
//
|
||||||
|
// If header.lineOrder() == INCREASING_Y:
|
||||||
|
//
|
||||||
|
// The current scan line before the first call to writePixels()
|
||||||
|
// is header().dataWindow().min.y. After writing each scan line,
|
||||||
|
// the current scan line is incremented by 1.
|
||||||
|
//
|
||||||
|
// If header.lineOrder() == DECREASING_Y:
|
||||||
|
//
|
||||||
|
// The current scan line before the first call to writePixels()
|
||||||
|
// is header().dataWindow().max.y. After writing each scan line,
|
||||||
|
// the current scan line is decremented by 1.
|
||||||
|
//
|
||||||
|
//------------------------------------------------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
int currentScanLine () const; |
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------
|
||||||
|
// Shortcut to copy all pixels from an InputFile into this file,
|
||||||
|
// without uncompressing and then recompressing the pixel data.
|
||||||
|
// This file's header must be compatible with the InputFile's
|
||||||
|
// header: The two header's "dataWindow", "compression",
|
||||||
|
// "lineOrder" and "channels" attributes must be the same.
|
||||||
|
//--------------------------------------------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
void copyPixels (DeepScanLineInputFile &in); |
||||||
|
|
||||||
|
// --------------------------------------------------------------
|
||||||
|
// Shortcut to copy pixels from a given part of a multipart file
|
||||||
|
// --------------------------------------------------------------
|
||||||
|
IMF_EXPORT |
||||||
|
void copyPixels (DeepScanLineInputPart &in); |
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------
|
||||||
|
// Updating the preview image:
|
||||||
|
//
|
||||||
|
// updatePreviewImage() supplies a new set of pixels for the
|
||||||
|
// preview image attribute in the file's header. If the header
|
||||||
|
// does not contain a preview image, updatePreviewImage() throws
|
||||||
|
// an IEX_NAMESPACE::LogicExc.
|
||||||
|
//
|
||||||
|
// Note: updatePreviewImage() is necessary because images are
|
||||||
|
// often stored in a file incrementally, a few scan lines at a
|
||||||
|
// time, while the image is being generated. Since the preview
|
||||||
|
// image is an attribute in the file's header, it gets stored in
|
||||||
|
// the file as soon as the file is opened, but we may not know
|
||||||
|
// what the preview image should look like until we have written
|
||||||
|
// the last scan line of the main image.
|
||||||
|
//
|
||||||
|
//--------------------------------------------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
void updatePreviewImage (const PreviewRgba newPixels[]); |
||||||
|
|
||||||
|
|
||||||
|
struct Data; |
||||||
|
|
||||||
|
private: |
||||||
|
|
||||||
|
//------------------------------------------------------------
|
||||||
|
// Constructor -- attaches the OutputStreamMutex to the
|
||||||
|
// given one from MultiPartOutputFile. Set the previewPosition
|
||||||
|
// and lineOffsetsPosition which have been acquired from
|
||||||
|
// the constructor of MultiPartOutputFile as well.
|
||||||
|
//------------------------------------------------------------
|
||||||
|
DeepScanLineOutputFile (const OutputPartData* part); |
||||||
|
|
||||||
|
DeepScanLineOutputFile (const DeepScanLineOutputFile &); // not implemented
|
||||||
|
DeepScanLineOutputFile & operator = (const DeepScanLineOutputFile &); // not implemented
|
||||||
|
|
||||||
|
void initialize (const Header &header); |
||||||
|
void initializeLineBuffer(); |
||||||
|
|
||||||
|
Data * _data; |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
friend class MultiPartOutputFile; |
||||||
|
}; |
||||||
|
|
||||||
|
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT |
||||||
|
|
||||||
|
#endif |
@ -0,0 +1,107 @@ |
|||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Copyright (c) 2011, Industrial Light & Magic, a division of Lucas
|
||||||
|
// Digital Ltd. LLC
|
||||||
|
//
|
||||||
|
// All rights reserved.
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without
|
||||||
|
// modification, are permitted provided that the following conditions are
|
||||||
|
// met:
|
||||||
|
// * Redistributions of source code must retain the above copyright
|
||||||
|
// notice, this list of conditions and the following disclaimer.
|
||||||
|
// * Redistributions in binary form must reproduce the above
|
||||||
|
// copyright notice, this list of conditions and the following disclaimer
|
||||||
|
// in the documentation and/or other materials provided with the
|
||||||
|
// distribution.
|
||||||
|
// * Neither the name of Industrial Light & Magic nor the names of
|
||||||
|
// its contributors may be used to endorse or promote products derived
|
||||||
|
// from this software without specific prior written permission.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
//
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include "ImfDeepScanLineOutputPart.h" |
||||||
|
#include "ImfNamespace.h" |
||||||
|
|
||||||
|
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_ENTER |
||||||
|
|
||||||
|
DeepScanLineOutputPart::DeepScanLineOutputPart(MultiPartOutputFile& multiPartFile, int partNumber) |
||||||
|
{ |
||||||
|
file = multiPartFile.getOutputPart<DeepScanLineOutputFile>(partNumber); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
const char * |
||||||
|
DeepScanLineOutputPart::fileName () const |
||||||
|
{ |
||||||
|
return file->fileName(); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
const Header & |
||||||
|
DeepScanLineOutputPart::header () const |
||||||
|
{ |
||||||
|
return file->header(); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
void |
||||||
|
DeepScanLineOutputPart::setFrameBuffer (const DeepFrameBuffer &frameBuffer) |
||||||
|
{ |
||||||
|
file->setFrameBuffer(frameBuffer); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
const DeepFrameBuffer & |
||||||
|
DeepScanLineOutputPart::frameBuffer () const |
||||||
|
{ |
||||||
|
return file->frameBuffer(); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
void |
||||||
|
DeepScanLineOutputPart::writePixels (int numScanLines) |
||||||
|
{ |
||||||
|
file->writePixels(numScanLines); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
int |
||||||
|
DeepScanLineOutputPart::currentScanLine () const |
||||||
|
{ |
||||||
|
return file->currentScanLine(); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
void |
||||||
|
DeepScanLineOutputPart::copyPixels (DeepScanLineInputFile &in) |
||||||
|
{ |
||||||
|
file->copyPixels(in); |
||||||
|
} |
||||||
|
|
||||||
|
void |
||||||
|
DeepScanLineOutputPart::copyPixels (DeepScanLineInputPart &in) |
||||||
|
{ |
||||||
|
file->copyPixels(in); |
||||||
|
} |
||||||
|
|
||||||
|
void |
||||||
|
DeepScanLineOutputPart::updatePreviewImage (const PreviewRgba newPixels[]) |
||||||
|
{ |
||||||
|
file->updatePreviewImage(newPixels); |
||||||
|
} |
||||||
|
|
||||||
|
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_EXIT |
||||||
|
|
@ -0,0 +1,178 @@ |
|||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Copyright (c) 2011, Industrial Light & Magic, a division of Lucas
|
||||||
|
// Digital Ltd. LLC
|
||||||
|
//
|
||||||
|
// All rights reserved.
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without
|
||||||
|
// modification, are permitted provided that the following conditions are
|
||||||
|
// met:
|
||||||
|
// * Redistributions of source code must retain the above copyright
|
||||||
|
// notice, this list of conditions and the following disclaimer.
|
||||||
|
// * Redistributions in binary form must reproduce the above
|
||||||
|
// copyright notice, this list of conditions and the following disclaimer
|
||||||
|
// in the documentation and/or other materials provided with the
|
||||||
|
// distribution.
|
||||||
|
// * Neither the name of Industrial Light & Magic nor the names of
|
||||||
|
// its contributors may be used to endorse or promote products derived
|
||||||
|
// from this software without specific prior written permission.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
//
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifndef IMFDEEPSCANLINEOUTPUTPART_H_ |
||||||
|
#define IMFDEEPSCANLINEOUTPUTPART_H_ |
||||||
|
|
||||||
|
#include "ImfDeepScanLineOutputFile.h" |
||||||
|
#include "ImfMultiPartOutputFile.h" |
||||||
|
#include "ImfNamespace.h" |
||||||
|
#include "ImfExport.h" |
||||||
|
|
||||||
|
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER |
||||||
|
|
||||||
|
class DeepScanLineOutputPart |
||||||
|
{ |
||||||
|
public: |
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
DeepScanLineOutputPart(MultiPartOutputFile& multiPartFile, int partNumber); |
||||||
|
|
||||||
|
//------------------------
|
||||||
|
// Access to the file name
|
||||||
|
//------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
const char * fileName () const; |
||||||
|
|
||||||
|
|
||||||
|
//--------------------------
|
||||||
|
// Access to the file header
|
||||||
|
//--------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
const Header & header () const; |
||||||
|
|
||||||
|
|
||||||
|
//-------------------------------------------------------
|
||||||
|
// Set the current frame buffer -- copies the FrameBuffer
|
||||||
|
// object into the OutputFile object.
|
||||||
|
//
|
||||||
|
// The current frame buffer is the source of the pixel
|
||||||
|
// data written to the file. The current frame buffer
|
||||||
|
// must be set at least once before writePixels() is
|
||||||
|
// called. The current frame buffer can be changed
|
||||||
|
// after each call to writePixels.
|
||||||
|
//-------------------------------------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
void setFrameBuffer (const DeepFrameBuffer &frameBuffer); |
||||||
|
|
||||||
|
|
||||||
|
//-----------------------------------
|
||||||
|
// Access to the current frame buffer
|
||||||
|
//-----------------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
const DeepFrameBuffer & frameBuffer () const; |
||||||
|
|
||||||
|
|
||||||
|
//-------------------------------------------------------------------
|
||||||
|
// Write pixel data:
|
||||||
|
//
|
||||||
|
// writePixels(n) retrieves the next n scan lines worth of data from
|
||||||
|
// the current frame buffer, starting with the scan line indicated by
|
||||||
|
// currentScanLine(), and stores the data in the output file, and
|
||||||
|
// progressing in the direction indicated by header.lineOrder().
|
||||||
|
//
|
||||||
|
// To produce a complete and correct file, exactly m scan lines must
|
||||||
|
// be written, where m is equal to
|
||||||
|
// header().dataWindow().max.y - header().dataWindow().min.y + 1.
|
||||||
|
//-------------------------------------------------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
void writePixels (int numScanLines = 1); |
||||||
|
|
||||||
|
|
||||||
|
//------------------------------------------------------------------
|
||||||
|
// Access to the current scan line:
|
||||||
|
//
|
||||||
|
// currentScanLine() returns the y coordinate of the first scan line
|
||||||
|
// that will be read from the current frame buffer during the next
|
||||||
|
// call to writePixels().
|
||||||
|
//
|
||||||
|
// If header.lineOrder() == INCREASING_Y:
|
||||||
|
//
|
||||||
|
// The current scan line before the first call to writePixels()
|
||||||
|
// is header().dataWindow().min.y. After writing each scan line,
|
||||||
|
// the current scan line is incremented by 1.
|
||||||
|
//
|
||||||
|
// If header.lineOrder() == DECREASING_Y:
|
||||||
|
//
|
||||||
|
// The current scan line before the first call to writePixels()
|
||||||
|
// is header().dataWindow().max.y. After writing each scan line,
|
||||||
|
// the current scan line is decremented by 1.
|
||||||
|
//
|
||||||
|
//------------------------------------------------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
int currentScanLine () const; |
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------
|
||||||
|
// Shortcut to copy all pixels from an InputFile into this file,
|
||||||
|
// without uncompressing and then recompressing the pixel data.
|
||||||
|
// This file's header must be compatible with the InputFile's
|
||||||
|
// header: The two header's "dataWindow", "compression",
|
||||||
|
// "lineOrder" and "channels" attributes must be the same.
|
||||||
|
//--------------------------------------------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
void copyPixels (DeepScanLineInputFile &in); |
||||||
|
IMF_EXPORT |
||||||
|
void copyPixels (DeepScanLineInputPart &in); |
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------
|
||||||
|
// Updating the preview image:
|
||||||
|
//
|
||||||
|
// updatePreviewImage() supplies a new set of pixels for the
|
||||||
|
// preview image attribute in the file's header. If the header
|
||||||
|
// does not contain a preview image, updatePreviewImage() throws
|
||||||
|
// an IEX_NAMESPACE::LogicExc.
|
||||||
|
//
|
||||||
|
// Note: updatePreviewImage() is necessary because images are
|
||||||
|
// often stored in a file incrementally, a few scan lines at a
|
||||||
|
// time, while the image is being generated. Since the preview
|
||||||
|
// image is an attribute in the file's header, it gets stored in
|
||||||
|
// the file as soon as the file is opened, but we may not know
|
||||||
|
// what the preview image should look like until we have written
|
||||||
|
// the last scan line of the main image.
|
||||||
|
//
|
||||||
|
//--------------------------------------------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
void updatePreviewImage (const PreviewRgba newPixels[]); |
||||||
|
|
||||||
|
private: |
||||||
|
DeepScanLineOutputFile* file; |
||||||
|
}; |
||||||
|
|
||||||
|
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* IMFDEEPSCANLINEOUTPUTPART_H_ */ |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,472 @@ |
|||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Copyright (c) 2011, Industrial Light & Magic, a division of Lucas
|
||||||
|
// Digital Ltd. LLC
|
||||||
|
//
|
||||||
|
// All rights reserved.
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without
|
||||||
|
// modification, are permitted provided that the following conditions are
|
||||||
|
// met:
|
||||||
|
// * Redistributions of source code must retain the above copyright
|
||||||
|
// notice, this list of conditions and the following disclaimer.
|
||||||
|
// * Redistributions in binary form must reproduce the above
|
||||||
|
// copyright notice, this list of conditions and the following disclaimer
|
||||||
|
// in the documentation and/or other materials provided with the
|
||||||
|
// distribution.
|
||||||
|
// * Neither the name of Industrial Light & Magic nor the names of
|
||||||
|
// its contributors may be used to endorse or promote products derived
|
||||||
|
// from this software without specific prior written permission.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
//
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef INCLUDED_IMF_DEEP_TILED_INPUT_FILE_H |
||||||
|
#define INCLUDED_IMF_DEEP_TILED_INPUT_FILE_H |
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// class DeepTiledInputFile
|
||||||
|
//
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#include "ImfHeader.h" |
||||||
|
#include "ImfFrameBuffer.h" |
||||||
|
#include "ImathBox.h" |
||||||
|
#include "ImfTileDescription.h" |
||||||
|
#include "ImfThreading.h" |
||||||
|
#include "ImfGenericInputFile.h" |
||||||
|
#include "ImfDeepFrameBuffer.h" |
||||||
|
#include "ImfDeepTiledOutputFile.h" |
||||||
|
#include "ImfForward.h" |
||||||
|
#include "ImfNamespace.h" |
||||||
|
#include "ImfExport.h" |
||||||
|
|
||||||
|
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER |
||||||
|
|
||||||
|
class DeepTiledInputFile : public GenericInputFile |
||||||
|
{ |
||||||
|
public: |
||||||
|
|
||||||
|
//--------------------------------------------------------------------
|
||||||
|
// A constructor that opens the file with the specified name, and
|
||||||
|
// reads the file header. The constructor throws an IEX_NAMESPACE::ArgExc
|
||||||
|
// exception if the file is not tiled.
|
||||||
|
// The numThreads parameter specifies how many worker threads this
|
||||||
|
// file will try to keep busy when decompressing individual tiles.
|
||||||
|
// Destroying TiledInputFile objects constructed with this constructor
|
||||||
|
// automatically closes the corresponding files.
|
||||||
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
DeepTiledInputFile (const char fileName[], |
||||||
|
int numThreads = globalThreadCount ()); |
||||||
|
|
||||||
|
|
||||||
|
// ----------------------------------------------------------
|
||||||
|
// A constructor that attaches the new TiledInputFile object
|
||||||
|
// to a file that has already been opened.
|
||||||
|
// Destroying TiledInputFile objects constructed with this
|
||||||
|
// constructor does not automatically close the corresponding
|
||||||
|
// files.
|
||||||
|
// ----------------------------------------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
DeepTiledInputFile (OPENEXR_IMF_INTERNAL_NAMESPACE::IStream &is, int numThreads = globalThreadCount ()); |
||||||
|
|
||||||
|
|
||||||
|
//-----------
|
||||||
|
// Destructor
|
||||||
|
//-----------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
virtual ~DeepTiledInputFile (); |
||||||
|
|
||||||
|
|
||||||
|
//------------------------
|
||||||
|
// Access to the file name
|
||||||
|
//------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
const char * fileName () const; |
||||||
|
|
||||||
|
|
||||||
|
//--------------------------
|
||||||
|
// Access to the file header
|
||||||
|
//--------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
const Header & header () const; |
||||||
|
|
||||||
|
|
||||||
|
//----------------------------------
|
||||||
|
// Access to the file format version
|
||||||
|
//----------------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
int version () const; |
||||||
|
|
||||||
|
|
||||||
|
//-----------------------------------------------------------
|
||||||
|
// Set the current frame buffer -- copies the FrameBuffer
|
||||||
|
// object into the TiledInputFile object.
|
||||||
|
//
|
||||||
|
// The current frame buffer is the destination for the pixel
|
||||||
|
// data read from the file. The current frame buffer must be
|
||||||
|
// set at least once before readTile() is called.
|
||||||
|
// The current frame buffer can be changed after each call
|
||||||
|
// to readTile().
|
||||||
|
//-----------------------------------------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
void setFrameBuffer (const DeepFrameBuffer &frameBuffer); |
||||||
|
|
||||||
|
|
||||||
|
//-----------------------------------
|
||||||
|
// Access to the current frame buffer
|
||||||
|
//-----------------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
const DeepFrameBuffer & frameBuffer () const; |
||||||
|
|
||||||
|
|
||||||
|
//------------------------------------------------------------
|
||||||
|
// Check if the file is complete:
|
||||||
|
//
|
||||||
|
// isComplete() returns true if all pixels in the data window
|
||||||
|
// (in all levels) are present in the input file, or false if
|
||||||
|
// any pixels are missing. (Another program may still be busy
|
||||||
|
// writing the file, or file writing may have been aborted
|
||||||
|
// prematurely.)
|
||||||
|
//------------------------------------------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
bool isComplete () const; |
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------
|
||||||
|
// Utility functions:
|
||||||
|
//--------------------------------------------------
|
||||||
|
|
||||||
|
//---------------------------------------------------------
|
||||||
|
// Multiresolution mode and tile size:
|
||||||
|
// The following functions return the xSize, ySize and mode
|
||||||
|
// fields of the file header's TileDescriptionAttribute.
|
||||||
|
//---------------------------------------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
unsigned int tileXSize () const; |
||||||
|
IMF_EXPORT |
||||||
|
unsigned int tileYSize () const; |
||||||
|
IMF_EXPORT |
||||||
|
LevelMode levelMode () const; |
||||||
|
IMF_EXPORT |
||||||
|
LevelRoundingMode levelRoundingMode () const; |
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------
|
||||||
|
// Number of levels:
|
||||||
|
//
|
||||||
|
// numXLevels() returns the file's number of levels in x direction.
|
||||||
|
//
|
||||||
|
// if levelMode() == ONE_LEVEL:
|
||||||
|
// return value is: 1
|
||||||
|
//
|
||||||
|
// if levelMode() == MIPMAP_LEVELS:
|
||||||
|
// return value is: rfunc (log (max (w, h)) / log (2)) + 1
|
||||||
|
//
|
||||||
|
// if levelMode() == RIPMAP_LEVELS:
|
||||||
|
// return value is: rfunc (log (w) / log (2)) + 1
|
||||||
|
//
|
||||||
|
// where
|
||||||
|
// w is the width of the image's data window, max.x - min.x + 1,
|
||||||
|
// y is the height of the image's data window, max.y - min.y + 1,
|
||||||
|
// and rfunc(x) is either floor(x), or ceil(x), depending on
|
||||||
|
// whether levelRoundingMode() returns ROUND_DOWN or ROUND_UP.
|
||||||
|
//
|
||||||
|
// numYLevels() returns the file's number of levels in y direction.
|
||||||
|
//
|
||||||
|
// if levelMode() == ONE_LEVEL or levelMode() == MIPMAP_LEVELS:
|
||||||
|
// return value is the same as for numXLevels()
|
||||||
|
//
|
||||||
|
// if levelMode() == RIPMAP_LEVELS:
|
||||||
|
// return value is: rfunc (log (h) / log (2)) + 1
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// numLevels() is a convenience function for use with
|
||||||
|
// MIPMAP_LEVELS files.
|
||||||
|
//
|
||||||
|
// if levelMode() == ONE_LEVEL or levelMode() == MIPMAP_LEVELS:
|
||||||
|
// return value is the same as for numXLevels()
|
||||||
|
//
|
||||||
|
// if levelMode() == RIPMAP_LEVELS:
|
||||||
|
// an IEX_NAMESPACE::LogicExc exception is thrown
|
||||||
|
//
|
||||||
|
// isValidLevel(lx, ly) returns true if the file contains
|
||||||
|
// a level with level number (lx, ly), false if not.
|
||||||
|
//
|
||||||
|
// totalTiles() returns the total number of tiles in the image
|
||||||
|
//
|
||||||
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
int numLevels () const; |
||||||
|
IMF_EXPORT |
||||||
|
int numXLevels () const; |
||||||
|
IMF_EXPORT |
||||||
|
int numYLevels () const; |
||||||
|
IMF_EXPORT |
||||||
|
bool isValidLevel (int lx, int ly) const; |
||||||
|
IMF_EXPORT |
||||||
|
size_t totalTiles() const; |
||||||
|
|
||||||
|
//----------------------------------------------------------
|
||||||
|
// Dimensions of a level:
|
||||||
|
//
|
||||||
|
// levelWidth(lx) returns the width of a level with level
|
||||||
|
// number (lx, *), where * is any number.
|
||||||
|
//
|
||||||
|
// return value is:
|
||||||
|
// max (1, rfunc (w / pow (2, lx)))
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// levelHeight(ly) returns the height of a level with level
|
||||||
|
// number (*, ly), where * is any number.
|
||||||
|
//
|
||||||
|
// return value is:
|
||||||
|
// max (1, rfunc (h / pow (2, ly)))
|
||||||
|
//
|
||||||
|
//----------------------------------------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
int levelWidth (int lx) const; |
||||||
|
IMF_EXPORT |
||||||
|
int levelHeight (int ly) const; |
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------
|
||||||
|
// Number of tiles:
|
||||||
|
//
|
||||||
|
// numXTiles(lx) returns the number of tiles in x direction
|
||||||
|
// that cover a level with level number (lx, *), where * is
|
||||||
|
// any number.
|
||||||
|
//
|
||||||
|
// return value is:
|
||||||
|
// (levelWidth(lx) + tileXSize() - 1) / tileXSize()
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// numYTiles(ly) returns the number of tiles in y direction
|
||||||
|
// that cover a level with level number (*, ly), where * is
|
||||||
|
// any number.
|
||||||
|
//
|
||||||
|
// return value is:
|
||||||
|
// (levelHeight(ly) + tileXSize() - 1) / tileXSize()
|
||||||
|
//
|
||||||
|
//--------------------------------------------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
int numXTiles (int lx = 0) const; |
||||||
|
IMF_EXPORT |
||||||
|
int numYTiles (int ly = 0) const; |
||||||
|
|
||||||
|
|
||||||
|
//---------------------------------------------------------------
|
||||||
|
// Level pixel ranges:
|
||||||
|
//
|
||||||
|
// dataWindowForLevel(lx, ly) returns a 2-dimensional region of
|
||||||
|
// valid pixel coordinates for a level with level number (lx, ly)
|
||||||
|
//
|
||||||
|
// return value is a Box2i with min value:
|
||||||
|
// (dataWindow.min.x, dataWindow.min.y)
|
||||||
|
//
|
||||||
|
// and max value:
|
||||||
|
// (dataWindow.min.x + levelWidth(lx) - 1,
|
||||||
|
// dataWindow.min.y + levelHeight(ly) - 1)
|
||||||
|
//
|
||||||
|
// dataWindowForLevel(level) is a convenience function used
|
||||||
|
// for ONE_LEVEL and MIPMAP_LEVELS files. It returns
|
||||||
|
// dataWindowForLevel(level, level).
|
||||||
|
//
|
||||||
|
//---------------------------------------------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
IMATH_NAMESPACE::Box2i dataWindowForLevel (int l = 0) const; |
||||||
|
IMF_EXPORT |
||||||
|
IMATH_NAMESPACE::Box2i dataWindowForLevel (int lx, int ly) const; |
||||||
|
|
||||||
|
|
||||||
|
//-------------------------------------------------------------------
|
||||||
|
// Tile pixel ranges:
|
||||||
|
//
|
||||||
|
// dataWindowForTile(dx, dy, lx, ly) returns a 2-dimensional
|
||||||
|
// region of valid pixel coordinates for a tile with tile coordinates
|
||||||
|
// (dx,dy) and level number (lx, ly).
|
||||||
|
//
|
||||||
|
// return value is a Box2i with min value:
|
||||||
|
// (dataWindow.min.x + dx * tileXSize(),
|
||||||
|
// dataWindow.min.y + dy * tileYSize())
|
||||||
|
//
|
||||||
|
// and max value:
|
||||||
|
// (dataWindow.min.x + (dx + 1) * tileXSize() - 1,
|
||||||
|
// dataWindow.min.y + (dy + 1) * tileYSize() - 1)
|
||||||
|
//
|
||||||
|
// dataWindowForTile(dx, dy, level) is a convenience function
|
||||||
|
// used for ONE_LEVEL and MIPMAP_LEVELS files. It returns
|
||||||
|
// dataWindowForTile(dx, dy, level, level).
|
||||||
|
//
|
||||||
|
//-------------------------------------------------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
IMATH_NAMESPACE::Box2i dataWindowForTile (int dx, int dy, int l = 0) const; |
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
IMATH_NAMESPACE::Box2i dataWindowForTile (int dx, int dy, |
||||||
|
int lx, int ly) const; |
||||||
|
|
||||||
|
//------------------------------------------------------------
|
||||||
|
// Read pixel data:
|
||||||
|
//
|
||||||
|
// readTile(dx, dy, lx, ly) reads the tile with tile
|
||||||
|
// coordinates (dx, dy), and level number (lx, ly),
|
||||||
|
// and stores it in the current frame buffer.
|
||||||
|
//
|
||||||
|
// dx must lie in the interval [0, numXTiles(lx)-1]
|
||||||
|
// dy must lie in the interval [0, numYTiles(ly)-1]
|
||||||
|
//
|
||||||
|
// lx must lie in the interval [0, numXLevels()-1]
|
||||||
|
// ly must lie in the inverval [0, numYLevels()-1]
|
||||||
|
//
|
||||||
|
// readTile(dx, dy, level) is a convenience function used
|
||||||
|
// for ONE_LEVEL and MIPMAP_LEVELS files. It calls
|
||||||
|
// readTile(dx, dy, level, level).
|
||||||
|
//
|
||||||
|
// The two readTiles(dx1, dx2, dy1, dy2, ...) functions allow
|
||||||
|
// reading multiple tiles at once. If multi-threading is used
|
||||||
|
// the multiple tiles are read concurrently.
|
||||||
|
//
|
||||||
|
// Pixels that are outside the pixel coordinate range for the
|
||||||
|
// tile's level, are never accessed by readTile().
|
||||||
|
//
|
||||||
|
// Attempting to access a tile that is not present in the file
|
||||||
|
// throws an InputExc exception.
|
||||||
|
//
|
||||||
|
//------------------------------------------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
void readTile (int dx, int dy, int l = 0); |
||||||
|
IMF_EXPORT |
||||||
|
void readTile (int dx, int dy, int lx, int ly); |
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
void readTiles (int dx1, int dx2, int dy1, int dy2, |
||||||
|
int lx, int ly); |
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
void readTiles (int dx1, int dx2, int dy1, int dy2, |
||||||
|
int l = 0); |
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------
|
||||||
|
// Read a tile of raw pixel data from the file,
|
||||||
|
// without uncompressing it (this function is
|
||||||
|
// used to implement TiledOutputFile::copyPixels()).
|
||||||
|
//--------------------------------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
void rawTileData (int &dx, int &dy, |
||||||
|
int &lx, int &ly, |
||||||
|
char *pixelData, |
||||||
|
Int64 &dataSize) const; |
||||||
|
|
||||||
|
//------------------------------------------------------------------
|
||||||
|
// Read pixel sample counts into a slice in the frame buffer.
|
||||||
|
//
|
||||||
|
// readPixelSampleCount(dx, dy, lx, ly) reads the sample counts
|
||||||
|
// for tile (dx, dy) in level (lx, ly).
|
||||||
|
//
|
||||||
|
// readPixelSampleCount(dx, dy, l) calls
|
||||||
|
// readPixelSampleCount(dx, dy, lx = l, ly = l)
|
||||||
|
//
|
||||||
|
// dx must lie in the interval [0, numXTiles(lx)-1]
|
||||||
|
// dy must lie in the interval [0, numYTiles(ly)-1]
|
||||||
|
//
|
||||||
|
// lx must lie in the interval [0, numXLevels()-1]
|
||||||
|
// ly must lie in the inverval [0, numYLevels()-1]
|
||||||
|
//
|
||||||
|
// readPixelSampleCounts(dx1, dx2, dy1, dy2, lx, ly) reads all
|
||||||
|
// the sample counts for tiles within range
|
||||||
|
// [(min(dx1, dx2), min(dy1, dy2))...(max(dx1, dx2), max(dy1, dy2)],
|
||||||
|
// and on level (lx, ly)
|
||||||
|
//
|
||||||
|
// readPixelSampleCounts(dx1, dx2, dy1, dy2, l) calls
|
||||||
|
// readPixelSampleCounts(dx1, dx2, dy1, dy2, lx = l, ly = l).
|
||||||
|
//------------------------------------------------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
void readPixelSampleCount (int dx, int dy, int l = 0); |
||||||
|
IMF_EXPORT |
||||||
|
void readPixelSampleCount (int dx, int dy, int lx, int ly); |
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
void readPixelSampleCounts (int dx1, int dx2, |
||||||
|
int dy1, int dy2, |
||||||
|
int lx, int ly); |
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
void readPixelSampleCounts (int dx1, int dx2, |
||||||
|
int dy1, int dy2, |
||||||
|
int l = 0); |
||||||
|
|
||||||
|
struct Data; |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private: |
||||||
|
|
||||||
|
friend class InputFile; |
||||||
|
friend class MultiPartInputFile; |
||||||
|
|
||||||
|
DeepTiledInputFile (InputPartData* part); |
||||||
|
|
||||||
|
DeepTiledInputFile (const DeepTiledInputFile &); // not implemented
|
||||||
|
DeepTiledInputFile & operator = (const DeepTiledInputFile &); // not implemented
|
||||||
|
|
||||||
|
DeepTiledInputFile (const Header &header, OPENEXR_IMF_INTERNAL_NAMESPACE::IStream *is, int version, |
||||||
|
int numThreads); |
||||||
|
|
||||||
|
void initialize (); |
||||||
|
void multiPartInitialize(InputPartData* part); |
||||||
|
void compatibilityInitialize(OPENEXR_IMF_INTERNAL_NAMESPACE::IStream& is); |
||||||
|
|
||||||
|
bool isValidTile (int dx, int dy, |
||||||
|
int lx, int ly) const; |
||||||
|
|
||||||
|
size_t bytesPerLineForTile (int dx, int dy, |
||||||
|
int lx, int ly) const; |
||||||
|
|
||||||
|
|
||||||
|
void getTileOrder(int dx[],int dy[],int lx[],int ly[]) const; |
||||||
|
|
||||||
|
|
||||||
|
Data * _data; |
||||||
|
|
||||||
|
|
||||||
|
// needed for copyPixels
|
||||||
|
friend void DeepTiledOutputFile::copyPixels(DeepTiledInputFile &); |
||||||
|
}; |
||||||
|
|
||||||
|
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT |
||||||
|
|
||||||
|
#endif |
@ -0,0 +1,273 @@ |
|||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Copyright (c) 2011, Industrial Light & Magic, a division of Lucas
|
||||||
|
// Digital Ltd. LLC
|
||||||
|
//
|
||||||
|
// All rights reserved.
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without
|
||||||
|
// modification, are permitted provided that the following conditions are
|
||||||
|
// met:
|
||||||
|
// * Redistributions of source code must retain the above copyright
|
||||||
|
// notice, this list of conditions and the following disclaimer.
|
||||||
|
// * Redistributions in binary form must reproduce the above
|
||||||
|
// copyright notice, this list of conditions and the following disclaimer
|
||||||
|
// in the documentation and/or other materials provided with the
|
||||||
|
// distribution.
|
||||||
|
// * Neither the name of Industrial Light & Magic nor the names of
|
||||||
|
// its contributors may be used to endorse or promote products derived
|
||||||
|
// from this software without specific prior written permission.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
//
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
#include "ImfDeepTiledInputPart.h" |
||||||
|
#include "ImfMultiPartInputFile.h" |
||||||
|
#include "ImfNamespace.h" |
||||||
|
|
||||||
|
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_ENTER |
||||||
|
|
||||||
|
DeepTiledInputPart::DeepTiledInputPart(MultiPartInputFile& multiPartFile, int partNumber) |
||||||
|
{ |
||||||
|
file = multiPartFile.getInputPart<DeepTiledInputFile>(partNumber); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
const char * |
||||||
|
DeepTiledInputPart::fileName () const |
||||||
|
{ |
||||||
|
return file->fileName(); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
const Header & |
||||||
|
DeepTiledInputPart::header () const |
||||||
|
{ |
||||||
|
return file->header(); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
int |
||||||
|
DeepTiledInputPart::version () const |
||||||
|
{ |
||||||
|
return file->version(); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
void |
||||||
|
DeepTiledInputPart::setFrameBuffer (const DeepFrameBuffer &frameBuffer) |
||||||
|
{ |
||||||
|
file->setFrameBuffer(frameBuffer); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
const DeepFrameBuffer & |
||||||
|
DeepTiledInputPart::frameBuffer () const |
||||||
|
{ |
||||||
|
return file->frameBuffer(); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
bool |
||||||
|
DeepTiledInputPart::isComplete () const |
||||||
|
{ |
||||||
|
return file->isComplete(); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
unsigned int |
||||||
|
DeepTiledInputPart::tileXSize () const |
||||||
|
{ |
||||||
|
return file->tileXSize(); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
unsigned int |
||||||
|
DeepTiledInputPart::tileYSize () const |
||||||
|
{ |
||||||
|
return file->tileYSize(); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
LevelMode |
||||||
|
DeepTiledInputPart::levelMode () const |
||||||
|
{ |
||||||
|
return file->levelMode(); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
LevelRoundingMode |
||||||
|
DeepTiledInputPart::levelRoundingMode () const |
||||||
|
{ |
||||||
|
return file->levelRoundingMode(); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
int |
||||||
|
DeepTiledInputPart::numLevels () const |
||||||
|
{ |
||||||
|
return file->numLevels(); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
int |
||||||
|
DeepTiledInputPart::numXLevels () const |
||||||
|
{ |
||||||
|
return file->numXLevels(); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
int |
||||||
|
DeepTiledInputPart::numYLevels () const |
||||||
|
{ |
||||||
|
return file->numYLevels(); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
bool |
||||||
|
DeepTiledInputPart::isValidLevel (int lx, int ly) const |
||||||
|
{ |
||||||
|
return file->isValidLevel(lx, ly); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
int |
||||||
|
DeepTiledInputPart::levelWidth (int lx) const |
||||||
|
{ |
||||||
|
return file->levelWidth(lx); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
int |
||||||
|
DeepTiledInputPart::levelHeight (int ly) const |
||||||
|
{ |
||||||
|
return file->levelHeight(ly); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
int |
||||||
|
DeepTiledInputPart::numXTiles (int lx) const |
||||||
|
{ |
||||||
|
return file->numXTiles(lx); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
int |
||||||
|
DeepTiledInputPart::numYTiles (int ly) const |
||||||
|
{ |
||||||
|
return file->numYTiles(ly); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
IMATH_NAMESPACE::Box2i |
||||||
|
DeepTiledInputPart::dataWindowForLevel (int l) const |
||||||
|
{ |
||||||
|
return file->dataWindowForLevel(l); |
||||||
|
} |
||||||
|
|
||||||
|
IMATH_NAMESPACE::Box2i |
||||||
|
DeepTiledInputPart::dataWindowForLevel (int lx, int ly) const |
||||||
|
{ |
||||||
|
return file->dataWindowForLevel(lx, ly); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
IMATH_NAMESPACE::Box2i |
||||||
|
DeepTiledInputPart::dataWindowForTile (int dx, int dy, int l) const |
||||||
|
{ |
||||||
|
return file->dataWindowForTile(dx, dy, l); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
IMATH_NAMESPACE::Box2i |
||||||
|
DeepTiledInputPart::dataWindowForTile (int dx, int dy, |
||||||
|
int lx, int ly) const |
||||||
|
{ |
||||||
|
return file->dataWindowForTile(dx, dy, lx, ly); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
void |
||||||
|
DeepTiledInputPart::readTile (int dx, int dy, int l) |
||||||
|
{ |
||||||
|
file->readTile(dx, dy, l); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
void |
||||||
|
DeepTiledInputPart::readTile (int dx, int dy, int lx, int ly) |
||||||
|
{ |
||||||
|
file->readTile(dx, dy, lx, ly); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
void |
||||||
|
DeepTiledInputPart::readTiles (int dx1, int dx2, int dy1, int dy2, |
||||||
|
int lx, int ly) |
||||||
|
{ |
||||||
|
file->readTiles(dx1, dx2, dy1, dy2, lx, ly); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
void |
||||||
|
DeepTiledInputPart::readTiles (int dx1, int dx2, int dy1, int dy2, |
||||||
|
int l) |
||||||
|
{ |
||||||
|
file->readTiles(dx1, dx2, dy1, dy2, l); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
void |
||||||
|
DeepTiledInputPart::rawTileData (int &dx, int &dy, |
||||||
|
int &lx, int &ly, |
||||||
|
char * pixelData, |
||||||
|
Int64 & dataSize) const |
||||||
|
{ |
||||||
|
file->rawTileData(dx, dy, lx, ly, pixelData, dataSize ); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
void |
||||||
|
DeepTiledInputPart::readPixelSampleCount (int dx, int dy, int l) |
||||||
|
{ |
||||||
|
file->readPixelSampleCount(dx, dy, l); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
void |
||||||
|
DeepTiledInputPart::readPixelSampleCount (int dx, int dy, int lx, int ly) |
||||||
|
{ |
||||||
|
file->readPixelSampleCount(dx, dy, lx, ly); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
void |
||||||
|
DeepTiledInputPart::readPixelSampleCounts (int dx1, int dx2, |
||||||
|
int dy1, int dy2, |
||||||
|
int lx, int ly) |
||||||
|
{ |
||||||
|
file->readPixelSampleCounts(dx1, dx2, dy1, dy2, lx, ly); |
||||||
|
} |
||||||
|
|
||||||
|
void |
||||||
|
DeepTiledInputPart::readPixelSampleCounts (int dx1, int dx2, |
||||||
|
int dy1, int dy2, |
||||||
|
int l) |
||||||
|
{ |
||||||
|
file->readPixelSampleCounts(dx1, dx2, dy1, dy2, l); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_EXIT |
@ -0,0 +1,394 @@ |
|||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Copyright (c) 2011, Industrial Light & Magic, a division of Lucas
|
||||||
|
// Digital Ltd. LLC
|
||||||
|
//
|
||||||
|
// All rights reserved.
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without
|
||||||
|
// modification, are permitted provided that the following conditions are
|
||||||
|
// met:
|
||||||
|
// * Redistributions of source code must retain the above copyright
|
||||||
|
// notice, this list of conditions and the following disclaimer.
|
||||||
|
// * Redistributions in binary form must reproduce the above
|
||||||
|
// copyright notice, this list of conditions and the following disclaimer
|
||||||
|
// in the documentation and/or other materials provided with the
|
||||||
|
// distribution.
|
||||||
|
// * Neither the name of Industrial Light & Magic nor the names of
|
||||||
|
// its contributors may be used to endorse or promote products derived
|
||||||
|
// from this software without specific prior written permission.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
//
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef IMFDEEPTILEDINPUTPART_H_ |
||||||
|
#define IMFDEEPTILEDINPUTPART_H_ |
||||||
|
|
||||||
|
#include "ImfDeepTiledInputFile.h" |
||||||
|
#include "ImfNamespace.h" |
||||||
|
#include "ImfForward.h" |
||||||
|
#include "ImfExport.h" |
||||||
|
|
||||||
|
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER |
||||||
|
|
||||||
|
class DeepTiledInputPart |
||||||
|
{ |
||||||
|
public: |
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
DeepTiledInputPart(MultiPartInputFile& multiPartFile, int partNumber); |
||||||
|
|
||||||
|
//------------------------
|
||||||
|
// Access to the file name
|
||||||
|
//------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
const char * fileName () const; |
||||||
|
|
||||||
|
|
||||||
|
//--------------------------
|
||||||
|
// Access to the file header
|
||||||
|
//--------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
const Header & header () const; |
||||||
|
|
||||||
|
|
||||||
|
//----------------------------------
|
||||||
|
// Access to the file format version
|
||||||
|
//----------------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
int version () const; |
||||||
|
|
||||||
|
|
||||||
|
//-----------------------------------------------------------
|
||||||
|
// Set the current frame buffer -- copies the FrameBuffer
|
||||||
|
// object into the TiledInputFile object.
|
||||||
|
//
|
||||||
|
// The current frame buffer is the destination for the pixel
|
||||||
|
// data read from the file. The current frame buffer must be
|
||||||
|
// set at least once before readTile() is called.
|
||||||
|
// The current frame buffer can be changed after each call
|
||||||
|
// to readTile().
|
||||||
|
//-----------------------------------------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
void setFrameBuffer (const DeepFrameBuffer &frameBuffer); |
||||||
|
|
||||||
|
|
||||||
|
//-----------------------------------
|
||||||
|
// Access to the current frame buffer
|
||||||
|
//-----------------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
const DeepFrameBuffer & frameBuffer () const; |
||||||
|
|
||||||
|
|
||||||
|
//------------------------------------------------------------
|
||||||
|
// Check if the file is complete:
|
||||||
|
//
|
||||||
|
// isComplete() returns true if all pixels in the data window
|
||||||
|
// (in all levels) are present in the input file, or false if
|
||||||
|
// any pixels are missing. (Another program may still be busy
|
||||||
|
// writing the file, or file writing may have been aborted
|
||||||
|
// prematurely.)
|
||||||
|
//------------------------------------------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
bool isComplete () const; |
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------
|
||||||
|
// Utility functions:
|
||||||
|
//--------------------------------------------------
|
||||||
|
|
||||||
|
//---------------------------------------------------------
|
||||||
|
// Multiresolution mode and tile size:
|
||||||
|
// The following functions return the xSize, ySize and mode
|
||||||
|
// fields of the file header's TileDescriptionAttribute.
|
||||||
|
//---------------------------------------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
unsigned int tileXSize () const; |
||||||
|
IMF_EXPORT |
||||||
|
unsigned int tileYSize () const; |
||||||
|
IMF_EXPORT |
||||||
|
LevelMode levelMode () const; |
||||||
|
IMF_EXPORT |
||||||
|
LevelRoundingMode levelRoundingMode () const; |
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------
|
||||||
|
// Number of levels:
|
||||||
|
//
|
||||||
|
// numXLevels() returns the file's number of levels in x direction.
|
||||||
|
//
|
||||||
|
// if levelMode() == ONE_LEVEL:
|
||||||
|
// return value is: 1
|
||||||
|
//
|
||||||
|
// if levelMode() == MIPMAP_LEVELS:
|
||||||
|
// return value is: rfunc (log (max (w, h)) / log (2)) + 1
|
||||||
|
//
|
||||||
|
// if levelMode() == RIPMAP_LEVELS:
|
||||||
|
// return value is: rfunc (log (w) / log (2)) + 1
|
||||||
|
//
|
||||||
|
// where
|
||||||
|
// w is the width of the image's data window, max.x - min.x + 1,
|
||||||
|
// y is the height of the image's data window, max.y - min.y + 1,
|
||||||
|
// and rfunc(x) is either floor(x), or ceil(x), depending on
|
||||||
|
// whether levelRoundingMode() returns ROUND_DOWN or ROUND_UP.
|
||||||
|
//
|
||||||
|
// numYLevels() returns the file's number of levels in y direction.
|
||||||
|
//
|
||||||
|
// if levelMode() == ONE_LEVEL or levelMode() == MIPMAP_LEVELS:
|
||||||
|
// return value is the same as for numXLevels()
|
||||||
|
//
|
||||||
|
// if levelMode() == RIPMAP_LEVELS:
|
||||||
|
// return value is: rfunc (log (h) / log (2)) + 1
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// numLevels() is a convenience function for use with
|
||||||
|
// MIPMAP_LEVELS files.
|
||||||
|
//
|
||||||
|
// if levelMode() == ONE_LEVEL or levelMode() == MIPMAP_LEVELS:
|
||||||
|
// return value is the same as for numXLevels()
|
||||||
|
//
|
||||||
|
// if levelMode() == RIPMAP_LEVELS:
|
||||||
|
// an IEX_NAMESPACE::LogicExc exception is thrown
|
||||||
|
//
|
||||||
|
// isValidLevel(lx, ly) returns true if the file contains
|
||||||
|
// a level with level number (lx, ly), false if not.
|
||||||
|
//
|
||||||
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
int numLevels () const; |
||||||
|
IMF_EXPORT |
||||||
|
int numXLevels () const; |
||||||
|
IMF_EXPORT |
||||||
|
int numYLevels () const; |
||||||
|
IMF_EXPORT |
||||||
|
bool isValidLevel (int lx, int ly) const; |
||||||
|
|
||||||
|
|
||||||
|
//----------------------------------------------------------
|
||||||
|
// Dimensions of a level:
|
||||||
|
//
|
||||||
|
// levelWidth(lx) returns the width of a level with level
|
||||||
|
// number (lx, *), where * is any number.
|
||||||
|
//
|
||||||
|
// return value is:
|
||||||
|
// max (1, rfunc (w / pow (2, lx)))
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// levelHeight(ly) returns the height of a level with level
|
||||||
|
// number (*, ly), where * is any number.
|
||||||
|
//
|
||||||
|
// return value is:
|
||||||
|
// max (1, rfunc (h / pow (2, ly)))
|
||||||
|
//
|
||||||
|
//----------------------------------------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
int levelWidth (int lx) const; |
||||||
|
IMF_EXPORT |
||||||
|
int levelHeight (int ly) const; |
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------
|
||||||
|
// Number of tiles:
|
||||||
|
//
|
||||||
|
// numXTiles(lx) returns the number of tiles in x direction
|
||||||
|
// that cover a level with level number (lx, *), where * is
|
||||||
|
// any number.
|
||||||
|
//
|
||||||
|
// return value is:
|
||||||
|
// (levelWidth(lx) + tileXSize() - 1) / tileXSize()
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// numYTiles(ly) returns the number of tiles in y direction
|
||||||
|
// that cover a level with level number (*, ly), where * is
|
||||||
|
// any number.
|
||||||
|
//
|
||||||
|
// return value is:
|
||||||
|
// (levelHeight(ly) + tileXSize() - 1) / tileXSize()
|
||||||
|
//
|
||||||
|
//--------------------------------------------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
int numXTiles (int lx = 0) const; |
||||||
|
IMF_EXPORT |
||||||
|
int numYTiles (int ly = 0) const; |
||||||
|
|
||||||
|
|
||||||
|
//---------------------------------------------------------------
|
||||||
|
// Level pixel ranges:
|
||||||
|
//
|
||||||
|
// dataWindowForLevel(lx, ly) returns a 2-dimensional region of
|
||||||
|
// valid pixel coordinates for a level with level number (lx, ly)
|
||||||
|
//
|
||||||
|
// return value is a Box2i with min value:
|
||||||
|
// (dataWindow.min.x, dataWindow.min.y)
|
||||||
|
//
|
||||||
|
// and max value:
|
||||||
|
// (dataWindow.min.x + levelWidth(lx) - 1,
|
||||||
|
// dataWindow.min.y + levelHeight(ly) - 1)
|
||||||
|
//
|
||||||
|
// dataWindowForLevel(level) is a convenience function used
|
||||||
|
// for ONE_LEVEL and MIPMAP_LEVELS files. It returns
|
||||||
|
// dataWindowForLevel(level, level).
|
||||||
|
//
|
||||||
|
//---------------------------------------------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
IMATH_NAMESPACE::Box2i dataWindowForLevel (int l = 0) const; |
||||||
|
IMF_EXPORT |
||||||
|
IMATH_NAMESPACE::Box2i dataWindowForLevel (int lx, int ly) const; |
||||||
|
|
||||||
|
|
||||||
|
//-------------------------------------------------------------------
|
||||||
|
// Tile pixel ranges:
|
||||||
|
//
|
||||||
|
// dataWindowForTile(dx, dy, lx, ly) returns a 2-dimensional
|
||||||
|
// region of valid pixel coordinates for a tile with tile coordinates
|
||||||
|
// (dx,dy) and level number (lx, ly).
|
||||||
|
//
|
||||||
|
// return value is a Box2i with min value:
|
||||||
|
// (dataWindow.min.x + dx * tileXSize(),
|
||||||
|
// dataWindow.min.y + dy * tileYSize())
|
||||||
|
//
|
||||||
|
// and max value:
|
||||||
|
// (dataWindow.min.x + (dx + 1) * tileXSize() - 1,
|
||||||
|
// dataWindow.min.y + (dy + 1) * tileYSize() - 1)
|
||||||
|
//
|
||||||
|
// dataWindowForTile(dx, dy, level) is a convenience function
|
||||||
|
// used for ONE_LEVEL and MIPMAP_LEVELS files. It returns
|
||||||
|
// dataWindowForTile(dx, dy, level, level).
|
||||||
|
//
|
||||||
|
//-------------------------------------------------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
IMATH_NAMESPACE::Box2i dataWindowForTile (int dx, int dy, int l = 0) const; |
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
IMATH_NAMESPACE::Box2i dataWindowForTile (int dx, int dy, |
||||||
|
int lx, int ly) const; |
||||||
|
|
||||||
|
//------------------------------------------------------------
|
||||||
|
// Read pixel data:
|
||||||
|
//
|
||||||
|
// readTile(dx, dy, lx, ly) reads the tile with tile
|
||||||
|
// coordinates (dx, dy), and level number (lx, ly),
|
||||||
|
// and stores it in the current frame buffer.
|
||||||
|
//
|
||||||
|
// dx must lie in the interval [0, numXTiles(lx)-1]
|
||||||
|
// dy must lie in the interval [0, numYTiles(ly)-1]
|
||||||
|
//
|
||||||
|
// lx must lie in the interval [0, numXLevels()-1]
|
||||||
|
// ly must lie in the inverval [0, numYLevels()-1]
|
||||||
|
//
|
||||||
|
// readTile(dx, dy, level) is a convenience function used
|
||||||
|
// for ONE_LEVEL and MIPMAP_LEVELS files. It calls
|
||||||
|
// readTile(dx, dy, level, level).
|
||||||
|
//
|
||||||
|
// The two readTiles(dx1, dx2, dy1, dy2, ...) functions allow
|
||||||
|
// reading multiple tiles at once. If multi-threading is used
|
||||||
|
// the multiple tiles are read concurrently.
|
||||||
|
//
|
||||||
|
// Pixels that are outside the pixel coordinate range for the
|
||||||
|
// tile's level, are never accessed by readTile().
|
||||||
|
//
|
||||||
|
// Attempting to access a tile that is not present in the file
|
||||||
|
// throws an InputExc exception.
|
||||||
|
//
|
||||||
|
//------------------------------------------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
void readTile (int dx, int dy, int l = 0); |
||||||
|
IMF_EXPORT |
||||||
|
void readTile (int dx, int dy, int lx, int ly); |
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
void readTiles (int dx1, int dx2, int dy1, int dy2, |
||||||
|
int lx, int ly); |
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
void readTiles (int dx1, int dx2, int dy1, int dy2, |
||||||
|
int l = 0); |
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------
|
||||||
|
// Read a tile of raw pixel data from the file,
|
||||||
|
// without uncompressing it (this function is
|
||||||
|
// used to implement TiledOutputFile::copyPixels()).
|
||||||
|
//--------------------------------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
void rawTileData (int &dx, int &dy, |
||||||
|
int &lx, int &ly, |
||||||
|
char *data, |
||||||
|
Int64 &dataSize |
||||||
|
) const; |
||||||
|
|
||||||
|
//------------------------------------------------------------------
|
||||||
|
// Read pixel sample counts into a slice in the frame buffer.
|
||||||
|
//
|
||||||
|
// readPixelSampleCount(dx, dy, lx, ly) reads the sample counts
|
||||||
|
// for tile (dx, dy) in level (lx, ly).
|
||||||
|
//
|
||||||
|
// readPixelSampleCount(dx, dy, l) calls
|
||||||
|
// readPixelSampleCount(dx, dy, lx = l, ly = l)
|
||||||
|
//
|
||||||
|
// dx must lie in the interval [0, numXTiles(lx)-1]
|
||||||
|
// dy must lie in the interval [0, numYTiles(ly)-1]
|
||||||
|
//
|
||||||
|
// lx must lie in the interval [0, numXLevels()-1]
|
||||||
|
// ly must lie in the inverval [0, numYLevels()-1]
|
||||||
|
//
|
||||||
|
// readPixelSampleCounts(dx1, dx2, dy1, dy2, lx, ly) reads all
|
||||||
|
// the sample counts for tiles within range
|
||||||
|
// [(min(dx1, dx2), min(dy1, dy2))...(max(dx1, dx2), max(dy1, dy2)],
|
||||||
|
// and on level (lx, ly)
|
||||||
|
//
|
||||||
|
// readPixelSampleCounts(dx1, dx2, dy1, dy2, l) calls
|
||||||
|
// readPixelSampleCounts(dx1, dx2, dy1, dy2, lx = l, ly = l).
|
||||||
|
//------------------------------------------------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
void readPixelSampleCount (int dx, int dy, int l = 0); |
||||||
|
IMF_EXPORT |
||||||
|
void readPixelSampleCount (int dx, int dy, int lx, int ly); |
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
void readPixelSampleCounts (int dx1, int dx2, |
||||||
|
int dy1, int dy2, |
||||||
|
int lx, int ly); |
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
void readPixelSampleCounts (int dx1, int dx2, |
||||||
|
int dy1, int dy2, |
||||||
|
int l = 0); |
||||||
|
|
||||||
|
private: |
||||||
|
DeepTiledInputFile* file; |
||||||
|
|
||||||
|
friend void DeepTiledOutputFile::copyPixels(DeepTiledInputPart &); |
||||||
|
}; |
||||||
|
|
||||||
|
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT |
||||||
|
|
||||||
|
|
||||||
|
#endif /* IMFDEEPTILEDINPUTPART_H_ */ |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,506 @@ |
|||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Copyright (c) 2011, Industrial Light & Magic, a division of Lucas
|
||||||
|
// Digital Ltd. LLC
|
||||||
|
//
|
||||||
|
// All rights reserved.
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without
|
||||||
|
// modification, are permitted provided that the following conditions are
|
||||||
|
// met:
|
||||||
|
// * Redistributions of source code must retain the above copyright
|
||||||
|
// notice, this list of conditions and the following disclaimer.
|
||||||
|
// * Redistributions in binary form must reproduce the above
|
||||||
|
// copyright notice, this list of conditions and the following disclaimer
|
||||||
|
// in the documentation and/or other materials provided with the
|
||||||
|
// distribution.
|
||||||
|
// * Neither the name of Industrial Light & Magic nor the names of
|
||||||
|
// its contributors may be used to endorse or promote products derived
|
||||||
|
// from this software without specific prior written permission.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
//
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef INCLUDED_IMF_DEEP_TILED_OUTPUT_FILE_H |
||||||
|
#define INCLUDED_IMF_DEEP_TILED_OUTPUT_FILE_H |
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// class DeepTiledOutputFile
|
||||||
|
//
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#include "ImfHeader.h" |
||||||
|
#include "ImfFrameBuffer.h" |
||||||
|
#include "ImathBox.h" |
||||||
|
#include "ImfThreading.h" |
||||||
|
#include "ImfGenericOutputFile.h" |
||||||
|
#include "ImfNamespace.h" |
||||||
|
#include "ImfForward.h" |
||||||
|
#include "ImfExport.h" |
||||||
|
|
||||||
|
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER |
||||||
|
|
||||||
|
|
||||||
|
class DeepTiledOutputFile : public GenericOutputFile |
||||||
|
{ |
||||||
|
public: |
||||||
|
|
||||||
|
//-------------------------------------------------------------------
|
||||||
|
// A constructor that opens the file with the specified name, and
|
||||||
|
// writes the file header. The file header is also copied into the
|
||||||
|
// TiledOutputFile object, and can later be accessed via the header()
|
||||||
|
// method.
|
||||||
|
//
|
||||||
|
// Destroying TiledOutputFile constructed with this constructor
|
||||||
|
// automatically closes the corresponding files.
|
||||||
|
//
|
||||||
|
// The header must contain a TileDescriptionAttribute called "tiles".
|
||||||
|
//
|
||||||
|
// The x and y subsampling factors for all image channels must be 1;
|
||||||
|
// subsampling is not supported.
|
||||||
|
//
|
||||||
|
// Tiles can be written to the file in arbitrary order. The line
|
||||||
|
// order attribute can be used to cause the tiles to be sorted in
|
||||||
|
// the file. When the file is read later, reading the tiles in the
|
||||||
|
// same order as they are in the file tends to be significantly
|
||||||
|
// faster than reading the tiles in random order (see writeTile,
|
||||||
|
// below).
|
||||||
|
//-------------------------------------------------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
DeepTiledOutputFile (const char fileName[], |
||||||
|
const Header &header, |
||||||
|
int numThreads = globalThreadCount ()); |
||||||
|
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------
|
||||||
|
// A constructor that attaches the new TiledOutputFile object to
|
||||||
|
// a file that has already been opened. Destroying TiledOutputFile
|
||||||
|
// objects constructed with this constructor does not automatically
|
||||||
|
// close the corresponding files.
|
||||||
|
// ----------------------------------------------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
DeepTiledOutputFile (OPENEXR_IMF_INTERNAL_NAMESPACE::OStream &os, |
||||||
|
const Header &header, |
||||||
|
int numThreads = globalThreadCount ()); |
||||||
|
|
||||||
|
|
||||||
|
//-----------------------------------------------------
|
||||||
|
// Destructor
|
||||||
|
//
|
||||||
|
// Destroying a TiledOutputFile object before all tiles
|
||||||
|
// have been written results in an incomplete file.
|
||||||
|
//-----------------------------------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
virtual ~DeepTiledOutputFile (); |
||||||
|
|
||||||
|
|
||||||
|
//------------------------
|
||||||
|
// Access to the file name
|
||||||
|
//------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
const char * fileName () const; |
||||||
|
|
||||||
|
|
||||||
|
//--------------------------
|
||||||
|
// Access to the file header
|
||||||
|
//--------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
const Header & header () const; |
||||||
|
|
||||||
|
|
||||||
|
//-------------------------------------------------------
|
||||||
|
// Set the current frame buffer -- copies the FrameBuffer
|
||||||
|
// object into the TiledOutputFile object.
|
||||||
|
//
|
||||||
|
// The current frame buffer is the source of the pixel
|
||||||
|
// data written to the file. The current frame buffer
|
||||||
|
// must be set at least once before writeTile() is
|
||||||
|
// called. The current frame buffer can be changed
|
||||||
|
// after each call to writeTile().
|
||||||
|
//-------------------------------------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
void setFrameBuffer (const DeepFrameBuffer &frameBuffer); |
||||||
|
|
||||||
|
|
||||||
|
//-----------------------------------
|
||||||
|
// Access to the current frame buffer
|
||||||
|
//-----------------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
const DeepFrameBuffer & frameBuffer () const; |
||||||
|
|
||||||
|
|
||||||
|
//-------------------
|
||||||
|
// Utility functions:
|
||||||
|
//-------------------
|
||||||
|
|
||||||
|
//---------------------------------------------------------
|
||||||
|
// Multiresolution mode and tile size:
|
||||||
|
// The following functions return the xSize, ySize and mode
|
||||||
|
// fields of the file header's TileDescriptionAttribute.
|
||||||
|
//---------------------------------------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
unsigned int tileXSize () const; |
||||||
|
IMF_EXPORT |
||||||
|
unsigned int tileYSize () const; |
||||||
|
IMF_EXPORT |
||||||
|
LevelMode levelMode () const; |
||||||
|
IMF_EXPORT |
||||||
|
LevelRoundingMode levelRoundingMode () const; |
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------
|
||||||
|
// Number of levels:
|
||||||
|
//
|
||||||
|
// numXLevels() returns the file's number of levels in x direction.
|
||||||
|
//
|
||||||
|
// if levelMode() == ONE_LEVEL:
|
||||||
|
// return value is: 1
|
||||||
|
//
|
||||||
|
// if levelMode() == MIPMAP_LEVELS:
|
||||||
|
// return value is: rfunc (log (max (w, h)) / log (2)) + 1
|
||||||
|
//
|
||||||
|
// if levelMode() == RIPMAP_LEVELS:
|
||||||
|
// return value is: rfunc (log (w) / log (2)) + 1
|
||||||
|
//
|
||||||
|
// where
|
||||||
|
// w is the width of the image's data window, max.x - min.x + 1,
|
||||||
|
// y is the height of the image's data window, max.y - min.y + 1,
|
||||||
|
// and rfunc(x) is either floor(x), or ceil(x), depending on
|
||||||
|
// whether levelRoundingMode() returns ROUND_DOWN or ROUND_UP.
|
||||||
|
//
|
||||||
|
// numYLevels() returns the file's number of levels in y direction.
|
||||||
|
//
|
||||||
|
// if levelMode() == ONE_LEVEL or levelMode() == MIPMAP_LEVELS:
|
||||||
|
// return value is the same as for numXLevels()
|
||||||
|
//
|
||||||
|
// if levelMode() == RIPMAP_LEVELS:
|
||||||
|
// return value is: rfunc (log (h) / log (2)) + 1
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// numLevels() is a convenience function for use with MIPMAP_LEVELS
|
||||||
|
// files.
|
||||||
|
//
|
||||||
|
// if levelMode() == ONE_LEVEL or levelMode() == MIPMAP_LEVELS:
|
||||||
|
// return value is the same as for numXLevels()
|
||||||
|
//
|
||||||
|
// if levelMode() == RIPMAP_LEVELS:
|
||||||
|
// an IEX_NAMESPACE::LogicExc exception is thrown
|
||||||
|
//
|
||||||
|
// isValidLevel(lx, ly) returns true if the file contains
|
||||||
|
// a level with level number (lx, ly), false if not.
|
||||||
|
//
|
||||||
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
int numLevels () const; |
||||||
|
IMF_EXPORT |
||||||
|
int numXLevels () const; |
||||||
|
IMF_EXPORT |
||||||
|
int numYLevels () const; |
||||||
|
IMF_EXPORT |
||||||
|
bool isValidLevel (int lx, int ly) const; |
||||||
|
|
||||||
|
|
||||||
|
//---------------------------------------------------------
|
||||||
|
// Dimensions of a level:
|
||||||
|
//
|
||||||
|
// levelWidth(lx) returns the width of a level with level
|
||||||
|
// number (lx, *), where * is any number.
|
||||||
|
//
|
||||||
|
// return value is:
|
||||||
|
// max (1, rfunc (w / pow (2, lx)))
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// levelHeight(ly) returns the height of a level with level
|
||||||
|
// number (*, ly), where * is any number.
|
||||||
|
//
|
||||||
|
// return value is:
|
||||||
|
// max (1, rfunc (h / pow (2, ly)))
|
||||||
|
//
|
||||||
|
//---------------------------------------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
int levelWidth (int lx) const; |
||||||
|
IMF_EXPORT |
||||||
|
int levelHeight (int ly) const; |
||||||
|
|
||||||
|
|
||||||
|
//----------------------------------------------------------
|
||||||
|
// Number of tiles:
|
||||||
|
//
|
||||||
|
// numXTiles(lx) returns the number of tiles in x direction
|
||||||
|
// that cover a level with level number (lx, *), where * is
|
||||||
|
// any number.
|
||||||
|
//
|
||||||
|
// return value is:
|
||||||
|
// (levelWidth(lx) + tileXSize() - 1) / tileXSize()
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// numYTiles(ly) returns the number of tiles in y direction
|
||||||
|
// that cover a level with level number (*, ly), where * is
|
||||||
|
// any number.
|
||||||
|
//
|
||||||
|
// return value is:
|
||||||
|
// (levelHeight(ly) + tileXSize() - 1) / tileXSize()
|
||||||
|
//
|
||||||
|
//----------------------------------------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
int numXTiles (int lx = 0) const; |
||||||
|
IMF_EXPORT |
||||||
|
int numYTiles (int ly = 0) const; |
||||||
|
|
||||||
|
|
||||||
|
//---------------------------------------------------------
|
||||||
|
// Level pixel ranges:
|
||||||
|
//
|
||||||
|
// dataWindowForLevel(lx, ly) returns a 2-dimensional
|
||||||
|
// region of valid pixel coordinates for a level with
|
||||||
|
// level number (lx, ly)
|
||||||
|
//
|
||||||
|
// return value is a Box2i with min value:
|
||||||
|
// (dataWindow.min.x, dataWindow.min.y)
|
||||||
|
//
|
||||||
|
// and max value:
|
||||||
|
// (dataWindow.min.x + levelWidth(lx) - 1,
|
||||||
|
// dataWindow.min.y + levelHeight(ly) - 1)
|
||||||
|
//
|
||||||
|
// dataWindowForLevel(level) is a convenience function used
|
||||||
|
// for ONE_LEVEL and MIPMAP_LEVELS files. It returns
|
||||||
|
// dataWindowForLevel(level, level).
|
||||||
|
//
|
||||||
|
//---------------------------------------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
IMATH_NAMESPACE::Box2i dataWindowForLevel (int l = 0) const; |
||||||
|
IMF_EXPORT |
||||||
|
IMATH_NAMESPACE::Box2i dataWindowForLevel (int lx, int ly) const; |
||||||
|
|
||||||
|
|
||||||
|
//-------------------------------------------------------------------
|
||||||
|
// Tile pixel ranges:
|
||||||
|
//
|
||||||
|
// dataWindowForTile(dx, dy, lx, ly) returns a 2-dimensional
|
||||||
|
// region of valid pixel coordinates for a tile with tile coordinates
|
||||||
|
// (dx,dy) and level number (lx, ly).
|
||||||
|
//
|
||||||
|
// return value is a Box2i with min value:
|
||||||
|
// (dataWindow.min.x + dx * tileXSize(),
|
||||||
|
// dataWindow.min.y + dy * tileYSize())
|
||||||
|
//
|
||||||
|
// and max value:
|
||||||
|
// (dataWindow.min.x + (dx + 1) * tileXSize() - 1,
|
||||||
|
// dataWindow.min.y + (dy + 1) * tileYSize() - 1)
|
||||||
|
//
|
||||||
|
// dataWindowForTile(dx, dy, level) is a convenience function
|
||||||
|
// used for ONE_LEVEL and MIPMAP_LEVELS files. It returns
|
||||||
|
// dataWindowForTile(dx, dy, level, level).
|
||||||
|
//
|
||||||
|
//-------------------------------------------------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
IMATH_NAMESPACE::Box2i dataWindowForTile (int dx, int dy, |
||||||
|
int l = 0) const; |
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
IMATH_NAMESPACE::Box2i dataWindowForTile (int dx, int dy, |
||||||
|
int lx, int ly) const; |
||||||
|
|
||||||
|
//------------------------------------------------------------------
|
||||||
|
// Write pixel data:
|
||||||
|
//
|
||||||
|
// writeTile(dx, dy, lx, ly) writes the tile with tile
|
||||||
|
// coordinates (dx, dy), and level number (lx, ly) to
|
||||||
|
// the file.
|
||||||
|
//
|
||||||
|
// dx must lie in the interval [0, numXTiles(lx) - 1]
|
||||||
|
// dy must lie in the interval [0, numYTiles(ly) - 1]
|
||||||
|
//
|
||||||
|
// lx must lie in the interval [0, numXLevels() - 1]
|
||||||
|
// ly must lie in the inverval [0, numYLevels() - 1]
|
||||||
|
//
|
||||||
|
// writeTile(dx, dy, level) is a convenience function
|
||||||
|
// used for ONE_LEVEL and MIPMAP_LEVEL files. It calls
|
||||||
|
// writeTile(dx, dy, level, level).
|
||||||
|
//
|
||||||
|
// The two writeTiles(dx1, dx2, dy1, dy2, ...) functions allow
|
||||||
|
// writing multiple tiles at once. If multi-threading is used
|
||||||
|
// multiple tiles are written concurrently. The tile coordinates,
|
||||||
|
// dx1, dx2 and dy1, dy2, specify inclusive ranges of tile
|
||||||
|
// coordinates. It is valid for dx1 < dx2 or dy1 < dy2; the
|
||||||
|
// tiles are always written in the order specified by the line
|
||||||
|
// order attribute. Hence, it is not possible to specify an
|
||||||
|
// "invalid" or empty tile range.
|
||||||
|
//
|
||||||
|
// Pixels that are outside the pixel coordinate range for the tile's
|
||||||
|
// level, are never accessed by writeTile().
|
||||||
|
//
|
||||||
|
// Each tile in the file must be written exactly once.
|
||||||
|
//
|
||||||
|
// The file's line order attribute determines the order of the tiles
|
||||||
|
// in the file:
|
||||||
|
//
|
||||||
|
// INCREASING_Y In the file, the tiles for each level are stored
|
||||||
|
// in a contiguous block. The levels are ordered
|
||||||
|
// like this:
|
||||||
|
//
|
||||||
|
// (0, 0) (1, 0) ... (nx-1, 0)
|
||||||
|
// (0, 1) (1, 1) ... (nx-1, 1)
|
||||||
|
// ...
|
||||||
|
// (0,ny-1) (1,ny-1) ... (nx-1,ny-1)
|
||||||
|
//
|
||||||
|
// where nx = numXLevels(), and ny = numYLevels().
|
||||||
|
// In an individual level, (lx, ly), the tiles
|
||||||
|
// are stored in the following order:
|
||||||
|
//
|
||||||
|
// (0, 0) (1, 0) ... (tx-1, 0)
|
||||||
|
// (0, 1) (1, 1) ... (tx-1, 1)
|
||||||
|
// ...
|
||||||
|
// (0,ty-1) (1,ty-1) ... (tx-1,ty-1)
|
||||||
|
//
|
||||||
|
// where tx = numXTiles(lx),
|
||||||
|
// and ty = numYTiles(ly).
|
||||||
|
//
|
||||||
|
// DECREASING_Y As for INCREASING_Y, the tiles for each level
|
||||||
|
// are stored in a contiguous block. The levels
|
||||||
|
// are ordered the same way as for INCREASING_Y,
|
||||||
|
// but within an individual level, the tiles
|
||||||
|
// are stored in this order:
|
||||||
|
//
|
||||||
|
// (0,ty-1) (1,ty-1) ... (tx-1,ty-1)
|
||||||
|
// ...
|
||||||
|
// (0, 1) (1, 1) ... (tx-1, 1)
|
||||||
|
// (0, 0) (1, 0) ... (tx-1, 0)
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// RANDOM_Y The order of the calls to writeTile() determines
|
||||||
|
// the order of the tiles in the file.
|
||||||
|
//
|
||||||
|
//------------------------------------------------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
void writeTile (int dx, int dy, int l = 0); |
||||||
|
IMF_EXPORT |
||||||
|
void writeTile (int dx, int dy, int lx, int ly); |
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
void writeTiles (int dx1, int dx2, int dy1, int dy2, |
||||||
|
int lx, int ly); |
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
void writeTiles (int dx1, int dx2, int dy1, int dy2, |
||||||
|
int l = 0); |
||||||
|
|
||||||
|
|
||||||
|
//------------------------------------------------------------------
|
||||||
|
// Shortcut to copy all pixels from a TiledInputFile into this file,
|
||||||
|
// without uncompressing and then recompressing the pixel data.
|
||||||
|
// This file's header must be compatible with the TiledInputFile's
|
||||||
|
// header: The two header's "dataWindow", "compression",
|
||||||
|
// "lineOrder", "channels", and "tiles" attributes must be the same.
|
||||||
|
//------------------------------------------------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
void copyPixels (DeepTiledInputFile &in); |
||||||
|
IMF_EXPORT |
||||||
|
void copyPixels (DeepTiledInputPart &in); |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------
|
||||||
|
// Updating the preview image:
|
||||||
|
//
|
||||||
|
// updatePreviewImage() supplies a new set of pixels for the
|
||||||
|
// preview image attribute in the file's header. If the header
|
||||||
|
// does not contain a preview image, updatePreviewImage() throws
|
||||||
|
// an IEX_NAMESPACE::LogicExc.
|
||||||
|
//
|
||||||
|
// Note: updatePreviewImage() is necessary because images are
|
||||||
|
// often stored in a file incrementally, a few tiles at a time,
|
||||||
|
// while the image is being generated. Since the preview image
|
||||||
|
// is an attribute in the file's header, it gets stored in the
|
||||||
|
// file as soon as the file is opened, but we may not know what
|
||||||
|
// the preview image should look like until we have written the
|
||||||
|
// last tile of the main image.
|
||||||
|
//
|
||||||
|
//--------------------------------------------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
void updatePreviewImage (const PreviewRgba newPixels[]); |
||||||
|
|
||||||
|
|
||||||
|
//-------------------------------------------------------------
|
||||||
|
// Break a tile -- for testing and debugging only:
|
||||||
|
//
|
||||||
|
// breakTile(dx,dy,lx,ly,p,n,c) introduces an error into the
|
||||||
|
// output file by writing n copies of character c, starting
|
||||||
|
// p bytes from the beginning of the tile with tile coordinates
|
||||||
|
// (dx, dy) and level number (lx, ly).
|
||||||
|
//
|
||||||
|
// Warning: Calling this function usually results in a broken
|
||||||
|
// image file. The file or parts of it may not be readable,
|
||||||
|
// or the file may contain bad data.
|
||||||
|
//
|
||||||
|
//-------------------------------------------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
void breakTile (int dx, int dy, |
||||||
|
int lx, int ly, |
||||||
|
int offset, |
||||||
|
int length, |
||||||
|
char c); |
||||||
|
struct Data; |
||||||
|
|
||||||
|
private: |
||||||
|
|
||||||
|
// ----------------------------------------------------------------
|
||||||
|
// A constructor attaches the OutputStreamMutex to the
|
||||||
|
// given one from MultiPartOutputFile. Set the previewPosition
|
||||||
|
// and lineOffsetsPosition which have been acquired from
|
||||||
|
// the constructor of MultiPartOutputFile as well.
|
||||||
|
// ----------------------------------------------------------------
|
||||||
|
DeepTiledOutputFile (const OutputPartData* part); |
||||||
|
|
||||||
|
DeepTiledOutputFile (const DeepTiledOutputFile &); // not implemented
|
||||||
|
DeepTiledOutputFile & operator = (const DeepTiledOutputFile &); // not implemented
|
||||||
|
|
||||||
|
void initialize (const Header &header); |
||||||
|
|
||||||
|
bool isValidTile (int dx, int dy, |
||||||
|
int lx, int ly) const; |
||||||
|
|
||||||
|
size_t bytesPerLineForTile (int dx, int dy, |
||||||
|
int lx, int ly) const; |
||||||
|
|
||||||
|
Data * _data; |
||||||
|
|
||||||
|
|
||||||
|
friend class MultiPartOutputFile; |
||||||
|
|
||||||
|
}; |
||||||
|
|
||||||
|
|
||||||
|
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT |
||||||
|
|
||||||
|
#endif |
@ -0,0 +1,250 @@ |
|||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Copyright (c) 2011, Industrial Light & Magic, a division of Lucas
|
||||||
|
// Digital Ltd. LLC
|
||||||
|
//
|
||||||
|
// All rights reserved.
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without
|
||||||
|
// modification, are permitted provided that the following conditions are
|
||||||
|
// met:
|
||||||
|
// * Redistributions of source code must retain the above copyright
|
||||||
|
// notice, this list of conditions and the following disclaimer.
|
||||||
|
// * Redistributions in binary form must reproduce the above
|
||||||
|
// copyright notice, this list of conditions and the following disclaimer
|
||||||
|
// in the documentation and/or other materials provided with the
|
||||||
|
// distribution.
|
||||||
|
// * Neither the name of Industrial Light & Magic nor the names of
|
||||||
|
// its contributors may be used to endorse or promote products derived
|
||||||
|
// from this software without specific prior written permission.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
//
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include "ImfDeepTiledOutputPart.h" |
||||||
|
#include "ImfMultiPartOutputFile.h" |
||||||
|
#include "ImfNamespace.h" |
||||||
|
|
||||||
|
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_ENTER |
||||||
|
|
||||||
|
DeepTiledOutputPart::DeepTiledOutputPart(MultiPartOutputFile& multiPartFile, int partNumber) |
||||||
|
{ |
||||||
|
file = multiPartFile.getOutputPart<DeepTiledOutputFile>(partNumber); |
||||||
|
} |
||||||
|
|
||||||
|
const char * |
||||||
|
DeepTiledOutputPart::fileName () const |
||||||
|
{ |
||||||
|
return file->fileName(); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
const Header & |
||||||
|
DeepTiledOutputPart::header () const |
||||||
|
{ |
||||||
|
return file->header(); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
void |
||||||
|
DeepTiledOutputPart::setFrameBuffer (const DeepFrameBuffer &frameBuffer) |
||||||
|
{ |
||||||
|
file->setFrameBuffer(frameBuffer); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
const DeepFrameBuffer & |
||||||
|
DeepTiledOutputPart::frameBuffer () const |
||||||
|
{ |
||||||
|
return file->frameBuffer(); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
unsigned int |
||||||
|
DeepTiledOutputPart::tileXSize () const |
||||||
|
{ |
||||||
|
return file->tileXSize(); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
unsigned int |
||||||
|
DeepTiledOutputPart::tileYSize () const |
||||||
|
{ |
||||||
|
return file->tileYSize(); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
LevelMode |
||||||
|
DeepTiledOutputPart::levelMode () const |
||||||
|
{ |
||||||
|
return file->levelMode(); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
LevelRoundingMode |
||||||
|
DeepTiledOutputPart::levelRoundingMode () const |
||||||
|
{ |
||||||
|
return file->levelRoundingMode(); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
int |
||||||
|
DeepTiledOutputPart::numLevels () const |
||||||
|
{ |
||||||
|
return file->numLevels(); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
int |
||||||
|
DeepTiledOutputPart::numXLevels () const |
||||||
|
{ |
||||||
|
return file->numXLevels(); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
int |
||||||
|
DeepTiledOutputPart::numYLevels () const |
||||||
|
{ |
||||||
|
return file->numYLevels(); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
bool |
||||||
|
DeepTiledOutputPart::isValidLevel (int lx, int ly) const |
||||||
|
{ |
||||||
|
return file->isValidLevel(lx, ly); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
int |
||||||
|
DeepTiledOutputPart::levelWidth (int lx) const |
||||||
|
{ |
||||||
|
return file->levelWidth(lx); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
int |
||||||
|
DeepTiledOutputPart::levelHeight (int ly) const |
||||||
|
{ |
||||||
|
return file->levelHeight(ly); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
int |
||||||
|
DeepTiledOutputPart::numXTiles (int lx) const |
||||||
|
{ |
||||||
|
return file->numXTiles(lx); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
int |
||||||
|
DeepTiledOutputPart::numYTiles (int ly) const |
||||||
|
{ |
||||||
|
return file->numYTiles(ly); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
IMATH_NAMESPACE::Box2i |
||||||
|
DeepTiledOutputPart::dataWindowForLevel (int l) const |
||||||
|
{ |
||||||
|
return file->dataWindowForLevel(l); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
IMATH_NAMESPACE::Box2i |
||||||
|
DeepTiledOutputPart::dataWindowForLevel (int lx, int ly) const |
||||||
|
{ |
||||||
|
return file->dataWindowForLevel(lx, ly); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
IMATH_NAMESPACE::Box2i |
||||||
|
DeepTiledOutputPart::dataWindowForTile (int dx, int dy, |
||||||
|
int l) const |
||||||
|
{ |
||||||
|
return file->dataWindowForTile(dx, dy, l); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
IMATH_NAMESPACE::Box2i |
||||||
|
DeepTiledOutputPart::dataWindowForTile (int dx, int dy, |
||||||
|
int lx, int ly) const |
||||||
|
{ |
||||||
|
return file->dataWindowForTile(dx, dy, lx, ly); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
void |
||||||
|
DeepTiledOutputPart::writeTile (int dx, int dy, int l) |
||||||
|
{ |
||||||
|
file->writeTile(dx, dy, l); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
void |
||||||
|
DeepTiledOutputPart::writeTile (int dx, int dy, int lx, int ly) |
||||||
|
{ |
||||||
|
file->writeTile(dx, dy, lx, ly); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
void |
||||||
|
DeepTiledOutputPart::writeTiles (int dx1, int dx2, int dy1, int dy2, |
||||||
|
int lx, int ly) |
||||||
|
{ |
||||||
|
file->writeTiles(dx1, dx2, dy1, dy2, lx, ly); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
void |
||||||
|
DeepTiledOutputPart::writeTiles (int dx1, int dx2, int dy1, int dy2, |
||||||
|
int l) |
||||||
|
{ |
||||||
|
file->writeTiles(dx1, dx2, dy1, dy2, l); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
void |
||||||
|
DeepTiledOutputPart::copyPixels (DeepTiledInputFile &in) |
||||||
|
{ |
||||||
|
file->copyPixels(in); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
void |
||||||
|
DeepTiledOutputPart::copyPixels (DeepTiledInputPart &in) |
||||||
|
{ |
||||||
|
file->copyPixels(in); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
void |
||||||
|
DeepTiledOutputPart::updatePreviewImage (const PreviewRgba newPixels[]) |
||||||
|
{ |
||||||
|
file->updatePreviewImage(newPixels); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
void |
||||||
|
DeepTiledOutputPart::breakTile (int dx, int dy, |
||||||
|
int lx, int ly, |
||||||
|
int offset, |
||||||
|
int length, |
||||||
|
char c) |
||||||
|
{ |
||||||
|
file->breakTile(dx, dy, lx, ly, offset, length, c); |
||||||
|
} |
||||||
|
|
||||||
|
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_EXIT |
@ -0,0 +1,423 @@ |
|||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Copyright (c) 2011, Industrial Light & Magic, a division of Lucas
|
||||||
|
// Digital Ltd. LLC
|
||||||
|
//
|
||||||
|
// All rights reserved.
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without
|
||||||
|
// modification, are permitted provided that the following conditions are
|
||||||
|
// met:
|
||||||
|
// * Redistributions of source code must retain the above copyright
|
||||||
|
// notice, this list of conditions and the following disclaimer.
|
||||||
|
// * Redistributions in binary form must reproduce the above
|
||||||
|
// copyright notice, this list of conditions and the following disclaimer
|
||||||
|
// in the documentation and/or other materials provided with the
|
||||||
|
// distribution.
|
||||||
|
// * Neither the name of Industrial Light & Magic nor the names of
|
||||||
|
// its contributors may be used to endorse or promote products derived
|
||||||
|
// from this software without specific prior written permission.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
//
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifndef IMFDEEPTILEDOUTPUTPART_H_ |
||||||
|
#define IMFDEEPTILEDOUTPUTPART_H_ |
||||||
|
|
||||||
|
#include "ImfForward.h" |
||||||
|
#include "ImfDeepTiledInputFile.h" |
||||||
|
#include "ImfNamespace.h" |
||||||
|
#include "ImfExport.h" |
||||||
|
|
||||||
|
|
||||||
|
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER |
||||||
|
|
||||||
|
|
||||||
|
class DeepTiledOutputPart |
||||||
|
{ |
||||||
|
public: |
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
DeepTiledOutputPart(MultiPartOutputFile& multiPartFile, int partNumber); |
||||||
|
|
||||||
|
//------------------------
|
||||||
|
// Access to the file name
|
||||||
|
//------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
const char * fileName () const; |
||||||
|
|
||||||
|
|
||||||
|
//--------------------------
|
||||||
|
// Access to the file header
|
||||||
|
//--------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
const Header & header () const; |
||||||
|
|
||||||
|
|
||||||
|
//-------------------------------------------------------
|
||||||
|
// Set the current frame buffer -- copies the FrameBuffer
|
||||||
|
// object into the TiledOutputFile object.
|
||||||
|
//
|
||||||
|
// The current frame buffer is the source of the pixel
|
||||||
|
// data written to the file. The current frame buffer
|
||||||
|
// must be set at least once before writeTile() is
|
||||||
|
// called. The current frame buffer can be changed
|
||||||
|
// after each call to writeTile().
|
||||||
|
//-------------------------------------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
void setFrameBuffer (const DeepFrameBuffer &frameBuffer); |
||||||
|
|
||||||
|
|
||||||
|
//-----------------------------------
|
||||||
|
// Access to the current frame buffer
|
||||||
|
//-----------------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
const DeepFrameBuffer & frameBuffer () const; |
||||||
|
|
||||||
|
|
||||||
|
//-------------------
|
||||||
|
// Utility functions:
|
||||||
|
//-------------------
|
||||||
|
|
||||||
|
//---------------------------------------------------------
|
||||||
|
// Multiresolution mode and tile size:
|
||||||
|
// The following functions return the xSize, ySize and mode
|
||||||
|
// fields of the file header's TileDescriptionAttribute.
|
||||||
|
//---------------------------------------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
unsigned int tileXSize () const; |
||||||
|
IMF_EXPORT |
||||||
|
unsigned int tileYSize () const; |
||||||
|
IMF_EXPORT |
||||||
|
LevelMode levelMode () const; |
||||||
|
IMF_EXPORT |
||||||
|
LevelRoundingMode levelRoundingMode () const; |
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------
|
||||||
|
// Number of levels:
|
||||||
|
//
|
||||||
|
// numXLevels() returns the file's number of levels in x direction.
|
||||||
|
//
|
||||||
|
// if levelMode() == ONE_LEVEL:
|
||||||
|
// return value is: 1
|
||||||
|
//
|
||||||
|
// if levelMode() == MIPMAP_LEVELS:
|
||||||
|
// return value is: rfunc (log (max (w, h)) / log (2)) + 1
|
||||||
|
//
|
||||||
|
// if levelMode() == RIPMAP_LEVELS:
|
||||||
|
// return value is: rfunc (log (w) / log (2)) + 1
|
||||||
|
//
|
||||||
|
// where
|
||||||
|
// w is the width of the image's data window, max.x - min.x + 1,
|
||||||
|
// y is the height of the image's data window, max.y - min.y + 1,
|
||||||
|
// and rfunc(x) is either floor(x), or ceil(x), depending on
|
||||||
|
// whether levelRoundingMode() returns ROUND_DOWN or ROUND_UP.
|
||||||
|
//
|
||||||
|
// numYLevels() returns the file's number of levels in y direction.
|
||||||
|
//
|
||||||
|
// if levelMode() == ONE_LEVEL or levelMode() == MIPMAP_LEVELS:
|
||||||
|
// return value is the same as for numXLevels()
|
||||||
|
//
|
||||||
|
// if levelMode() == RIPMAP_LEVELS:
|
||||||
|
// return value is: rfunc (log (h) / log (2)) + 1
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// numLevels() is a convenience function for use with MIPMAP_LEVELS
|
||||||
|
// files.
|
||||||
|
//
|
||||||
|
// if levelMode() == ONE_LEVEL or levelMode() == MIPMAP_LEVELS:
|
||||||
|
// return value is the same as for numXLevels()
|
||||||
|
//
|
||||||
|
// if levelMode() == RIPMAP_LEVELS:
|
||||||
|
// an IEX_NAMESPACE::LogicExc exception is thrown
|
||||||
|
//
|
||||||
|
// isValidLevel(lx, ly) returns true if the file contains
|
||||||
|
// a level with level number (lx, ly), false if not.
|
||||||
|
//
|
||||||
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
int numLevels () const; |
||||||
|
IMF_EXPORT |
||||||
|
int numXLevels () const; |
||||||
|
IMF_EXPORT |
||||||
|
int numYLevels () const; |
||||||
|
IMF_EXPORT |
||||||
|
bool isValidLevel (int lx, int ly) const; |
||||||
|
|
||||||
|
|
||||||
|
//---------------------------------------------------------
|
||||||
|
// Dimensions of a level:
|
||||||
|
//
|
||||||
|
// levelWidth(lx) returns the width of a level with level
|
||||||
|
// number (lx, *), where * is any number.
|
||||||
|
//
|
||||||
|
// return value is:
|
||||||
|
// max (1, rfunc (w / pow (2, lx)))
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// levelHeight(ly) returns the height of a level with level
|
||||||
|
// number (*, ly), where * is any number.
|
||||||
|
//
|
||||||
|
// return value is:
|
||||||
|
// max (1, rfunc (h / pow (2, ly)))
|
||||||
|
//
|
||||||
|
//---------------------------------------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
int levelWidth (int lx) const; |
||||||
|
IMF_EXPORT |
||||||
|
int levelHeight (int ly) const; |
||||||
|
|
||||||
|
|
||||||
|
//----------------------------------------------------------
|
||||||
|
// Number of tiles:
|
||||||
|
//
|
||||||
|
// numXTiles(lx) returns the number of tiles in x direction
|
||||||
|
// that cover a level with level number (lx, *), where * is
|
||||||
|
// any number.
|
||||||
|
//
|
||||||
|
// return value is:
|
||||||
|
// (levelWidth(lx) + tileXSize() - 1) / tileXSize()
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// numYTiles(ly) returns the number of tiles in y direction
|
||||||
|
// that cover a level with level number (*, ly), where * is
|
||||||
|
// any number.
|
||||||
|
//
|
||||||
|
// return value is:
|
||||||
|
// (levelHeight(ly) + tileXSize() - 1) / tileXSize()
|
||||||
|
//
|
||||||
|
//----------------------------------------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
int numXTiles (int lx = 0) const; |
||||||
|
IMF_EXPORT |
||||||
|
int numYTiles (int ly = 0) const; |
||||||
|
|
||||||
|
|
||||||
|
//---------------------------------------------------------
|
||||||
|
// Level pixel ranges:
|
||||||
|
//
|
||||||
|
// dataWindowForLevel(lx, ly) returns a 2-dimensional
|
||||||
|
// region of valid pixel coordinates for a level with
|
||||||
|
// level number (lx, ly)
|
||||||
|
//
|
||||||
|
// return value is a Box2i with min value:
|
||||||
|
// (dataWindow.min.x, dataWindow.min.y)
|
||||||
|
//
|
||||||
|
// and max value:
|
||||||
|
// (dataWindow.min.x + levelWidth(lx) - 1,
|
||||||
|
// dataWindow.min.y + levelHeight(ly) - 1)
|
||||||
|
//
|
||||||
|
// dataWindowForLevel(level) is a convenience function used
|
||||||
|
// for ONE_LEVEL and MIPMAP_LEVELS files. It returns
|
||||||
|
// dataWindowForLevel(level, level).
|
||||||
|
//
|
||||||
|
//---------------------------------------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
IMATH_NAMESPACE::Box2i dataWindowForLevel (int l = 0) const; |
||||||
|
IMF_EXPORT |
||||||
|
IMATH_NAMESPACE::Box2i dataWindowForLevel (int lx, int ly) const; |
||||||
|
|
||||||
|
|
||||||
|
//-------------------------------------------------------------------
|
||||||
|
// Tile pixel ranges:
|
||||||
|
//
|
||||||
|
// dataWindowForTile(dx, dy, lx, ly) returns a 2-dimensional
|
||||||
|
// region of valid pixel coordinates for a tile with tile coordinates
|
||||||
|
// (dx,dy) and level number (lx, ly).
|
||||||
|
//
|
||||||
|
// return value is a Box2i with min value:
|
||||||
|
// (dataWindow.min.x + dx * tileXSize(),
|
||||||
|
// dataWindow.min.y + dy * tileYSize())
|
||||||
|
//
|
||||||
|
// and max value:
|
||||||
|
// (dataWindow.min.x + (dx + 1) * tileXSize() - 1,
|
||||||
|
// dataWindow.min.y + (dy + 1) * tileYSize() - 1)
|
||||||
|
//
|
||||||
|
// dataWindowForTile(dx, dy, level) is a convenience function
|
||||||
|
// used for ONE_LEVEL and MIPMAP_LEVELS files. It returns
|
||||||
|
// dataWindowForTile(dx, dy, level, level).
|
||||||
|
//
|
||||||
|
//-------------------------------------------------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
IMATH_NAMESPACE::Box2i dataWindowForTile (int dx, int dy, |
||||||
|
int l = 0) const; |
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
IMATH_NAMESPACE::Box2i dataWindowForTile (int dx, int dy, |
||||||
|
int lx, int ly) const; |
||||||
|
|
||||||
|
//------------------------------------------------------------------
|
||||||
|
// Write pixel data:
|
||||||
|
//
|
||||||
|
// writeTile(dx, dy, lx, ly) writes the tile with tile
|
||||||
|
// coordinates (dx, dy), and level number (lx, ly) to
|
||||||
|
// the file.
|
||||||
|
//
|
||||||
|
// dx must lie in the interval [0, numXTiles(lx) - 1]
|
||||||
|
// dy must lie in the interval [0, numYTiles(ly) - 1]
|
||||||
|
//
|
||||||
|
// lx must lie in the interval [0, numXLevels() - 1]
|
||||||
|
// ly must lie in the inverval [0, numYLevels() - 1]
|
||||||
|
//
|
||||||
|
// writeTile(dx, dy, level) is a convenience function
|
||||||
|
// used for ONE_LEVEL and MIPMAP_LEVEL files. It calls
|
||||||
|
// writeTile(dx, dy, level, level).
|
||||||
|
//
|
||||||
|
// The two writeTiles(dx1, dx2, dy1, dy2, ...) functions allow
|
||||||
|
// writing multiple tiles at once. If multi-threading is used
|
||||||
|
// multiple tiles are written concurrently. The tile coordinates,
|
||||||
|
// dx1, dx2 and dy1, dy2, specify inclusive ranges of tile
|
||||||
|
// coordinates. It is valid for dx1 < dx2 or dy1 < dy2; the
|
||||||
|
// tiles are always written in the order specified by the line
|
||||||
|
// order attribute. Hence, it is not possible to specify an
|
||||||
|
// "invalid" or empty tile range.
|
||||||
|
//
|
||||||
|
// Pixels that are outside the pixel coordinate range for the tile's
|
||||||
|
// level, are never accessed by writeTile().
|
||||||
|
//
|
||||||
|
// Each tile in the file must be written exactly once.
|
||||||
|
//
|
||||||
|
// The file's line order attribute determines the order of the tiles
|
||||||
|
// in the file:
|
||||||
|
//
|
||||||
|
// INCREASING_Y In the file, the tiles for each level are stored
|
||||||
|
// in a contiguous block. The levels are ordered
|
||||||
|
// like this:
|
||||||
|
//
|
||||||
|
// (0, 0) (1, 0) ... (nx-1, 0)
|
||||||
|
// (0, 1) (1, 1) ... (nx-1, 1)
|
||||||
|
// ...
|
||||||
|
// (0,ny-1) (1,ny-1) ... (nx-1,ny-1)
|
||||||
|
//
|
||||||
|
// where nx = numXLevels(), and ny = numYLevels().
|
||||||
|
// In an individual level, (lx, ly), the tiles
|
||||||
|
// are stored in the following order:
|
||||||
|
//
|
||||||
|
// (0, 0) (1, 0) ... (tx-1, 0)
|
||||||
|
// (0, 1) (1, 1) ... (tx-1, 1)
|
||||||
|
// ...
|
||||||
|
// (0,ty-1) (1,ty-1) ... (tx-1,ty-1)
|
||||||
|
//
|
||||||
|
// where tx = numXTiles(lx),
|
||||||
|
// and ty = numYTiles(ly).
|
||||||
|
//
|
||||||
|
// DECREASING_Y As for INCREASING_Y, the tiles for each level
|
||||||
|
// are stored in a contiguous block. The levels
|
||||||
|
// are ordered the same way as for INCREASING_Y,
|
||||||
|
// but within an individual level, the tiles
|
||||||
|
// are stored in this order:
|
||||||
|
//
|
||||||
|
// (0,ty-1) (1,ty-1) ... (tx-1,ty-1)
|
||||||
|
// ...
|
||||||
|
// (0, 1) (1, 1) ... (tx-1, 1)
|
||||||
|
// (0, 0) (1, 0) ... (tx-1, 0)
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// RANDOM_Y The order of the calls to writeTile() determines
|
||||||
|
// the order of the tiles in the file.
|
||||||
|
//
|
||||||
|
//------------------------------------------------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
void writeTile (int dx, int dy, int l = 0); |
||||||
|
IMF_EXPORT |
||||||
|
void writeTile (int dx, int dy, int lx, int ly); |
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
void writeTiles (int dx1, int dx2, int dy1, int dy2, |
||||||
|
int lx, int ly); |
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
void writeTiles (int dx1, int dx2, int dy1, int dy2, |
||||||
|
int l = 0); |
||||||
|
|
||||||
|
|
||||||
|
//------------------------------------------------------------------
|
||||||
|
// Shortcut to copy all pixels from a TiledInputFile into this file,
|
||||||
|
// without uncompressing and then recompressing the pixel data.
|
||||||
|
// This file's header must be compatible with the TiledInputFile's
|
||||||
|
// header: The two header's "dataWindow", "compression",
|
||||||
|
// "lineOrder", "channels", and "tiles" attributes must be the same.
|
||||||
|
//------------------------------------------------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
void copyPixels (DeepTiledInputFile &in); |
||||||
|
IMF_EXPORT |
||||||
|
void copyPixels (DeepTiledInputPart &in); |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------
|
||||||
|
// Updating the preview image:
|
||||||
|
//
|
||||||
|
// updatePreviewImage() supplies a new set of pixels for the
|
||||||
|
// preview image attribute in the file's header. If the header
|
||||||
|
// does not contain a preview image, updatePreviewImage() throws
|
||||||
|
// an IEX_NAMESPACE::LogicExc.
|
||||||
|
//
|
||||||
|
// Note: updatePreviewImage() is necessary because images are
|
||||||
|
// often stored in a file incrementally, a few tiles at a time,
|
||||||
|
// while the image is being generated. Since the preview image
|
||||||
|
// is an attribute in the file's header, it gets stored in the
|
||||||
|
// file as soon as the file is opened, but we may not know what
|
||||||
|
// the preview image should look like until we have written the
|
||||||
|
// last tile of the main image.
|
||||||
|
//
|
||||||
|
//--------------------------------------------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
void updatePreviewImage (const PreviewRgba newPixels[]); |
||||||
|
|
||||||
|
|
||||||
|
//-------------------------------------------------------------
|
||||||
|
// Break a tile -- for testing and debugging only:
|
||||||
|
//
|
||||||
|
// breakTile(dx,dy,lx,ly,p,n,c) introduces an error into the
|
||||||
|
// output file by writing n copies of character c, starting
|
||||||
|
// p bytes from the beginning of the tile with tile coordinates
|
||||||
|
// (dx, dy) and level number (lx, ly).
|
||||||
|
//
|
||||||
|
// Warning: Calling this function usually results in a broken
|
||||||
|
// image file. The file or parts of it may not be readable,
|
||||||
|
// or the file may contain bad data.
|
||||||
|
//
|
||||||
|
//-------------------------------------------------------------
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
void breakTile (int dx, int dy, |
||||||
|
int lx, int ly, |
||||||
|
int offset, |
||||||
|
int length, |
||||||
|
char c); |
||||||
|
|
||||||
|
private: |
||||||
|
DeepTiledOutputFile* file; |
||||||
|
|
||||||
|
}; |
||||||
|
|
||||||
|
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT |
||||||
|
|
||||||
|
#endif /* IMFDEEPTILEDOUTPUTPART_H_ */ |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,219 @@ |
|||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Copyright (c) 2009-2014 DreamWorks Animation LLC.
|
||||||
|
//
|
||||||
|
// All rights reserved.
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without
|
||||||
|
// modification, are permitted provided that the following conditions are
|
||||||
|
// met:
|
||||||
|
// * Redistributions of source code must retain the above copyright
|
||||||
|
// notice, this list of conditions and the following disclaimer.
|
||||||
|
// * Redistributions in binary form must reproduce the above
|
||||||
|
// copyright notice, this list of conditions and the following disclaimer
|
||||||
|
// in the documentation and/or other materials provided with the
|
||||||
|
// distribution.
|
||||||
|
// * Neither the name of DreamWorks Animation nor the names of
|
||||||
|
// its contributors may be used to endorse or promote products derived
|
||||||
|
// from this software without specific prior written permission.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
//
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifndef INCLUDED_IMF_DWA_COMRESSOR_H |
||||||
|
#define INCLUDED_IMF_DWA_COMRESSOR_H |
||||||
|
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// class DwaCompressor -- Store lossy RGB data by quantizing DCT components.
|
||||||
|
//
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#include <vector> |
||||||
|
#include <half.h> |
||||||
|
|
||||||
|
#include "ImfInt64.h" |
||||||
|
#include "ImfZip.h" |
||||||
|
#include "ImfChannelList.h" |
||||||
|
#include "ImfCompressor.h" |
||||||
|
#include "ImfNamespace.h" |
||||||
|
|
||||||
|
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER |
||||||
|
|
||||||
|
class DwaCompressor: public Compressor |
||||||
|
{ |
||||||
|
public: |
||||||
|
|
||||||
|
enum AcCompression
|
||||||
|
{ |
||||||
|
STATIC_HUFFMAN, |
||||||
|
DEFLATE, |
||||||
|
}; |
||||||
|
|
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
DwaCompressor (const Header &hdr,
|
||||||
|
int maxScanLineSize, |
||||||
|
int numScanLines, // ideally is a multiple of 8
|
||||||
|
AcCompression acCompression); |
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
virtual ~DwaCompressor (); |
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
virtual int numScanLines () const; |
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
virtual OPENEXR_IMF_NAMESPACE::Compressor::Format format () const; |
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
virtual int compress (const char *inPtr, |
||||||
|
int inSize, |
||||||
|
int minY, |
||||||
|
const char *&outPtr); |
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
virtual int compressTile (const char *inPtr, |
||||||
|
int inSize, |
||||||
|
IMATH_NAMESPACE::Box2i range, |
||||||
|
const char *&outPtr); |
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
virtual int uncompress (const char *inPtr, |
||||||
|
int inSize, |
||||||
|
int minY, |
||||||
|
const char *&outPtr); |
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
virtual int uncompressTile (const char *inPtr, |
||||||
|
int inSize, |
||||||
|
IMATH_NAMESPACE::Box2i range, |
||||||
|
const char *&outPtr); |
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
static void initializeFuncs (); |
||||||
|
|
||||||
|
private: |
||||||
|
|
||||||
|
struct ChannelData; |
||||||
|
struct CscChannelSet; |
||||||
|
struct Classifier; |
||||||
|
|
||||||
|
class LossyDctDecoderBase; |
||||||
|
class LossyDctDecoder; |
||||||
|
class LossyDctDecoderCsc; |
||||||
|
|
||||||
|
class LossyDctEncoderBase; |
||||||
|
class LossyDctEncoder; |
||||||
|
class LossyDctEncoderCsc; |
||||||
|
|
||||||
|
enum CompressorScheme
|
||||||
|
{ |
||||||
|
UNKNOWN = 0, |
||||||
|
LOSSY_DCT, |
||||||
|
RLE, |
||||||
|
|
||||||
|
NUM_COMPRESSOR_SCHEMES |
||||||
|
}; |
||||||
|
|
||||||
|
//
|
||||||
|
// Per-chunk compressed data sizes, one value per chunk
|
||||||
|
//
|
||||||
|
|
||||||
|
enum DataSizesSingle
|
||||||
|
{ |
||||||
|
VERSION = 0, // Version number:
|
||||||
|
// 0: classic
|
||||||
|
// 1: adds "end of block" to the AC RLE
|
||||||
|
|
||||||
|
UNKNOWN_UNCOMPRESSED_SIZE, // Size of leftover data, uncompressed.
|
||||||
|
UNKNOWN_COMPRESSED_SIZE, // Size of leftover data, zlib compressed.
|
||||||
|
|
||||||
|
AC_COMPRESSED_SIZE, // AC RLE + Huffman size
|
||||||
|
DC_COMPRESSED_SIZE, // DC + Deflate size
|
||||||
|
RLE_COMPRESSED_SIZE, // RLE + Deflate data size
|
||||||
|
RLE_UNCOMPRESSED_SIZE, // RLE'd data size
|
||||||
|
RLE_RAW_SIZE, // Un-RLE'd data size
|
||||||
|
|
||||||
|
AC_UNCOMPRESSED_COUNT, // AC RLE number of elements
|
||||||
|
DC_UNCOMPRESSED_COUNT, // DC number of elements
|
||||||
|
|
||||||
|
AC_COMPRESSION, // AC compression strategy
|
||||||
|
NUM_SIZES_SINGLE |
||||||
|
}; |
||||||
|
|
||||||
|
AcCompression _acCompression; |
||||||
|
|
||||||
|
int _maxScanLineSize; |
||||||
|
int _numScanLines; |
||||||
|
int _min[2], _max[2]; |
||||||
|
|
||||||
|
ChannelList _channels; |
||||||
|
std::vector<ChannelData> _channelData; |
||||||
|
std::vector<CscChannelSet> _cscSets; |
||||||
|
std::vector<Classifier> _channelRules; |
||||||
|
|
||||||
|
char *_packedAcBuffer; |
||||||
|
size_t _packedAcBufferSize; |
||||||
|
char *_packedDcBuffer; |
||||||
|
size_t _packedDcBufferSize; |
||||||
|
char *_rleBuffer; |
||||||
|
size_t _rleBufferSize; |
||||||
|
char *_outBuffer; |
||||||
|
size_t _outBufferSize; |
||||||
|
char *_planarUncBuffer[NUM_COMPRESSOR_SCHEMES]; |
||||||
|
size_t _planarUncBufferSize[NUM_COMPRESSOR_SCHEMES]; |
||||||
|
|
||||||
|
Zip *_zip; |
||||||
|
float _dwaCompressionLevel; |
||||||
|
|
||||||
|
int compress (const char *inPtr, |
||||||
|
int inSize, |
||||||
|
IMATH_NAMESPACE::Box2i range, |
||||||
|
const char *&outPtr); |
||||||
|
|
||||||
|
int uncompress (const char *inPtr, |
||||||
|
int inSize, |
||||||
|
IMATH_NAMESPACE::Box2i range, |
||||||
|
const char *&outPtr); |
||||||
|
|
||||||
|
void initializeBuffers (size_t&); |
||||||
|
void initializeDefaultChannelRules (); |
||||||
|
void initializeLegacyChannelRules (); |
||||||
|
|
||||||
|
void relevantChannelRules( std::vector<Classifier> &) const; |
||||||
|
|
||||||
|
//
|
||||||
|
// Populate our cached version of the channel data with
|
||||||
|
// data from the real channel list. We want to
|
||||||
|
// copy over attributes, determine compression schemes
|
||||||
|
// releveant for the channel type, and find sets of
|
||||||
|
// channels to be compressed from Y'CbCr data instead
|
||||||
|
// of R'G'B'.
|
||||||
|
//
|
||||||
|
|
||||||
|
void classifyChannels (ChannelList channels, |
||||||
|
std::vector<ChannelData> &chanData,
|
||||||
|
std::vector<CscChannelSet> &cscData); |
||||||
|
|
||||||
|
//
|
||||||
|
// Compute various buffer pointers for each channel
|
||||||
|
//
|
||||||
|
|
||||||
|
void setupChannelData (int minX, int minY, int maxX, int maxY); |
||||||
|
}; |
||||||
|
|
||||||
|
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT |
||||||
|
|
||||||
|
#endif |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,46 @@ |
|||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Copyright (c) 2012, Industrial Light & Magic, a division of Lucas
|
||||||
|
// Digital Ltd. LLC
|
||||||
|
//
|
||||||
|
// All rights reserved.
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without
|
||||||
|
// modification, are permitted provided that the following conditions are
|
||||||
|
// met:
|
||||||
|
// * Redistributions of source code must retain the above copyright
|
||||||
|
// notice, this list of conditions and the following disclaimer.
|
||||||
|
// * Redistributions in binary form must reproduce the above
|
||||||
|
// copyright notice, this list of conditions and the following disclaimer
|
||||||
|
// in the documentation and/or other materials provided with the
|
||||||
|
// distribution.
|
||||||
|
// * Neither the name of Industrial Light & Magic nor the names of
|
||||||
|
// its contributors may be used to endorse or promote products derived
|
||||||
|
// from this software without specific prior written permission.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
//
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#if defined(OPENEXR_DLL) |
||||||
|
#if defined(ILMIMF_EXPORTS) |
||||||
|
#define IMF_EXPORT __declspec(dllexport) |
||||||
|
#define IMF_EXPORT_CONST extern __declspec(dllexport) |
||||||
|
#else |
||||||
|
#define IMF_EXPORT __declspec(dllimport) |
||||||
|
#define IMF_EXPORT_CONST extern __declspec(dllimport) |
||||||
|
#endif |
||||||
|
#else |
||||||
|
#define IMF_EXPORT |
||||||
|
#define IMF_EXPORT_CONST extern const |
||||||
|
#endif |
@ -0,0 +1,768 @@ |
|||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Copyright (c) 2009-2014 DreamWorks Animation LLC.
|
||||||
|
//
|
||||||
|
// All rights reserved.
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without
|
||||||
|
// modification, are permitted provided that the following conditions are
|
||||||
|
// met:
|
||||||
|
// * Redistributions of source code must retain the above copyright
|
||||||
|
// notice, this list of conditions and the following disclaimer.
|
||||||
|
// * Redistributions in binary form must reproduce the above
|
||||||
|
// copyright notice, this list of conditions and the following disclaimer
|
||||||
|
// in the documentation and/or other materials provided with the
|
||||||
|
// distribution.
|
||||||
|
// * Neither the name of DreamWorks Animation nor the names of
|
||||||
|
// its contributors may be used to endorse or promote products derived
|
||||||
|
// from this software without specific prior written permission.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
//
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include "ImfFastHuf.h" |
||||||
|
#include <Iex.h> |
||||||
|
|
||||||
|
#include <string.h> |
||||||
|
#include <assert.h> |
||||||
|
#include <math.h> |
||||||
|
#include <vector> |
||||||
|
|
||||||
|
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_ENTER |
||||||
|
|
||||||
|
//
|
||||||
|
// Adapted from hufUnpackEncTable -
|
||||||
|
// We don't need to reconstruct the code book, just the encoded
|
||||||
|
// lengths for each symbol. From the lengths, we can build the
|
||||||
|
// base + offset tables. This should be a bit more efficient
|
||||||
|
// for sparse code books.
|
||||||
|
//
|
||||||
|
// table - ptr to the start of the code length data. Will be
|
||||||
|
// updated as we decode data
|
||||||
|
//
|
||||||
|
// numBytes - size of the encoded table (I think)?
|
||||||
|
//
|
||||||
|
// minSymbol - smallest symbol in the code book
|
||||||
|
//
|
||||||
|
// maxSymbol - largest symbol in the code book.
|
||||||
|
//
|
||||||
|
// rleSymbol - the symbol to trigger RLE in the encoded bitstream
|
||||||
|
//
|
||||||
|
|
||||||
|
FastHufDecoder::FastHufDecoder |
||||||
|
(const char *&table, |
||||||
|
int numBytes, |
||||||
|
int minSymbol, |
||||||
|
int maxSymbol, |
||||||
|
int rleSymbol) |
||||||
|
: |
||||||
|
_rleSymbol (rleSymbol), |
||||||
|
_numSymbols (0), |
||||||
|
_minCodeLength (255), |
||||||
|
_maxCodeLength (0), |
||||||
|
_idToSymbol (0) |
||||||
|
{ |
||||||
|
//
|
||||||
|
// List of symbols that we find with non-zero code lengths
|
||||||
|
// (listed in the order we find them). Store these in the
|
||||||
|
// same format as the code book stores codes + lengths -
|
||||||
|
// low 6 bits are the length, everything above that is
|
||||||
|
// the symbol.
|
||||||
|
//
|
||||||
|
|
||||||
|
std::vector<Int64> symbols; |
||||||
|
|
||||||
|
//
|
||||||
|
// The 'base' table is the minimum code at each code length. base[i]
|
||||||
|
// is the smallest code (numerically) of length i.
|
||||||
|
//
|
||||||
|
|
||||||
|
Int64 base[MAX_CODE_LEN + 1];
|
||||||
|
|
||||||
|
//
|
||||||
|
// The 'offset' table is the position (in sorted order) of the first id
|
||||||
|
// of a given code lenght. Array is indexed by code length, like base.
|
||||||
|
//
|
||||||
|
|
||||||
|
Int64 offset[MAX_CODE_LEN + 1];
|
||||||
|
|
||||||
|
//
|
||||||
|
// Count of how many codes at each length there are. Array is
|
||||||
|
// indexed by code length, like base and offset.
|
||||||
|
//
|
||||||
|
|
||||||
|
size_t codeCount[MAX_CODE_LEN + 1];
|
||||||
|
|
||||||
|
for (int i = 0; i <= MAX_CODE_LEN; ++i) |
||||||
|
{ |
||||||
|
codeCount[i] = 0; |
||||||
|
base[i] = 0xffffffffffffffffULL; |
||||||
|
offset[i] = 0; |
||||||
|
} |
||||||
|
|
||||||
|
//
|
||||||
|
// Count the number of codes, the min/max code lengths, the number of
|
||||||
|
// codes with each length, and record symbols with non-zero code
|
||||||
|
// length as we find them.
|
||||||
|
//
|
||||||
|
|
||||||
|
const char *currByte = table; |
||||||
|
Int64 currBits = 0; |
||||||
|
int currBitCount = 0; |
||||||
|
|
||||||
|
const int SHORT_ZEROCODE_RUN = 59; |
||||||
|
const int LONG_ZEROCODE_RUN = 63; |
||||||
|
const int SHORTEST_LONG_RUN = 2 + LONG_ZEROCODE_RUN - SHORT_ZEROCODE_RUN; |
||||||
|
|
||||||
|
for (Int64 symbol = minSymbol; symbol <= maxSymbol; symbol++) |
||||||
|
{ |
||||||
|
if (currByte - table > numBytes) |
||||||
|
{ |
||||||
|
throw IEX_NAMESPACE::InputExc ("Error decoding Huffman table " |
||||||
|
"(Truncated table data)."); |
||||||
|
} |
||||||
|
|
||||||
|
//
|
||||||
|
// Next code length - either:
|
||||||
|
// 0-58 (literal code length)
|
||||||
|
// 59-62 (various lengths runs of 0)
|
||||||
|
// 63 (run of n 0's, with n is the next 8 bits)
|
||||||
|
//
|
||||||
|
|
||||||
|
Int64 codeLen = readBits (6, currBits, currBitCount, currByte); |
||||||
|
|
||||||
|
if (codeLen == (Int64) LONG_ZEROCODE_RUN) |
||||||
|
{ |
||||||
|
if (currByte - table > numBytes) |
||||||
|
{ |
||||||
|
throw IEX_NAMESPACE::InputExc ("Error decoding Huffman table " |
||||||
|
"(Truncated table data)."); |
||||||
|
} |
||||||
|
|
||||||
|
int runLen = readBits (8, currBits, currBitCount, currByte) + |
||||||
|
SHORTEST_LONG_RUN; |
||||||
|
|
||||||
|
if (symbol + runLen > maxSymbol + 1) |
||||||
|
{ |
||||||
|
throw IEX_NAMESPACE::InputExc ("Error decoding Huffman table " |
||||||
|
"(Run beyond end of table)."); |
||||||
|
} |
||||||
|
|
||||||
|
symbol += runLen - 1; |
||||||
|
|
||||||
|
} |
||||||
|
else if (codeLen >= (Int64) SHORT_ZEROCODE_RUN) |
||||||
|
{ |
||||||
|
int runLen = codeLen - SHORT_ZEROCODE_RUN + 2; |
||||||
|
|
||||||
|
if (symbol + runLen > maxSymbol + 1) |
||||||
|
{ |
||||||
|
throw IEX_NAMESPACE::InputExc ("Error decoding Huffman table " |
||||||
|
"(Run beyond end of table)."); |
||||||
|
} |
||||||
|
|
||||||
|
symbol += runLen - 1; |
||||||
|
|
||||||
|
} |
||||||
|
else if (codeLen != 0) |
||||||
|
{ |
||||||
|
symbols.push_back ((symbol << 6) | (codeLen & 63)); |
||||||
|
|
||||||
|
if (codeLen < _minCodeLength) |
||||||
|
_minCodeLength = codeLen; |
||||||
|
|
||||||
|
if (codeLen > _maxCodeLength) |
||||||
|
_maxCodeLength = codeLen; |
||||||
|
|
||||||
|
codeCount[codeLen]++; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
for (int i = 0; i < MAX_CODE_LEN; ++i) |
||||||
|
_numSymbols += codeCount[i]; |
||||||
|
|
||||||
|
table = currByte; |
||||||
|
|
||||||
|
//
|
||||||
|
// Compute base - once we have the code length counts, there
|
||||||
|
// is a closed form solution for this
|
||||||
|
//
|
||||||
|
|
||||||
|
{ |
||||||
|
double* countTmp = new double[_maxCodeLength+1]; |
||||||
|
|
||||||
|
for (int l = _minCodeLength; l <= _maxCodeLength; ++l) |
||||||
|
{ |
||||||
|
countTmp[l] = (double)codeCount[l] *
|
||||||
|
(double)(2 << (_maxCodeLength-l)); |
||||||
|
} |
||||||
|
|
||||||
|
for (int l = _minCodeLength; l <= _maxCodeLength; ++l) |
||||||
|
{ |
||||||
|
double tmp = 0; |
||||||
|
|
||||||
|
for (int k =l + 1; k <= _maxCodeLength; ++k) |
||||||
|
tmp += countTmp[k]; |
||||||
|
|
||||||
|
tmp /= (double)(2 << (_maxCodeLength - l)); |
||||||
|
|
||||||
|
base[l] = (Int64)ceil (tmp); |
||||||
|
} |
||||||
|
|
||||||
|
delete [] countTmp; |
||||||
|
} |
||||||
|
|
||||||
|
//
|
||||||
|
// Compute offset - these are the positions of the first
|
||||||
|
// id (not symbol) that has length [i]
|
||||||
|
//
|
||||||
|
|
||||||
|
offset[_maxCodeLength] = 0; |
||||||
|
|
||||||
|
for (int i= _maxCodeLength - 1; i >= _minCodeLength; i--) |
||||||
|
offset[i] = offset[i + 1] + codeCount[i + 1]; |
||||||
|
|
||||||
|
//
|
||||||
|
// Allocate and fill the symbol-to-id mapping. Smaller Ids should be
|
||||||
|
// mapped to less-frequent symbols (which have longer codes). Use
|
||||||
|
// the offset table to tell us where the id's for a given code
|
||||||
|
// length start off.
|
||||||
|
//
|
||||||
|
|
||||||
|
_idToSymbol = new int[_numSymbols]; |
||||||
|
|
||||||
|
Int64 mapping[MAX_CODE_LEN + 1]; |
||||||
|
for (int i = 0; i < MAX_CODE_LEN + 1; ++i)
|
||||||
|
mapping[i] = -1; |
||||||
|
for (int i = _minCodeLength; i <= _maxCodeLength; ++i) |
||||||
|
mapping[i] = offset[i]; |
||||||
|
|
||||||
|
for (std::vector<Int64>::const_iterator i = symbols.begin();
|
||||||
|
i != symbols.end(); |
||||||
|
++i) |
||||||
|
{ |
||||||
|
int codeLen = *i & 63; |
||||||
|
int symbol = *i >> 6; |
||||||
|
|
||||||
|
if (mapping[codeLen] >= _numSymbols) |
||||||
|
throw IEX_NAMESPACE::InputExc ("Huffman decode error " |
||||||
|
"(Invalid symbol in header)."); |
||||||
|
|
||||||
|
_idToSymbol[mapping[codeLen]] = symbol; |
||||||
|
mapping[codeLen]++; |
||||||
|
} |
||||||
|
|
||||||
|
buildTables(base, offset); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
FastHufDecoder::~FastHufDecoder() |
||||||
|
{ |
||||||
|
delete[] _idToSymbol; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// Static check if the decoder is enabled.
|
||||||
|
//
|
||||||
|
// ATM, I only have access to little endian hardware for testing,
|
||||||
|
// so I'm not entirely sure that we are reading fom the bit stream
|
||||||
|
// properly on BE.
|
||||||
|
//
|
||||||
|
// If you happen to have more obscure hardware, check that the
|
||||||
|
// byte swapping in refill() is happening sensable, add an endian
|
||||||
|
// check if needed, and fix the preprocessor magic here.
|
||||||
|
//
|
||||||
|
|
||||||
|
#define READ64(c) \ |
||||||
|
((Int64)(c)[0] << 56) | ((Int64)(c)[1] << 48) | ((Int64)(c)[2] << 40) | \
|
||||||
|
((Int64)(c)[3] << 32) | ((Int64)(c)[4] << 24) | ((Int64)(c)[5] << 16) | \
|
||||||
|
((Int64)(c)[6] << 8) | ((Int64)(c)[7] )
|
||||||
|
|
||||||
|
#ifdef __INTEL_COMPILER // ICC built-in swap for LE hosts
|
||||||
|
#if defined (__i386__) || defined(__x86_64__) |
||||||
|
#undef READ64 |
||||||
|
#define READ64(c) _bswap64 (*(const Int64*)(c)) |
||||||
|
#endif |
||||||
|
#endif |
||||||
|
|
||||||
|
|
||||||
|
bool |
||||||
|
FastHufDecoder::enabled() |
||||||
|
{ |
||||||
|
#if defined(__INTEL_COMPILER) || defined(__GNUC__) |
||||||
|
|
||||||
|
//
|
||||||
|
// Enabled for ICC, GCC:
|
||||||
|
// __i386__ -> x86
|
||||||
|
// __x86_64__ -> 64-bit x86
|
||||||
|
//
|
||||||
|
|
||||||
|
#if defined (__i386__) || defined(__x86_64__) |
||||||
|
return true; |
||||||
|
#else |
||||||
|
return false; |
||||||
|
#endif |
||||||
|
|
||||||
|
#elif defined (_MSC_VER) |
||||||
|
|
||||||
|
//
|
||||||
|
// Enabled for Visual Studio:
|
||||||
|
// _M_IX86 -> x86
|
||||||
|
// _M_X64 -> 64bit x86
|
||||||
|
|
||||||
|
#if defined (_M_IX86) || defined(_M_X64) |
||||||
|
return true; |
||||||
|
#else |
||||||
|
return false; |
||||||
|
#endif |
||||||
|
|
||||||
|
#else |
||||||
|
|
||||||
|
//
|
||||||
|
// Unknown compiler - Be safe and disable.
|
||||||
|
//
|
||||||
|
return false; |
||||||
|
#endif |
||||||
|
} |
||||||
|
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Built the acceleration tables for lookups on the upper bits
|
||||||
|
// as well as the 'LJ' tables.
|
||||||
|
//
|
||||||
|
|
||||||
|
void |
||||||
|
FastHufDecoder::buildTables (Int64 *base, Int64 *offset) |
||||||
|
{ |
||||||
|
//
|
||||||
|
// Build the 'left justified' base table, by shifting base left..
|
||||||
|
//
|
||||||
|
|
||||||
|
for (int i = 0; i <= MAX_CODE_LEN; ++i) |
||||||
|
{ |
||||||
|
if (base[i] != 0xffffffffffffffffULL) |
||||||
|
{ |
||||||
|
_ljBase[i] = base[i] << (64 - i); |
||||||
|
} |
||||||
|
else |
||||||
|
{ |
||||||
|
//
|
||||||
|
// Unused code length - insert dummy values
|
||||||
|
//
|
||||||
|
|
||||||
|
_ljBase[i] = 0xffffffffffffffffULL; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
//
|
||||||
|
// Combine some terms into a big fat constant, which for
|
||||||
|
// lack of a better term we'll call the 'left justified'
|
||||||
|
// offset table (because it serves the same function
|
||||||
|
// as 'offset', when using the left justified base table.
|
||||||
|
//
|
||||||
|
|
||||||
|
for (int i = 0; i <= MAX_CODE_LEN; ++i) |
||||||
|
_ljOffset[i] = offset[i] - (_ljBase[i] >> (64 - i)); |
||||||
|
|
||||||
|
//
|
||||||
|
// Build the acceleration tables for the lookups of
|
||||||
|
// short codes ( <= TABLE_LOOKUP_BITS long)
|
||||||
|
//
|
||||||
|
|
||||||
|
for (Int64 i = 0; i < 1 << TABLE_LOOKUP_BITS; ++i) |
||||||
|
{ |
||||||
|
Int64 value = i << (64 - TABLE_LOOKUP_BITS); |
||||||
|
|
||||||
|
_tableSymbol[i] = 0xffff; |
||||||
|
_tableCodeLen[i] = 0;
|
||||||
|
|
||||||
|
for (int codeLen = _minCodeLength; codeLen <= _maxCodeLength; ++codeLen) |
||||||
|
{ |
||||||
|
if (_ljBase[codeLen] <= value) |
||||||
|
{ |
||||||
|
_tableCodeLen[i] = codeLen; |
||||||
|
|
||||||
|
Int64 id = _ljOffset[codeLen] + (value >> (64 - codeLen)); |
||||||
|
if (id < _numSymbols) |
||||||
|
{ |
||||||
|
_tableSymbol[i] = _idToSymbol[id]; |
||||||
|
} |
||||||
|
else |
||||||
|
{ |
||||||
|
throw IEX_NAMESPACE::InputExc ("Huffman decode error " |
||||||
|
"(Overrun)."); |
||||||
|
} |
||||||
|
break; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
//
|
||||||
|
// Store the smallest value in the table that points to real data.
|
||||||
|
// This should be the entry for the largest length that has
|
||||||
|
// valid data (in our case, non-dummy _ljBase)
|
||||||
|
//
|
||||||
|
|
||||||
|
int minIdx = TABLE_LOOKUP_BITS; |
||||||
|
|
||||||
|
while (minIdx > 0 && _ljBase[minIdx] == 0xffffffffffffffffULL) |
||||||
|
minIdx--; |
||||||
|
|
||||||
|
if (minIdx < 0) |
||||||
|
{ |
||||||
|
//
|
||||||
|
// Error, no codes with lengths 0-TABLE_LOOKUP_BITS used.
|
||||||
|
// Set the min value such that the table is never tested.
|
||||||
|
//
|
||||||
|
|
||||||
|
_tableMin = 0xffffffffffffffffULL; |
||||||
|
} |
||||||
|
else |
||||||
|
{ |
||||||
|
_tableMin = _ljBase[minIdx]; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// For decoding, we're holding onto 2 Int64's.
|
||||||
|
//
|
||||||
|
// The first (buffer), holds the next bits from the bitstream to be
|
||||||
|
// decoded. For certain paths in the decoder, we only need TABLE_LOOKUP_BITS
|
||||||
|
// valid bits to decode the next symbol. For other paths, we need a full
|
||||||
|
// 64-bits to decode a symbol.
|
||||||
|
//
|
||||||
|
// When we need to refill 'buffer', we could pull bits straight from
|
||||||
|
// the bitstream. But this is very slow and requires lots of book keeping
|
||||||
|
// (what's the next bit in the next byte?). Instead, we keep another Int64
|
||||||
|
// around that we use to refill from. While this doesn't cut down on the
|
||||||
|
// book keeping (still need to know how many valid bits), it does cut
|
||||||
|
// down on some of the bit shifting crazy and byte access.
|
||||||
|
//
|
||||||
|
// The refill Int64 (bufferBack) gets left-shifted after we've pulled
|
||||||
|
// off bits. If we run out of bits in the input bit stream, we just
|
||||||
|
// shift in 0's to bufferBack.
|
||||||
|
//
|
||||||
|
// The refill act takes numBits from the top of bufferBack and sticks
|
||||||
|
// them in the bottom of buffer. If there arn't enough bits in bufferBack,
|
||||||
|
// it gets refilled (to 64-bits) from the input bitstream.
|
||||||
|
//
|
||||||
|
|
||||||
|
inline void |
||||||
|
FastHufDecoder::refill |
||||||
|
(Int64 &buffer, |
||||||
|
int numBits, // number of bits to refill
|
||||||
|
Int64 &bufferBack, // the next 64-bits, to refill from
|
||||||
|
int &bufferBackNumBits, // number of bits left in bufferBack
|
||||||
|
const unsigned char *&currByte, // current byte in the bitstream
|
||||||
|
int &currBitsLeft) // number of bits left in the bitsream
|
||||||
|
{ |
||||||
|
//
|
||||||
|
// Refill bits into the bottom of buffer, from the top of bufferBack.
|
||||||
|
// Always top up buffer to be completely full.
|
||||||
|
//
|
||||||
|
|
||||||
|
buffer |= bufferBack >> (64 - numBits); |
||||||
|
|
||||||
|
if (bufferBackNumBits < numBits) |
||||||
|
{ |
||||||
|
numBits -= bufferBackNumBits; |
||||||
|
|
||||||
|
//
|
||||||
|
// Refill all of bufferBack from the bitstream. Either grab
|
||||||
|
// a full 64-bit chunk, or whatever bytes are left. If we
|
||||||
|
// don't have 64-bits left, pad with 0's.
|
||||||
|
//
|
||||||
|
|
||||||
|
if (currBitsLeft >= 64) |
||||||
|
{ |
||||||
|
bufferBack = READ64 (currByte);
|
||||||
|
bufferBackNumBits = 64; |
||||||
|
currByte += sizeof (Int64); |
||||||
|
currBitsLeft -= 8 * sizeof (Int64); |
||||||
|
|
||||||
|
} |
||||||
|
else |
||||||
|
{ |
||||||
|
bufferBack = 0; |
||||||
|
bufferBackNumBits = 64;
|
||||||
|
|
||||||
|
Int64 shift = 56; |
||||||
|
|
||||||
|
while (currBitsLeft > 0) |
||||||
|
{ |
||||||
|
bufferBack |= ((Int64)(*currByte)) << shift; |
||||||
|
|
||||||
|
currByte++; |
||||||
|
shift -= 8; |
||||||
|
currBitsLeft -= 8; |
||||||
|
} |
||||||
|
|
||||||
|
//
|
||||||
|
// At this point, currBitsLeft might be negative, just because
|
||||||
|
// we're subtracting whole bytes. To keep anyone from freaking
|
||||||
|
// out, zero the counter.
|
||||||
|
//
|
||||||
|
|
||||||
|
if (currBitsLeft < 0) |
||||||
|
currBitsLeft = 0; |
||||||
|
} |
||||||
|
|
||||||
|
buffer |= bufferBack >> (64 - numBits); |
||||||
|
} |
||||||
|
|
||||||
|
bufferBack = bufferBack << numBits; |
||||||
|
bufferBackNumBits -= numBits; |
||||||
|
|
||||||
|
//
|
||||||
|
// We can have cases where the previous shift of bufferBack is << 64 -
|
||||||
|
// in which case no shift occurs. The bit count math still works though,
|
||||||
|
// so if we don't have any bits left, zero out bufferBack.
|
||||||
|
//
|
||||||
|
|
||||||
|
if (bufferBackNumBits == 0) |
||||||
|
bufferBack = 0; |
||||||
|
} |
||||||
|
|
||||||
|
//
|
||||||
|
// Read the next few bits out of a bitstream. Will be given a backing buffer
|
||||||
|
// (buffer) that may still have data left over from previous reads
|
||||||
|
// (bufferNumBits). Bitstream pointer (currByte) will be advanced when needed.
|
||||||
|
//
|
||||||
|
|
||||||
|
inline Int64
|
||||||
|
FastHufDecoder::readBits |
||||||
|
(int numBits, |
||||||
|
Int64 &buffer, // c
|
||||||
|
int &bufferNumBits, // lc
|
||||||
|
const char *&currByte) // in
|
||||||
|
{ |
||||||
|
while (bufferNumBits < numBits) |
||||||
|
{ |
||||||
|
buffer = (buffer << 8) | *(unsigned char*)(currByte++); |
||||||
|
bufferNumBits += 8; |
||||||
|
} |
||||||
|
|
||||||
|
bufferNumBits -= numBits; |
||||||
|
return (buffer >> bufferNumBits) & ((1 << numBits) - 1); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// Decode using a the 'One-Shift' strategy for decoding, with a
|
||||||
|
// small-ish table to accelerate decoding of short codes.
|
||||||
|
//
|
||||||
|
// If possible, try looking up codes into the acceleration table.
|
||||||
|
// This has a few benifits - there's no search involved; We don't
|
||||||
|
// need an additional lookup to map id to symbol; we don't need
|
||||||
|
// a full 64-bits (so less refilling).
|
||||||
|
//
|
||||||
|
|
||||||
|
void |
||||||
|
FastHufDecoder::decode |
||||||
|
(const unsigned char *src, |
||||||
|
int numSrcBits, |
||||||
|
unsigned short *dst,
|
||||||
|
int numDstElems) |
||||||
|
{ |
||||||
|
if (numSrcBits < 128) |
||||||
|
throw IEX_NAMESPACE::InputExc ("Error choosing Huffman decoder implementation " |
||||||
|
"(insufficient number of bits)."); |
||||||
|
|
||||||
|
//
|
||||||
|
// Current position (byte/bit) in the src data stream
|
||||||
|
// (after the first buffer fill)
|
||||||
|
//
|
||||||
|
|
||||||
|
const unsigned char *currByte = src + 2 * sizeof (Int64); |
||||||
|
|
||||||
|
numSrcBits -= 8 * 2 * sizeof (Int64); |
||||||
|
|
||||||
|
//
|
||||||
|
// 64-bit buffer holding the current bits in the stream
|
||||||
|
//
|
||||||
|
|
||||||
|
Int64 buffer = READ64 (src);
|
||||||
|
int bufferNumBits = 64; |
||||||
|
|
||||||
|
//
|
||||||
|
// 64-bit buffer holding the next bits in the stream
|
||||||
|
//
|
||||||
|
|
||||||
|
Int64 bufferBack = READ64 ((src + sizeof (Int64)));
|
||||||
|
int bufferBackNumBits = 64; |
||||||
|
|
||||||
|
int dstIdx = 0; |
||||||
|
|
||||||
|
while (dstIdx < numDstElems) |
||||||
|
{ |
||||||
|
int codeLen; |
||||||
|
int symbol; |
||||||
|
|
||||||
|
//
|
||||||
|
// Test if we can be table accelerated. If so, directly
|
||||||
|
// lookup the output symbol. Otherwise, we need to fall
|
||||||
|
// back to searching for the code.
|
||||||
|
//
|
||||||
|
// If we're doing table lookups, we don't really need
|
||||||
|
// a re-filled buffer, so long as we have TABLE_LOOKUP_BITS
|
||||||
|
// left. But for a search, we do need a refilled table.
|
||||||
|
//
|
||||||
|
|
||||||
|
if (_tableMin <= buffer) |
||||||
|
{ |
||||||
|
int tableIdx = buffer >> (64 - TABLE_LOOKUP_BITS); |
||||||
|
|
||||||
|
//
|
||||||
|
// For invalid codes, _tableCodeLen[] should return 0. This
|
||||||
|
// will cause the decoder to get stuck in the current spot
|
||||||
|
// until we run out of elements, then barf that the codestream
|
||||||
|
// is bad. So we don't need to stick a condition like
|
||||||
|
// if (codeLen > _maxCodeLength) in this inner.
|
||||||
|
//
|
||||||
|
|
||||||
|
codeLen = _tableCodeLen[tableIdx]; |
||||||
|
symbol = _tableSymbol[tableIdx]; |
||||||
|
} |
||||||
|
else |
||||||
|
{ |
||||||
|
if (bufferNumBits < 64) |
||||||
|
{ |
||||||
|
refill (buffer, |
||||||
|
64 - bufferNumBits, |
||||||
|
bufferBack, |
||||||
|
bufferBackNumBits, |
||||||
|
currByte, |
||||||
|
numSrcBits); |
||||||
|
|
||||||
|
bufferNumBits = 64; |
||||||
|
} |
||||||
|
|
||||||
|
//
|
||||||
|
// Brute force search:
|
||||||
|
// Find the smallest length where _ljBase[length] <= buffer
|
||||||
|
//
|
||||||
|
|
||||||
|
codeLen = TABLE_LOOKUP_BITS + 1; |
||||||
|
|
||||||
|
while (_ljBase[codeLen] > buffer && codeLen <= _maxCodeLength) |
||||||
|
codeLen++; |
||||||
|
|
||||||
|
if (codeLen > _maxCodeLength) |
||||||
|
{ |
||||||
|
throw IEX_NAMESPACE::InputExc ("Huffman decode error " |
||||||
|
"(Decoded an invalid symbol)."); |
||||||
|
} |
||||||
|
|
||||||
|
Int64 id = _ljOffset[codeLen] + (buffer >> (64 - codeLen)); |
||||||
|
if (id < _numSymbols) |
||||||
|
{ |
||||||
|
symbol = _idToSymbol[id]; |
||||||
|
} |
||||||
|
else |
||||||
|
{ |
||||||
|
throw IEX_NAMESPACE::InputExc ("Huffman decode error " |
||||||
|
"(Decoded an invalid symbol)."); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
//
|
||||||
|
// Shift over bit stream, and update the bit count in the buffer
|
||||||
|
//
|
||||||
|
|
||||||
|
buffer = buffer << codeLen; |
||||||
|
bufferNumBits -= codeLen; |
||||||
|
|
||||||
|
//
|
||||||
|
// If we recieved a RLE symbol (_rleSymbol), then we need
|
||||||
|
// to read ahead 8 bits to know how many times to repeat
|
||||||
|
// the previous symbol. Need to ensure we at least have
|
||||||
|
// 8 bits of data in the buffer
|
||||||
|
//
|
||||||
|
|
||||||
|
if (symbol == _rleSymbol) |
||||||
|
{ |
||||||
|
if (bufferNumBits < 8) |
||||||
|
{ |
||||||
|
refill (buffer, |
||||||
|
64 - bufferNumBits, |
||||||
|
bufferBack, |
||||||
|
bufferBackNumBits, |
||||||
|
currByte, |
||||||
|
numSrcBits); |
||||||
|
|
||||||
|
bufferNumBits = 64; |
||||||
|
} |
||||||
|
|
||||||
|
int rleCount = buffer >> 56; |
||||||
|
|
||||||
|
if (dstIdx < 1) |
||||||
|
{ |
||||||
|
throw IEX_NAMESPACE::InputExc ("Huffman decode error (RLE code " |
||||||
|
"with no previous symbol)."); |
||||||
|
} |
||||||
|
|
||||||
|
if (dstIdx + rleCount > numDstElems) |
||||||
|
{ |
||||||
|
throw IEX_NAMESPACE::InputExc ("Huffman decode error (Symbol run " |
||||||
|
"beyond expected output buffer length)."); |
||||||
|
} |
||||||
|
|
||||||
|
if (rleCount <= 0)
|
||||||
|
{ |
||||||
|
throw IEX_NAMESPACE::InputExc("Huffman decode error" |
||||||
|
" (Invalid RLE length)"); |
||||||
|
} |
||||||
|
|
||||||
|
for (int i = 0; i < rleCount; ++i) |
||||||
|
dst[dstIdx + i] = dst[dstIdx - 1]; |
||||||
|
|
||||||
|
dstIdx += rleCount; |
||||||
|
|
||||||
|
buffer = buffer << 8; |
||||||
|
bufferNumBits -= 8; |
||||||
|
} |
||||||
|
else |
||||||
|
{ |
||||||
|
dst[dstIdx] = symbol; |
||||||
|
dstIdx++; |
||||||
|
} |
||||||
|
|
||||||
|
//
|
||||||
|
// refill bit stream buffer if we're below the number of
|
||||||
|
// bits needed for a table lookup
|
||||||
|
//
|
||||||
|
|
||||||
|
if (bufferNumBits < TABLE_LOOKUP_BITS) |
||||||
|
{ |
||||||
|
refill (buffer, |
||||||
|
64 - bufferNumBits, |
||||||
|
bufferBack, |
||||||
|
bufferBackNumBits, |
||||||
|
currByte, |
||||||
|
numSrcBits); |
||||||
|
|
||||||
|
bufferNumBits = 64; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
if (numSrcBits != 0) |
||||||
|
{ |
||||||
|
throw IEX_NAMESPACE::InputExc ("Huffman decode error (Compressed data remains " |
||||||
|
"after filling expected output buffer)."); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_EXIT |
@ -0,0 +1,153 @@ |
|||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Copyright (c) 2009-2014 DreamWorks Animation LLC.
|
||||||
|
//
|
||||||
|
// All rights reserved.
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without
|
||||||
|
// modification, are permitted provided that the following conditions are
|
||||||
|
// met:
|
||||||
|
// * Redistributions of source code must retain the above copyright
|
||||||
|
// notice, this list of conditions and the following disclaimer.
|
||||||
|
// * Redistributions in binary form must reproduce the above
|
||||||
|
// copyright notice, this list of conditions and the following disclaimer
|
||||||
|
// in the documentation and/or other materials provided with the
|
||||||
|
// distribution.
|
||||||
|
// * Neither the name of DreamWorks Animation nor the names of
|
||||||
|
// its contributors may be used to endorse or promote products derived
|
||||||
|
// from this software without specific prior written permission.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
//
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifndef INCLUDED_IMF_FAST_HUF_H |
||||||
|
#define INCLUDED_IMF_FAST_HUF_H |
||||||
|
|
||||||
|
#include "ImfInt64.h" |
||||||
|
#include "ImfNamespace.h" |
||||||
|
#include "ImfExport.h" |
||||||
|
|
||||||
|
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER |
||||||
|
|
||||||
|
//
|
||||||
|
// Alternative Canonical Huffman decoder:
|
||||||
|
//
|
||||||
|
// Canonical Huffman decoder based on 'On the Implementation of Minimum
|
||||||
|
// Redundancy Prefix Codes' by Moffat and Turpin - highly recommended
|
||||||
|
// reading as a good description of the problem space, as well as
|
||||||
|
// a fast decoding algorithm.
|
||||||
|
//
|
||||||
|
// The premise is that instead of working directly with the coded
|
||||||
|
// symbols, we create a new ordering based on the frequency of symbols.
|
||||||
|
// Less frequent symbols (and thus longer codes) are ordered earler.
|
||||||
|
// We're calling the values in this ordering 'Ids', as oppsed to
|
||||||
|
// 'Symbols' - which are the short values we eventually want decoded.
|
||||||
|
//
|
||||||
|
// With this new ordering, a few small tables can be derived ('base'
|
||||||
|
// and 'offset') which drive the decoding. To cut down on the
|
||||||
|
// linear scanning of these tables, you can add a small table
|
||||||
|
// to directly look up short codes (as you might in a traditional
|
||||||
|
// lookup-table driven decoder).
|
||||||
|
//
|
||||||
|
// The decoder is meant to be compatible with the encoder (and decoder)
|
||||||
|
// in ImfHuf.cpp, just faster. For ease of implementation, this decoder
|
||||||
|
// should only be used on compressed bitstreams >= 128 bits long.
|
||||||
|
//
|
||||||
|
|
||||||
|
class FastHufDecoder |
||||||
|
{ |
||||||
|
public: |
||||||
|
|
||||||
|
//
|
||||||
|
// Longest compressed code length that ImfHuf supports (58 bits)
|
||||||
|
//
|
||||||
|
|
||||||
|
static const int MAX_CODE_LEN = 58; |
||||||
|
|
||||||
|
//
|
||||||
|
// Number of bits in our acceleration table. Should match all
|
||||||
|
// codes up to TABLE_LOOKUP_BITS in length.
|
||||||
|
//
|
||||||
|
|
||||||
|
static const int TABLE_LOOKUP_BITS = 12; |
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
FastHufDecoder (const char*& table, |
||||||
|
int numBytes, |
||||||
|
int minSymbol, |
||||||
|
int maxSymbol, |
||||||
|
int rleSymbol); |
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
~FastHufDecoder (); |
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
static bool enabled (); |
||||||
|
|
||||||
|
IMF_EXPORT |
||||||
|
void decode (const unsigned char *src, |
||||||
|
int numSrcBits, |
||||||
|
unsigned short *dst, |
||||||
|
int numDstElems); |
||||||
|
|
||||||
|
private: |
||||||
|
|
||||||
|
void buildTables (Int64*, Int64*); |
||||||
|
void refill (Int64&, int, Int64&, int&, const unsigned char *&, int&); |
||||||
|
Int64 readBits (int, Int64&, int&, const char *&); |
||||||
|
|
||||||
|
int _rleSymbol; // RLE symbol written by the encoder.
|
||||||
|
// This could be 65536, so beware
|
||||||
|
// when you use shorts to hold things.
|
||||||
|
|
||||||
|
int _numSymbols; // Number of symbols in the codebook.
|
||||||
|
|
||||||
|
unsigned char _minCodeLength; // Minimum code length, in bits.
|
||||||
|
unsigned char _maxCodeLength; // Maximum code length, in bits.
|
||||||
|
|
||||||
|
int *_idToSymbol; // Maps Ids to symbols. Ids are a symbol
|
||||||
|
// ordering sorted first in terms of
|
||||||
|
// code length, and by code within
|
||||||
|
// the same length. Ids run from 0
|
||||||
|
// to mNumSymbols-1.
|
||||||
|
|
||||||
|
Int64 _ljBase[MAX_CODE_LEN + 1]; // the 'left justified base' table.
|
||||||
|
// Takes base[i] (i = code length)
|
||||||
|
// and 'left justifies' it into an Int64
|
||||||
|
|
||||||
|
Int64 _ljOffset[MAX_CODE_LEN +1 ]; // There are some other terms that can
|
||||||
|
// be folded into constants when taking
|
||||||
|
// the 'left justified' decode path. This
|
||||||
|
// holds those constants, indexed by
|
||||||
|
// code length
|
||||||
|
|
||||||
|
//
|
||||||
|
// We can accelerate the 'left justified' processing by running the
|
||||||
|
// top TABLE_LOOKUP_BITS through a LUT, to find the symbol and code
|
||||||
|
// length. These are those acceleration tables.
|
||||||
|
//
|
||||||
|
// Even though our evental 'symbols' are ushort's, the encoder adds
|
||||||
|
// a symbol to indicate RLE. So with a dense code book, we could
|
||||||
|
// have 2^16+1 codes, so both mIdToSymbol and mTableSymbol need
|
||||||
|
// to be bigger than 16 bits.
|
||||||
|
//
|
||||||
|
|
||||||
|
int _tableSymbol[1 << TABLE_LOOKUP_BITS]; |
||||||
|
unsigned char _tableCodeLen[1 << TABLE_LOOKUP_BITS]; |
||||||
|
Int64 _tableMin; |
||||||
|
}; |
||||||
|
|
||||||
|
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT |
||||||
|
|
||||||
|
#endif |
@ -0,0 +1,76 @@ |
|||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Copyright (c) 2007, Weta Digital Ltd
|
||||||
|
//
|
||||||
|
// All rights reserved.
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without
|
||||||
|
// modification, are permitted provided that the following conditions are
|
||||||
|
// met:
|
||||||
|
// * Redistributions of source code must retain the above copyright
|
||||||
|
// notice, this list of conditions and the following disclaimer.
|
||||||
|
// * Redistributions in binary form must reproduce the above
|
||||||
|
// copyright notice, this list of conditions and the following disclaimer
|
||||||
|
// in the documentation and/or other materials provided with the
|
||||||
|
// distribution.
|
||||||
|
// * Neither the name of Weta Digital nor the names of
|
||||||
|
// its contributors may be used to endorse or promote products derived
|
||||||
|
// from this software without specific prior written permission.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
//
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef INCLUDED_IMF_FLOATVECTOR_ATTRIBUTE_H |
||||||
|
#define INCLUDED_IMF_FLOATVECTOR_ATTRIBUTE_H |
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// class FloatVectorAttribute
|
||||||
|
//
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#include "ImfAttribute.h" |
||||||
|
#include "ImfNamespace.h" |
||||||
|
|
||||||
|
#include <vector> |
||||||
|
|
||||||
|
|
||||||
|
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER |
||||||
|
|
||||||
|
typedef std::vector<float> |
||||||
|
FloatVector; |
||||||
|
|
||||||
|
typedef TypedAttribute<OPENEXR_IMF_INTERNAL_NAMESPACE::FloatVector> |
||||||
|
FloatVectorAttribute; |
||||||
|
|
||||||
|
template <> |
||||||
|
IMF_EXPORT |
||||||
|
const char *FloatVectorAttribute::staticTypeName (); |
||||||
|
|
||||||
|
template <> |
||||||
|
IMF_EXPORT |
||||||
|
void FloatVectorAttribute::writeValueTo |
||||||
|
(OPENEXR_IMF_INTERNAL_NAMESPACE::OStream &, int) const; |
||||||
|
|
||||||
|
template <> |
||||||
|
IMF_EXPORT |
||||||
|
void FloatVectorAttribute::readValueFrom |
||||||
|
(OPENEXR_IMF_INTERNAL_NAMESPACE::IStream &, int, int); |
||||||
|
|
||||||
|
|
||||||
|
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT |
||||||
|
|
||||||
|
#endif |
@ -0,0 +1,127 @@ |
|||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Copyright (c) 2011, Industrial Light & Magic, a division of Lucas
|
||||||
|
// Digital Ltd. LLC
|
||||||
|
//
|
||||||
|
// Portions (c) 2012 Weta Digital Ltd
|
||||||
|
//
|
||||||
|
// All rights reserved.
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without
|
||||||
|
// modification, are permitted provided that the following conditions are
|
||||||
|
// met:
|
||||||
|
// * Redistributions of source code must retain the above copyright
|
||||||
|
// notice, this list of conditions and the following disclaimer.
|
||||||
|
// * Redistributions in binary form must reproduce the above
|
||||||
|
// copyright notice, this list of conditions and the following disclaimer
|
||||||
|
// in the documentation and/or other materials provided with the
|
||||||
|
// distribution.
|
||||||
|
// * Neither the name of Industrial Light & Magic nor the names of
|
||||||
|
// its contributors may be used to endorse or promote products derived
|
||||||
|
// from this software without specific prior written permission.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
//
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifndef INCLUDED_IMF_FORWARD_H |
||||||
|
#define INCLUDED_IMF_FORWARD_H |
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Forward declarations for OpenEXR - correctly declares namespace
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include "ImfNamespace.h" |
||||||
|
|
||||||
|
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER |
||||||
|
|
||||||
|
|
||||||
|
// classes for basic types;
|
||||||
|
template<class T> class Array; |
||||||
|
template<class T> class Array2D; |
||||||
|
struct Channel; |
||||||
|
class ChannelList; |
||||||
|
struct Chromaticities; |
||||||
|
|
||||||
|
// attributes used in headers are TypedAttributes
|
||||||
|
class Attribute; |
||||||
|
|
||||||
|
class Header; |
||||||
|
|
||||||
|
// file handling classes
|
||||||
|
class OutputFile; |
||||||
|
class TiledInputFile; |
||||||
|
class ScanLineInputFile; |
||||||
|
class InputFile; |
||||||
|
class TiledOutputFile; |
||||||
|
class DeepScanLineInputFile; |
||||||
|
class DeepScanLineOutputFile; |
||||||
|
class DeepTiledInputFile; |
||||||
|
class DeepTiledOutputFile; |
||||||
|
class AcesInputFile; |
||||||
|
class AcesOutputFile; |
||||||
|
class TiledInputPart; |
||||||
|
class TiledInputFile; |
||||||
|
class TileOffsets; |
||||||
|
|
||||||
|
// multipart file handling
|
||||||
|
class GenericInputFile; |
||||||
|
class GenericOutputFile; |
||||||
|
class MultiPartInputFile; |
||||||
|
class MultiPartOutputFile; |
||||||
|
|
||||||
|
class InputPart; |
||||||
|
class TiledInputPart; |
||||||
|
class DeepScanLineInputPart; |
||||||
|
class DeepTiledInputPart; |
||||||
|
|
||||||
|
class OutputPart; |
||||||
|
class ScanLineOutputPart; |
||||||
|
class TiledOutputPart; |
||||||
|
class DeepScanLineOutputPart; |
||||||
|
class DeepTiledOutputPart; |
||||||
|
|
||||||
|
|
||||||
|
// internal use only
|
||||||
|
struct InputPartData; |
||||||
|
struct OutputStreamMutex; |
||||||
|
struct OutputPartData; |
||||||
|
struct InputStreamMutex; |
||||||
|
|
||||||
|
// frame buffers
|
||||||
|
|
||||||
|
class FrameBuffer; |
||||||
|
class DeepFrameBuffer; |
||||||
|
struct DeepSlice; |
||||||
|
|
||||||
|
// compositing
|
||||||
|
class DeepCompositing; |
||||||
|
class CompositeDeepScanLine; |
||||||
|
|
||||||
|
// preview image
|
||||||
|
class PreviewImage; |
||||||
|
struct PreviewRgba; |
||||||
|
|
||||||
|
// streams
|
||||||
|
class OStream; |
||||||
|
class IStream; |
||||||
|
|
||||||
|
|
||||||
|
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT |
||||||
|
|
||||||
|
|
||||||
|
#endif // include guard
|
@ -0,0 +1,76 @@ |
|||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Copyright (c) 2011, Industrial Light & Magic, a division of Lucas
|
||||||
|
// Digital Ltd. LLC
|
||||||
|
//
|
||||||
|
// All rights reserved.
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without
|
||||||
|
// modification, are permitted provided that the following conditions are
|
||||||
|
// met:
|
||||||
|
// * Redistributions of source code must retain the above copyright
|
||||||
|
// notice, this list of conditions and the following disclaimer.
|
||||||
|
// * Redistributions in binary form must reproduce the above
|
||||||
|
// copyright notice, this list of conditions and the following disclaimer
|
||||||
|
// in the documentation and/or other materials provided with the
|
||||||
|
// distribution.
|
||||||
|
// * Neither the name of Industrial Light & Magic nor the names of
|
||||||
|
// its contributors may be used to endorse or promote products derived
|
||||||
|
// from this software without specific prior written permission.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
//
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include "ImfGenericInputFile.h" |
||||||
|
|
||||||
|
#include <ImfVersion.h> |
||||||
|
#include <ImfXdr.h> |
||||||
|
#include <Iex.h> |
||||||
|
#include <OpenEXRConfig.h> |
||||||
|
|
||||||
|
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_ENTER |
||||||
|
|
||||||
|
void GenericInputFile::readMagicNumberAndVersionField(OPENEXR_IMF_INTERNAL_NAMESPACE::IStream& is, int& version) |
||||||
|
{ |
||||||
|
//
|
||||||
|
// Read the magic number and the file format version number.
|
||||||
|
// Then check if we can read the rest of this file.
|
||||||
|
//
|
||||||
|
|
||||||
|
int magic; |
||||||
|
|
||||||
|
OPENEXR_IMF_INTERNAL_NAMESPACE::Xdr::read <OPENEXR_IMF_INTERNAL_NAMESPACE::StreamIO> (is, magic); |
||||||
|
OPENEXR_IMF_INTERNAL_NAMESPACE::Xdr::read <OPENEXR_IMF_INTERNAL_NAMESPACE::StreamIO> (is, version); |
||||||
|
|
||||||
|
if (magic != MAGIC) |
||||||
|
{ |
||||||
|
throw IEX_NAMESPACE::InputExc ("File is not an image file."); |
||||||
|
} |
||||||
|
|
||||||
|
if (getVersion (version) != EXR_VERSION) |
||||||
|
{ |
||||||
|
THROW (IEX_NAMESPACE::InputExc, "Cannot read " |
||||||
|
"version " << getVersion (version) << " " |
||||||
|
"image files. Current file format version " |
||||||
|
"is " << EXR_VERSION << "."); |
||||||
|
} |
||||||
|
|
||||||
|
if (!supportsFlags (getFlags (version))) |
||||||
|
{ |
||||||
|
THROW (IEX_NAMESPACE::InputExc, "The file format version number's flag field " |
||||||
|
"contains unrecognized flags."); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_EXIT |
@ -0,0 +1,61 @@ |
|||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Copyright (c) 2011, Industrial Light & Magic, a division of Lucas
|
||||||
|
// Digital Ltd. LLC
|
||||||
|
//
|
||||||
|
// All rights reserved.
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without
|
||||||
|
// modification, are permitted provided that the following conditions are
|
||||||
|
// met:
|
||||||
|
// * Redistributions of source code must retain the above copyright
|
||||||
|
// notice, this list of conditions and the following disclaimer.
|
||||||
|
// * Redistributions in binary form must reproduce the above
|
||||||
|
// copyright notice, this list of conditions and the following disclaimer
|
||||||
|
// in the documentation and/or other materials provided with the
|
||||||
|
// distribution.
|
||||||
|
// * Neither the name of Industrial Light & Magic nor the names of
|
||||||
|
// its contributors may be used to endorse or promote products derived
|
||||||
|
// from this software without specific prior written permission.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
//
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifndef IMFGENERICINPUTFILE_H_ |
||||||
|
#define IMFGENERICINPUTFILE_H_ |
||||||
|
|
||||||
|
#include "ImfIO.h" |
||||||
|
#include "ImfHeader.h" |
||||||
|
#include "ImfNamespace.h" |
||||||
|
#include "ImfExport.h" |
||||||
|
|
||||||
|
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER |
||||||
|
|
||||||
|
class GenericInputFile |
||||||
|
{ |
||||||
|
public: |
||||||
|
IMF_EXPORT |
||||||
|
virtual ~GenericInputFile() {} |
||||||
|
|
||||||
|
protected: |
||||||
|
IMF_EXPORT |
||||||
|
GenericInputFile() {} |
||||||
|
IMF_EXPORT |
||||||
|
void readMagicNumberAndVersionField(OPENEXR_IMF_INTERNAL_NAMESPACE::IStream& is, int& version); |
||||||
|
}; |
||||||
|
|
||||||
|
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT |
||||||
|
|
||||||
|
|
||||||
|
#endif /* IMFGENERICINPUTFILE_H_ */ |
@ -0,0 +1,112 @@ |
|||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Copyright (c) 2011, Industrial Light & Magic, a division of Lucas
|
||||||
|
// Digital Ltd. LLC
|
||||||
|
//
|
||||||
|
// All rights reserved.
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without
|
||||||
|
// modification, are permitted provided that the following conditions are
|
||||||
|
// met:
|
||||||
|
// * Redistributions of source code must retain the above copyright
|
||||||
|
// notice, this list of conditions and the following disclaimer.
|
||||||
|
// * Redistributions in binary form must reproduce the above
|
||||||
|
// copyright notice, this list of conditions and the following disclaimer
|
||||||
|
// in the documentation and/or other materials provided with the
|
||||||
|
// distribution.
|
||||||
|
// * Neither the name of Industrial Light & Magic nor the names of
|
||||||
|
// its contributors may be used to endorse or promote products derived
|
||||||
|
// from this software without specific prior written permission.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
//
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include "ImfGenericOutputFile.h" |
||||||
|
|
||||||
|
#include <ImfBoxAttribute.h> |
||||||
|
#include <ImfFloatAttribute.h> |
||||||
|
#include <ImfTimeCodeAttribute.h> |
||||||
|
#include <ImfChromaticitiesAttribute.h> |
||||||
|
|
||||||
|
#include <ImfMisc.h> |
||||||
|
#include <ImfPartType.h> |
||||||
|
|
||||||
|
#include "ImfNamespace.h" |
||||||
|
|
||||||
|
|
||||||
|
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_ENTER |
||||||
|
|
||||||
|
|
||||||
|
using namespace std; |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void |
||||||
|
GenericOutputFile::writeMagicNumberAndVersionField (OPENEXR_IMF_INTERNAL_NAMESPACE::OStream& os, |
||||||
|
const Header& header) |
||||||
|
{ |
||||||
|
OPENEXR_IMF_INTERNAL_NAMESPACE::Xdr::write <OPENEXR_IMF_INTERNAL_NAMESPACE::StreamIO> (os, MAGIC); |
||||||
|
|
||||||
|
int version = EXR_VERSION; |
||||||
|
|
||||||
|
if (header.hasType() && isDeepData(header.type())) |
||||||
|
{ |
||||||
|
version |= NON_IMAGE_FLAG; |
||||||
|
} |
||||||
|
else |
||||||
|
{ |
||||||
|
// (TODO) we may want to check something else in function signature
|
||||||
|
// instead of hasTileDescription()?
|
||||||
|
if (header.hasTileDescription()) |
||||||
|
version |= TILED_FLAG; |
||||||
|
} |
||||||
|
|
||||||
|
if (usesLongNames (header)) |
||||||
|
version |= LONG_NAMES_FLAG; |
||||||
|
|
||||||
|
OPENEXR_IMF_INTERNAL_NAMESPACE::Xdr::write <OPENEXR_IMF_INTERNAL_NAMESPACE::StreamIO> (os, version); |
||||||
|
} |
||||||
|
|
||||||
|
void |
||||||
|
GenericOutputFile::writeMagicNumberAndVersionField (OPENEXR_IMF_INTERNAL_NAMESPACE::OStream& os, |
||||||
|
const Header * headers, |
||||||
|
int parts) |
||||||
|
{ |
||||||
|
OPENEXR_IMF_INTERNAL_NAMESPACE::Xdr::write <OPENEXR_IMF_INTERNAL_NAMESPACE::StreamIO> (os, MAGIC); |
||||||
|
|
||||||
|
int version = EXR_VERSION; |
||||||
|
|
||||||
|
if (parts == 1) |
||||||
|
{ |
||||||
|
if (headers[0].type() == TILEDIMAGE) |
||||||
|
version |= TILED_FLAG; |
||||||
|
} |
||||||
|
else |
||||||
|
{ |
||||||
|
version |= MULTI_PART_FILE_FLAG; |
||||||
|
} |
||||||
|
|
||||||
|
for (int i = 0; i < parts; i++) |
||||||
|
{ |
||||||
|
if (usesLongNames (headers[i])) |
||||||
|
version |= LONG_NAMES_FLAG; |
||||||
|
|
||||||
|
if (headers[i].hasType() && isImage(headers[i].type()) == false) |
||||||
|
version |= NON_IMAGE_FLAG; |
||||||
|
} |
||||||
|
|
||||||
|
OPENEXR_IMF_INTERNAL_NAMESPACE::Xdr::write <OPENEXR_IMF_INTERNAL_NAMESPACE::StreamIO> (os, version); |
||||||
|
} |
||||||
|
|
||||||
|
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_EXIT |
@ -0,0 +1,66 @@ |
|||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Copyright (c) 2011, Industrial Light & Magic, a division of Lucas
|
||||||
|
// Digital Ltd. LLC
|
||||||
|
//
|
||||||
|
// All rights reserved.
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without
|
||||||
|
// modification, are permitted provided that the following conditions are
|
||||||
|
// met:
|
||||||
|
// * Redistributions of source code must retain the above copyright
|
||||||
|
// notice, this list of conditions and the following disclaimer.
|
||||||
|
// * Redistributions in binary form must reproduce the above
|
||||||
|
// copyright notice, this list of conditions and the following disclaimer
|
||||||
|
// in the documentation and/or other materials provided with the
|
||||||
|
// distribution.
|
||||||
|
// * Neither the name of Industrial Light & Magic nor the names of
|
||||||
|
// its contributors may be used to endorse or promote products derived
|
||||||
|
// from this software without specific prior written permission.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
//
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifndef IMFGENERICOUTPUTFILE_H_ |
||||||
|
#define IMFGENERICOUTPUTFILE_H_ |
||||||
|
|
||||||
|
#include "ImfVersion.h" |
||||||
|
#include "ImfIO.h" |
||||||
|
#include "ImfXdr.h" |
||||||
|
#include "ImfHeader.h" |
||||||
|
#include "ImfNamespace.h" |
||||||
|
#include "ImfExport.h" |
||||||
|
|
||||||
|
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER |
||||||
|
|
||||||
|
|
||||||
|
class GenericOutputFile |
||||||
|
{ |
||||||
|
public: |
||||||
|
IMF_EXPORT |
||||||
|
virtual ~GenericOutputFile() {} |
||||||
|
|
||||||
|
protected: |
||||||
|
IMF_EXPORT |
||||||
|
GenericOutputFile() {} |
||||||
|
IMF_EXPORT |
||||||
|
void writeMagicNumberAndVersionField (OPENEXR_IMF_INTERNAL_NAMESPACE::OStream& os, const Header& header); |
||||||
|
IMF_EXPORT |
||||||
|
void writeMagicNumberAndVersionField (OPENEXR_IMF_INTERNAL_NAMESPACE::OStream& os, const Header * headers, int parts); |
||||||
|
|
||||||
|
}; |
||||||
|
|
||||||
|
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT |
||||||
|
|
||||||
|
#endif /* GENERICOUTPUTFILE_H_ */ |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue