HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TIL_FileSequence.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: TIL_FileSequence.h
7  *
8  * COMMENTS:
9  * Class for deal with sequences of images (determining start/end, etc).
10  */
11 #ifndef TIL_FILE_SEQUENCE_H
12 #define TIL_FILE_SEQUENCE_H
13 
14 #include "TIL_API.h"
15 #include <sys/types.h>
16 #include <UT/UT_String.h>
17 #include <UT/UT_Rect.h>
18 #include <UT/UT_BitArray.h>
19 #include <UT/UT_ValArray.h>
20 #include <UT/UT_Array.h>
21 #include <UT/UT_IntArray.h>
22 
23 #include "TIL_Defines.h"
24 
25 class IMG_Stat;
26 class TIL_Sequence;
27 class til_FrameInfo;
28 
30 {
31 public:
34 
35  int64 getMemoryUsage(bool inclusive) const;
36 
37  TIL_FileSequence &operator=(const TIL_FileSequence &);
38 
39  // returns 1 if the pattern is different than the current pattern, else 0.
40  int setNewPattern(const char *filepattern);
41 
42  // fills the sequence with the start/end range, size, data type, etc.
43  // returns 1 if successful, and 0 if the sequence doesn't exist.
44  int getFileInfo(TIL_Sequence &seq_info,
45  int override_size = 0,
46  int override_range = 0,
47  TIL_DataFormat *depth_override = 0,
48  int use_rgba = 0,
49  bool useframe = false, int frame = 0,
50  bool clearseq = true,
51  bool coloronly = false,
52  bool fractional = false);
53 
54  int getSingleFileInfo(const char *name, TIL_Sequence &seq_info,
55  bool override_size = true,
56  TIL_DataFormat *override_depth = 0,
57  int use_rgba = 0,
58  bool clearseq = true,
59  bool coloronly = false);
60 
61  // returns the frame range. The filename is only used if the frame range
62  // hasn't been determined yet (by calling getFileInfo).
63  bool getFrameRange(int &start, int &end, bool fractional=false);
64 
65  // gets the filename at a specific frame. Returns 0 if the frame doesn't
66  // exist. If frame == -MAX_INT, the first frame is returned.
67  bool getFilename(UT_String &name, int frame = 0x80000000);
68 
69  bool doesFrameExist(const UT_String &framename) const;
70  bool doesFrameExist(int frame) const;
71  int getClosestFrame(int to_frame) const;
72  int getClosestPrevFrame(int to_frame) const;
73  int getClosestNextFrame(int to_frame) const;
74 
75  int getPlaneIndex(const char *name) const;
76 
77  PXL_ColorSpace getPlaneColorSpace(int plane_index) const;
78  fpreal getPlaneColorSpaceGamma(int plane_index) const;
79 
80  // attempts to determine the frame step of the files by analyzing the gaps.
81  // only call after getFileInfo.
82  int getFrameStep();
83 
84  // call this to determine whether or not the specified sequence was
85  // only a single frame. Only call this after first calling
86  // getFileInfo() or getSingleFileInfo().
87  bool isSingleFrame() const { return myFrameSingle ? 1 : 0; }
88 
89  int getNumFrames() const { return myFrames.entries(); }
90 
91  // call this to determine whether the sequence is really a movie
92  // file which contains the frames. Only call this after first
93  // calling getFileInfo() or getSingleFileInfo(). Also note that
94  // this is the only method of this class that understands movie
95  // files because they aren't file sequences. You should use the
96  // API on IMG_File to query and read frames.
97  bool isMovieFile() const;
98 
99  bool isTopFirstImage() const { return myIsTopFirst; }
100  IMG_ColorModel getColorModel() const { return myColorModel; }
101 
102  // returns true if the digits was set by the user (ie $4F), and sets the
103  // digits parm to the number of file index digits. If nothing was specified
104  // this returns false.
105  bool getFileDigits(int &digits) const;
106  void setFileDigits(int digits);
107 
108  int getFractionFrameIndex(float frame) const;
109 
110  UT_InclusiveRect getBounds(int frame, bool &streak);
111  UT_InclusiveRect getBounds(const char *filename, bool &streak);
112 
113  fpreal getRenderTime(int frame) const;
114  int64 getRenderMemory(int frame) const;
115 
116  // Removes the frame from the list.
117  void markBadFrame(int frame);
118  // resets the list of bad frames.
119  void resetBadFrames();
120 
121  // returns the list of bad frames.
122  const UT_IntArray &getBadFrames() const { return myBadFrames; }
123 
124  void setComment(const UT_String &comment, int frame);
125  void getComment(UT_String &comment, int frame) const;
126 
127  static int getInfoForFilename(const char *name, TIL_Sequence &seq_info,
128  bool override_size = true,
129  TIL_DataFormat *override_depth = NULL,
130  bool use_rgba = false,
131  bool clearseq = true,
132  bool coloronly = false,
133  bool *topfirst = NULL,
134  IMG_Stat **stat = NULL);
135 
136 private:
137  int lookupRange(char sepchar, bool fractional);
138  void removeBadFrames();
139  void reorganizeFractions();
140  void clearBoundsCache();
141  void clearRenderTimesCache();
142  bool prepRenderTimeCache(int &frame) const;
143  UT_InclusiveRect getBoundsByIndex(int index, bool &streak);
144 
145  static int compareFileToRange(const char *filename, void *me);
146  static int checkExist(const char *filename, void *me);
147 
148  UT_String myFilePattern;
149  UT_String myMatchPattern;
150  int myFileNumberDigits;
151  IMG_Stat *myStat;
152  IMG_ColorModel myColorModel;
153  bool myIsTopFirst;
154 
155  // file range lookup info
156  int myFrameStart;
157  int myFrameSingle;
158  int myFrameEnd;
159  int myFrameInit;
160  int myFrameHasFraction;
161  float myFrameFractionScale;
162  bool myFractional;
164  UT_IntArray myBadFrames;
165  UT_String myBase, mySuffix;
166  UT_String myPath;
167  bool myUserSpecifiedDigits;
168  UT_BitArray myCachedBoundsFrame;
169  UT_Array<UT_InclusiveRect> myCachedBounds;
170  UT_BitArray myCachedBoundsStreak;
171  mutable UT_Lock myCachedRenderTimesLock;
172  mutable UT_BitArray myCachedRenderTimesFrame;
173  mutable UT_Array<fpreal> myCachedRenderTimes;
174  mutable UT_Array<int64> myCachedRenderMemories;
175 };
176 
177 #endif
GT_API const UT_StringHolder filename
GLuint start
Definition: glcorearb.h:475
const UT_IntArray & getBadFrames() const
#define TIL_DataFormat
Definition: TIL_Defines.h:65
GLuint GLuint end
Definition: glcorearb.h:475
long long int64
Definition: SYS_Types.h:116
GLuint const GLchar * name
Definition: glcorearb.h:786
int getNumFrames() const
bool isSingleFrame() const
Base Integer Rectangle class.
fpreal64 fpreal
Definition: SYS_Types.h:277
GLuint index
Definition: glcorearb.h:786
PXL_ColorSpace
Definition: PXL_Common.h:72
IMG_ColorModel
Definition: IMG_FileTypes.h:53
bool isTopFirstImage() const
Contains the details of a specific image file, used by IMG_File. This class contains all the high-lev...
Definition: IMG_Stat.h:38
IMG_ColorModel getColorModel() const
#define TIL_API
Definition: TIL_API.h:10