1
///////////////////////////////////////////////////////////////////////////
3
// Copyright (c) 2007, Industrial Light & Magic, a division of Lucas
6
// All rights reserved.
8
// Redistribution and use in source and binary forms, with or without
9
// modification, are permitted provided that the following conditions are
11
// * Redistributions of source code must retain the above copyright
12
// notice, this list of conditions and the following disclaimer.
13
// * Redistributions in binary form must reproduce the above
14
// copyright notice, this list of conditions and the following disclaimer
15
// in the documentation and/or other materials provided with the
17
// * Neither the name of Industrial Light & Magic nor the names of
18
// its contributors may be used to endorse or promote products derived
19
// from this software without specific prior written permission.
21
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33
///////////////////////////////////////////////////////////////////////////
37
#ifndef INCLUDED_IMF_ACES_FILE_H
38
#define INCLUDED_IMF_ACES_FILE_H
41
//-----------------------------------------------------------------------------
43
// ACES image file I/O.
45
// This header file declares two classes that directly support
46
// image file input and output according to the Academy Image
47
// Interchange Framework.
49
// The Academy Image Interchange file format is a subset of OpenEXR:
51
// - Images are stored as scanlines. Tiles are not allowed.
53
// - Images contain three color channels, either
54
// R, G, B (red, green, blue) or
55
// Y, RY, BY (luminance, sub-sampled chroma)
57
// - Images may optionally contain an alpha channel.
59
// - Only three compression types are allowed:
60
// - NO_COMPRESSION (file is not compressed)
61
// - PIZ_COMPRESSION (lossless)
62
// - B44A_COMPRESSION (lossy)
64
// - The "chromaticities" header attribute must specify
65
// the ACES RGB primaries and white point.
67
// class AcesOutputFile writes an OpenEXR file, enforcing the
68
// restrictions listed above. Pixel data supplied by application
69
// software must already be in the ACES RGB space.
71
// class AcesInputFile reads an OpenEXR file. Pixel data delivered
72
// to application software is guaranteed to be in the ACES RGB space.
73
// If the RGB space of the file is not the same as the ACES space,
74
// then the pixels are automatically converted: the pixels are
75
// converted to CIE XYZ, a color adaptation transform shifts the
76
// white point, and the result is converted to ACES RGB.
78
//-----------------------------------------------------------------------------
80
#include <ImfHeader.h>
84
#include <ImfThreading.h>
93
struct Chromaticities;
96
// ACES red, green, blue and white-point chromaticities.
99
const Chromaticities & acesChromaticities ();
110
//---------------------------------------------------
111
// Constructor -- header is constructed by the caller
112
//---------------------------------------------------
114
AcesOutputFile (const std::string &name,
115
const Header &header,
116
RgbaChannels rgbaChannels = WRITE_RGBA,
117
int numThreads = globalThreadCount());
120
//----------------------------------------------------
121
// Constructor -- header is constructed by the caller,
122
// file is opened by the caller, destructor will not
123
// automatically close the file.
124
//----------------------------------------------------
126
AcesOutputFile (OStream &os,
127
const Header &header,
128
RgbaChannels rgbaChannels = WRITE_RGBA,
129
int numThreads = globalThreadCount());
132
//----------------------------------------------------------------
133
// Constructor -- header data are explicitly specified as function
134
// call arguments (empty dataWindow means "same as displayWindow")
135
//----------------------------------------------------------------
137
AcesOutputFile (const std::string &name,
138
const Imath::Box2i &displayWindow,
139
const Imath::Box2i &dataWindow = Imath::Box2i(),
140
RgbaChannels rgbaChannels = WRITE_RGBA,
141
float pixelAspectRatio = 1,
142
const Imath::V2f screenWindowCenter = Imath::V2f (0, 0),
143
float screenWindowWidth = 1,
144
LineOrder lineOrder = INCREASING_Y,
145
Compression compression = PIZ_COMPRESSION,
146
int numThreads = globalThreadCount());
149
//-----------------------------------------------
150
// Constructor -- like the previous one, but both
151
// the display window and the data window are
152
// Box2i (V2i (0, 0), V2i (width - 1, height -1))
153
//-----------------------------------------------
155
AcesOutputFile (const std::string &name,
158
RgbaChannels rgbaChannels = WRITE_RGBA,
159
float pixelAspectRatio = 1,
160
const Imath::V2f screenWindowCenter = Imath::V2f (0, 0),
161
float screenWindowWidth = 1,
162
LineOrder lineOrder = INCREASING_Y,
163
Compression compression = PIZ_COMPRESSION,
164
int numThreads = globalThreadCount());
171
virtual ~AcesOutputFile ();
174
//------------------------------------------------
175
// Define a frame buffer as the pixel data source:
176
// Pixel (x, y) is at address
178
// base + x * xStride + y * yStride
180
//------------------------------------------------
182
void setFrameBuffer (const Rgba *base,
187
//-------------------------------------------------
188
// Write pixel data (see class Imf::OutputFile)
189
// The pixels are assumed to contain ACES RGB data.
190
//-------------------------------------------------
192
void writePixels (int numScanLines = 1);
193
int currentScanLine () const;
196
//--------------------------
197
// Access to the file header
198
//--------------------------
200
const Header & header () const;
201
const Imath::Box2i & displayWindow () const;
202
const Imath::Box2i & dataWindow () const;
203
float pixelAspectRatio () const;
204
const Imath::V2f screenWindowCenter () const;
205
float screenWindowWidth () const;
206
LineOrder lineOrder () const;
207
Compression compression () const;
208
RgbaChannels channels () const;
211
// --------------------------------------------------------------------
212
// Update the preview image (see Imf::OutputFile::updatePreviewImage())
213
// --------------------------------------------------------------------
215
void updatePreviewImage (const PreviewRgba[]);
220
AcesOutputFile (const AcesOutputFile &); // not implemented
221
AcesOutputFile & operator = (const AcesOutputFile &); // not implemented
237
//-------------------------------------------------------
238
// Constructor -- opens the file with the specified name,
239
// destructor will automatically close the file.
240
//-------------------------------------------------------
242
AcesInputFile (const std::string &name,
243
int numThreads = globalThreadCount());
246
//-----------------------------------------------------------
247
// Constructor -- attaches the new AcesInputFile object to a
248
// file that has already been opened by the caller.
249
// Destroying the AcesInputFile object will not automatically
251
//-----------------------------------------------------------
253
AcesInputFile (IStream &is,
254
int numThreads = globalThreadCount());
261
virtual ~AcesInputFile ();
264
//-----------------------------------------------------
265
// Define a frame buffer as the pixel data destination:
266
// Pixel (x, y) is at address
268
// base + x * xStride + y * yStride
270
//-----------------------------------------------------
272
void setFrameBuffer (Rgba *base,
277
//--------------------------------------------
278
// Read pixel data (see class Imf::InputFile)
279
// Pixels returned will contain ACES RGB data.
280
//--------------------------------------------
282
void readPixels (int scanLine1, int scanLine2);
283
void readPixels (int scanLine);
286
//--------------------------
287
// Access to the file header
288
//--------------------------
290
const Header & header () const;
291
const Imath::Box2i & displayWindow () const;
292
const Imath::Box2i & dataWindow () const;
293
float pixelAspectRatio () const;
294
const Imath::V2f screenWindowCenter () const;
295
float screenWindowWidth () const;
296
LineOrder lineOrder () const;
297
Compression compression () const;
298
RgbaChannels channels () const;
299
const char * fileName () const;
300
bool isComplete () const;
303
//----------------------------------
304
// Access to the file format version
305
//----------------------------------
307
int version () const;
311
AcesInputFile (const AcesInputFile &); // not implemented
312
AcesInputFile & operator = (const AcesInputFile &); // not implemented