HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ImfDeepScanLineInputFile.h
Go to the documentation of this file.
1 //
2 // SPDX-License-Identifier: BSD-3-Clause
3 // Copyright (c) Contributors to the OpenEXR Project.
4 //
5 
6 #ifndef INCLUDED_IMF_DEEP_SCAN_LINE_INPUT_FILE_H
7 #define INCLUDED_IMF_DEEP_SCAN_LINE_INPUT_FILE_H
8 
9 //-----------------------------------------------------------------------------
10 //
11 // class DeepScanLineInputFile
12 //
13 //-----------------------------------------------------------------------------
14 
15 #include "ImfForward.h"
16 
17 #include "ImfThreading.h"
18 #include "ImfGenericInputFile.h"
20 
22 
23 
25 {
26  public:
27 
28  //------------
29  // Constructor
30  //------------
31 
33  DeepScanLineInputFile (const char fileName[],
34  int numThreads = globalThreadCount());
35 
38  int numThreads = globalThreadCount());
39 
40 
43  int version, /*version field from file*/
44  int numThreads = globalThreadCount());
45 
46  DeepScanLineInputFile (const DeepScanLineInputFile& other) = delete;
47  DeepScanLineInputFile& operator = (const DeepScanLineInputFile& other) = delete;
48  DeepScanLineInputFile (DeepScanLineInputFile&& other) = delete;
49  DeepScanLineInputFile& operator = (DeepScanLineInputFile&& other) = delete;
50 
51  //-----------------------------------------
52  // Destructor -- deallocates internal data
53  // structures, but does not close the file.
54  //-----------------------------------------
55 
57  virtual ~DeepScanLineInputFile ();
58 
59 
60  //------------------------
61  // Access to the file name
62  //------------------------
63 
65  const char * fileName () const;
66 
67 
68  //--------------------------
69  // Access to the file header
70  //--------------------------
71 
73  const Header & header () const;
74 
75 
76  //----------------------------------
77  // Access to the file format version
78  //----------------------------------
79 
81  int version () const;
82 
83 
84  //-----------------------------------------------------------
85  // Set the current frame buffer -- copies the FrameBuffer
86  // object into the InputFile object.
87  //
88  // The current frame buffer is the destination for the pixel
89  // data read from the file. The current frame buffer must be
90  // set at least once before readPixels() is called.
91  // The current frame buffer can be changed after each call
92  // to readPixels().
93  //-----------------------------------------------------------
94 
96  void setFrameBuffer (const DeepFrameBuffer &frameBuffer);
97 
98 
99  //-----------------------------------
100  // Access to the current frame buffer
101  //-----------------------------------
102 
103  IMF_EXPORT
104  const DeepFrameBuffer & frameBuffer () const;
105 
106 
107  //---------------------------------------------------------------
108  // Check if the file is complete:
109  //
110  // isComplete() returns true if all pixels in the data window are
111  // present in the input file, or false if any pixels are missing.
112  // (Another program may still be busy writing the file, or file
113  // writing may have been aborted prematurely.)
114  //---------------------------------------------------------------
115 
116  IMF_EXPORT
117  bool isComplete () const;
118 
119 
120  //---------------------------------------------------------------
121  // Read pixel data:
122  //
123  // readPixels(s1,s2) reads all scan lines with y coordinates
124  // in the interval [min (s1, s2), max (s1, s2)] from the file,
125  // and stores them in the current frame buffer.
126  //
127  // Both s1 and s2 must be within the interval
128  // [header().dataWindow().min.y, header.dataWindow().max.y]
129  //
130  // The scan lines can be read from the file in random order, and
131  // individual scan lines may be skipped or read multiple times.
132  // For maximum efficiency, the scan lines should be read in the
133  // order in which they were written to the file.
134  //
135  // readPixels(s) calls readPixels(s,s).
136  //
137  // If threading is enabled, readPixels (s1, s2) tries to perform
138  // decopmression of multiple scanlines in parallel.
139  //
140  //---------------------------------------------------------------
141 
142  IMF_EXPORT
143  void readPixels (int scanLine1, int scanLine2);
144  IMF_EXPORT
145  void readPixels (int scanLine);
146 
147 
148 
149  //---------------------------------------------------------------
150  // Extract pixel data from pre-read block
151  //
152  // readPixels(rawPixelData,frameBuffer,s1,s2) reads all scan lines with y coordinates
153  // in the interval [min (s1, s2), max (s1, s2)] from the data provided and
154  // stores them in the provided frameBuffer.
155  // the data can be obtained from a call to rawPixelData()
156  //
157  //
158  // Both s1 and s2 must be within the data specified
159  //
160  // you must provide a frameBuffer with a samplecountslice, which must have been read
161  // and the data valid - readPixels uses your sample count buffer to compute
162  // offsets to the data it needs
163  //
164  // This call does not block, and is thread safe for clients with an existing
165  // threading model. The InputFile's frameBuffer is not used in this call.
166  //
167  // This call is only provided for clients which have an existing threading model in place
168  // and unpredictable access patterns to the data.
169  // The fastest way to read an entire image is to enable threading,use setFrameBuffer then
170  // readPixels(header().dataWindow().min.y, header.dataWindow().max.y)
171  //
172  //---------------------------------------------------------------
173 
174  IMF_EXPORT
175  void readPixels (const char * rawPixelData,
176  const DeepFrameBuffer & frameBuffer,
177  int scanLine1,
178  int scanLine2) const;
179 
180  //----------------------------------------------
181  // Read a block of raw pixel data from the file,
182  // without uncompressing it (this function is
183  // used to implement OutputFile::copyPixels()).
184  // note: returns the entire payload of the relevant chunk of data, not including part number
185  // including compressed and uncompressed sizes
186  // on entry, if pixelDataSize is insufficiently large, no bytes are read (pixelData can safely be NULL)
187  // on exit, pixelDataSize is the number of bytes required to read the chunk
188  //
189  //----------------------------------------------
190 
191  IMF_EXPORT
192  void rawPixelData (int firstScanLine,
193  char * pixelData,
194  uint64_t &pixelDataSize);
195 
196 
197  //-------------------------------------------------
198  // firstScanLineInChunk() returns the row number of the first row that's stored in the
199  // same chunk as scanline y. Depending on the compression mode, this may not be the same as y
200  //
201  // lastScanLineInChunk() returns the row number of the last row that's stored in the same
202  // chunk as scanline y. Depending on the compression mode, this may not be the same as y.
203  // The last chunk in the file may be smaller than all the others
204  //
205  //------------------------------------------------
206  IMF_EXPORT
207  int firstScanLineInChunk(int y) const;
208  IMF_EXPORT
209  int lastScanLineInChunk (int y) const;
210 
211  //-----------------------------------------------------------
212  // Read pixel sample counts into a slice in the frame buffer.
213  //
214  // readPixelSampleCounts(s1, s2) reads all the counts of
215  // pixel samples with y coordinates in the interval
216  // [min (s1, s2), max (s1, s2)] from the file, and stores
217  // them in the slice naming "sample count".
218  //
219  // Both s1 and s2 must be within the interval
220  // [header().dataWindow().min.y, header.dataWindow().max.y]
221  //
222  // readPixelSampleCounts(s) calls readPixelSampleCounts(s,s).
223  //
224  //-----------------------------------------------------------
225 
226  IMF_EXPORT
227  void readPixelSampleCounts (int scanline1,
228  int scanline2);
229  IMF_EXPORT
230  void readPixelSampleCounts (int scanline);
231 
232 
233  //----------------------------------------------------------
234  // Read pixel sample counts into the provided frameBuffer
235  // using a block read of data read by rawPixelData
236  // for multi-scanline compression schemes, you must decode the entire block
237  // so scanline1=firstScanLineInChunk(y) and scanline2=lastScanLineInChunk(y)
238  //
239  // This call does not block, and is thread safe for clients with an existing
240  // threading model. The InputFile's frameBuffer is not used in this call.
241  //
242  // The fastest way to read an entire image is to enable threading in OpenEXR, use setFrameBuffer then
243  // readPixelSampleCounts(header().dataWindow().min.y, header.dataWindow().max.y)
244  //
245  //----------------------------------------------------------
246  IMF_EXPORT
247  void readPixelSampleCounts (const char * rawdata ,
248  const DeepFrameBuffer & frameBuffer,
249  int scanLine1 ,
250  int scanLine2) const;
251 
252  struct IMF_HIDDEN Data;
253 
254  private:
255 
256  Data * _data;
257 
258  DeepScanLineInputFile (InputPartData* part);
259 
260  void initialize(const Header& header);
261  void compatibilityInitialize(OPENEXR_IMF_INTERNAL_NAMESPACE::IStream & is);
262  void multiPartInitialize(InputPartData* part);
263 
264  friend class InputFile;
265  friend class MultiPartInputFile;
266  friend void DeepScanLineOutputFile::copyPixels(DeepScanLineInputFile &);
267 };
268 
269 
271 
272 #endif
#define OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
Definition: ImfNamespace.h:80
GLint y
Definition: glcorearb.h:103
#define IMF_HIDDEN
Definition: ImfExport.h:55
#define IMF_EXPORT
Definition: ImfExport.h:54
OPENVDB_API void initialize()
Global registration of native Grid, Transform, Metadata and Point attribute types. Also initializes blosc (if enabled).
Definition: logging.h:294
GT_API const UT_StringHolder version
class IMF_EXPORT_TYPE DeepScanLineInputFile
Definition: ImfForward.h:39
IMF_EXPORT void copyPixels(DeepScanLineInputFile &in)
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER IMF_EXPORT int globalThreadCount()
#define OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER
Definition: ImfNamespace.h:79
#define IMF_EXPORT_TYPE
Definition: ImfExport.h:57
class IMF_EXPORT_TYPE IStream
Definition: ImfForward.h:89