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 #include <IMG/IMG_Metadata.h>
23 
24 #include "TIL_Defines.h"
25 
26 class IMG_Stat;
27 class TIL_Sequence;
28 class til_FrameInfo;
29 
31 {
32 public:
35 
36  int64 getMemoryUsage(bool inclusive) const;
37 
39 
40  // returns 1 if the pattern is different than the current pattern, else 0.
41  int setNewPattern(const char *filepattern);
42 
43  // fills the sequence with the start/end range, size, data type, etc.
44  // returns 1 if successful, and 0 if the sequence doesn't exist.
45  int getFileInfo(TIL_Sequence &seq_info,
46  int override_size = 0,
47  int override_range = 0,
48  TIL_DataFormat *depth_override = 0,
49  int use_rgba = 0,
50  bool useframe = false, int frame = 0,
51  bool clearseq = true,
52  bool coloronly = false,
53  bool fractional = false);
54 
55  int getSingleFileInfo(const char *name, TIL_Sequence &seq_info,
56  bool override_size = true,
57  TIL_DataFormat *override_depth = 0,
58  int use_rgba = 0,
59  bool clearseq = true,
60  bool coloronly = false);
61 
62  // returns the frame range. The filename is only used if the frame range
63  // hasn't been determined yet (by calling getFileInfo).
64  bool getFrameRange(int &start, int &end, bool fractional=false);
65 
66  // gets the filename at a specific frame. Returns 0 if the frame doesn't
67  // exist. If frame == -MAX_INT, the first frame is returned.
68  bool getFilename(UT_String &name, int frame = 0x80000000);
69 
70  bool doesFrameExist(const UT_String &framename) const;
71  bool doesFrameExist(int frame) const;
72  int getClosestFrame(int to_frame) const;
73  int getClosestPrevFrame(int to_frame) const;
74  int getClosestNextFrame(int to_frame) const;
75 
76  int getPlaneIndex(const char *name) const;
77 
78  PXL_ColorSpace getPlaneColorSpace(int plane_index) const;
79  fpreal getPlaneColorSpaceGamma(int plane_index) const;
80 
81  // attempts to determine the frame step of the files by analyzing the gaps.
82  // only call after getFileInfo.
83  int getFrameStep();
84 
85  // call this to determine whether or not the specified sequence was
86  // only a single frame. Only call this after first calling
87  // getFileInfo() or getSingleFileInfo().
88  bool isSingleFrame() const { return myFrameSingle ? 1 : 0; }
89 
90  int getNumFrames() const { return myFrames.entries(); }
91 
92  // call this to determine whether the sequence is really a movie
93  // file which contains the frames. Only call this after first
94  // calling getFileInfo() or getSingleFileInfo(). Also note that
95  // this is the only method of this class that understands movie
96  // files because they aren't file sequences. You should use the
97  // API on IMG_File to query and read frames.
98  bool isMovieFile() const;
99 
100  bool isTopFirstImage() const { return myIsTopFirst; }
101  IMG_ColorModel getColorModel() const { return myColorModel; }
102 
103  // returns true if the digits was set by the user (ie $4F), and sets the
104  // digits parm to the number of file index digits. If nothing was specified
105  // this returns false.
106  bool getFileDigits(int &digits) const;
107  void setFileDigits(int digits);
108 
109  int getFractionFrameIndex(float frame) const;
110 
111  UT_InclusiveRect getBounds(int frame, bool &streak);
112  UT_InclusiveRect getBounds(const char *filename, bool &streak);
113 
114  fpreal getRenderTime(int frame) const;
115  int64 getRenderMemory(int frame) const;
116  const IMG_Metadata *getMetadata(int frame) const;
117 
118  // Removes the frame from the list.
119  void markBadFrame(int frame);
120  // resets the list of bad frames.
121  void resetBadFrames();
122 
123  // returns the list of bad frames.
124  const UT_IntArray &getBadFrames() const { return myBadFrames; }
125 
126  void setComment(const UT_String &comment, int frame);
127  void getComment(UT_String &comment, int frame) const;
128 
129  static int getInfoForFilename(const char *name, TIL_Sequence &seq_info,
130  bool override_size = true,
131  TIL_DataFormat *override_depth = NULL,
132  bool use_rgba = false,
133  bool clearseq = true,
134  bool coloronly = false,
135  bool *topfirst = NULL,
136  IMG_Stat **stat = NULL);
137 
138 private:
139  int lookupRange(char sepchar, bool fractional);
140  void removeBadFrames();
141  void reorganizeFractions();
142  void clearBoundsCache();
143  void clearRenderTimesCache();
144  bool prepRenderTimeCache(int &frame) const;
145  UT_InclusiveRect getBoundsByIndex(int index, bool &streak);
146 
147  static int compareFileToRange(const char *filename, void *me);
148  static int checkExist(const char *filename, void *me);
149 
150  UT_String myFilePattern;
151  UT_String myMatchPattern;
152  int myFileNumberDigits;
153  IMG_Stat *myStat;
154  IMG_ColorModel myColorModel;
155  bool myIsTopFirst;
156 
157  // file range lookup info
158  int myFrameStart;
159  int myFrameSingle;
160  int myFrameEnd;
161  int myFrameInit;
162  int myFrameHasFraction;
163  float myFrameFractionScale;
164  bool myFractional;
166  UT_IntArray myBadFrames;
167  UT_String myBase, mySuffix;
168  UT_String myPath;
169  bool myUserSpecifiedDigits;
170  UT_BitArray myCachedBoundsFrame;
171  UT_Array<UT_InclusiveRect> myCachedBounds;
172  UT_BitArray myCachedBoundsStreak;
173  mutable UT_Lock myCachedRenderTimesLock;
174  mutable UT_BitArray myCachedRenderTimesFrame;
175  mutable UT_Array<fpreal> myCachedRenderTimes;
176  mutable UT_Array<int64> myCachedRenderMemories;
177  mutable UT_Array<IMG_Metadata> myCachedMetadata;
178 };
179 
180 #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:64
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:278
LeafData & operator=(const LeafData &)=delete
GLuint index
Definition: glcorearb.h:786
PXL_ColorSpace
Definition: PXL_Common.h:72
IMG_ColorModel
Definition: IMG_FileTypes.h:52
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
Map of metadata items.
Definition: IMG_Metadata.h:217
#define TIL_API
Definition: TIL_API.h:10