1 ///////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (c) 2011, Industrial Light & Magic, a division of Lucas
4 // Digital Ltd. LLC
5 //
6 // Portions (c) 2012 Weta Digital Ltd
7 //
8 // All rights reserved.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 // *       Redistributions of source code must retain the above copyright
14 // notice, this list of conditions and the following disclaimer.
15 // *       Redistributions in binary form must reproduce the above
16 // copyright notice, this list of conditions and the following disclaimer
17 // in the documentation and/or other materials provided with the
18 // distribution.
19 // *       Neither the name of Industrial Light & Magic nor the names of
20 // its contributors may be used to endorse or promote products derived
21 // from this software without specific prior written permission.
22 //
23 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 //
35 ///////////////////////////////////////////////////////////////////////////
36 
37 #ifndef MULTIPARTOUTPUTFILE_H_
38 #define MULTIPARTOUTPUTFILE_H_
39 
40 #include "ImfHeader.h"
41 #include "ImfGenericOutputFile.h"
42 #include "ImfForward.h"
43 #include "ImfThreading.h"
44 #include "ImfNamespace.h"
45 #include "ImfExport.h"
46 
47 OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER
48 
49 
50 //
51 // Class responsible for handling the writing of multipart images.
52 //
53 // Note: Certain attributes are 'common' to all parts. Notably:
54 // * Display Window
55 // * Pixel Aspect Ratio
56 // * Time Code
57 // * Chromaticities
58 // The first header forms the basis for the set of attributes that are shared
59 // across the constituent parts.
60 //
61 // Parameters
62 //  headers - pointer to array of headers; one for each part of the image file
63 //  parts - count of number of parts
64 //  overrideSharedAttributes - toggle for the handling of shared attributes.
65 //                             set false to check for inconsistencies, true
66 //                             to copy the values over from the first header.
67 //  numThreads - number of threads that should be used in encoding the data.
68 //
69 
70 class IMF_EXPORT MultiPartOutputFile : public GenericOutputFile
71 {
72     public:
73         MultiPartOutputFile(const char fileName[],
74                             const Header * headers,
75                             int parts,
76                             bool overrideSharedAttributes = false,
77                             int numThreads = globalThreadCount());
78 
79         MultiPartOutputFile(OStream & os,
80                             const Header * headers,
81                             int parts,
82                             bool overrideSharedAttributes = false,
83                             int numThreads = globalThreadCount());
84 
85         //
86         // return number of parts in file
87         //
88         int parts() const ;
89 
90 
91         //
92         // return header for part n
93         // (note: may have additional attributes compared to that passed to constructor)
94         //
95         const Header & header(int n) const;
96 
97         ~MultiPartOutputFile();
98 
99         struct Data;
100 
101     private:
102         Data*                           _data;
103 
104         MultiPartOutputFile(const MultiPartOutputFile &); // not implemented
105 
106         template<class T>         T*  getOutputPart(int partNumber);
107 
108 
109     friend class OutputPart;
110     friend class TiledOutputPart;
111     friend class DeepScanLineOutputPart;
112     friend class DeepTiledOutputPart;
113 };
114 
115 
116 OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
117 
118 #endif /* MULTIPARTOUTPUTFILE_H_ */
119