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