HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TIL_Sequence.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_Sequence.h (Tile Image Library, C++)
7  *
8  * COMMENTS:
9  * Defines the information for a series of images.
10  */
11 #ifndef TIL_SEQUENCE_H
12 #define TIL_SEQUENCE_H
13 
14 #include "TIL_API.h"
15 #include <iosfwd>
16 #include <UT/UT_Options.h>
17 #include <UT/UT_SmallObject.h>
18 #include <UT/UT_ValArray.h>
19 #include <UT/UT_String.h>
20 
21 #include "TIL_Defines.h"
22 
23 // image rounding
24 #define SEQUENCE_NEAREST 0
25 #define SEQUENCE_PREVIOUS 1
26 #define SEQUENCE_NEXT 2
27 
28 class UT_WorkBuffer;
29 class UT_InfoTree;
30 class TIL_Plane;
31 class IMG_Stat;
32 
34  public UT_SmallObject<TIL_Sequence,
35  UT_SMALLOBJECT_CLEANPAGES_OFF, 196,
36  UT_SMALLOBJECT_THREADSAFE_ON>
37 
38 {
39 public:
40  TIL_Sequence();
41  TIL_Sequence(const TIL_Sequence &);
42 
43  ~TIL_Sequence();
44 
45  int64 getMemoryUsage(bool inclusive) const;
46 
47  void reset();
48  bool isValid() const { return myValidFlag; }
49  void setValid(bool valid) { myValidFlag = valid; }
50 
51  // copies everything.
52  TIL_Sequence & operator=(const TIL_Sequence &);
53 
54  bool operator==(const TIL_Sequence &) const;
55 
56  bool matches(const TIL_Sequence &other_seq,
57  bool metdata_tool = true) const;
58 
59  void copyFrom(const IMG_Stat &stat);
60  void copyTo(IMG_Stat &stat) const;
61 
62  // copies everything but the plane information.
63  void copyAttributes(const TIL_Sequence &);
64 
65  void getInfoText(UT_WorkBuffer &info,
66  bool timedep = true,
67  bool mark_unscoped = false) const;
68  void getInfoTree(UT_InfoTree &tree,
69  bool timeDep) const;
70 
71  // querying/setting
72 
73  bool isSingleImage() const { return mySingleImage;}
74  void setSingleImage(bool on) { mySingleImage = on; }
75 
76  double getFrameRate() const { return myRate; }
77  void setFrameRate(double rate) { myRate = rate; }
78 
79  exint getLength() const { return myLength; }
80  void setLength(exint n) { myLength = n; }
81 
82  double getStart() const { return myStart; }
83  void setStart(double start) { myStart = start; }
84 
85  double getEnd() const { return myStart+myLength-1; }
86 
87  double getStartTime() const { return (myStart-1) / myRate; }
88  double getEndTime() const
89  { return (myStart + myLength -2) / myRate; }
90 
91  // 'Res' is the visible resolution of the image. 'Size' is the actual
92  // size of the image, which is equal to or greater than the res.
93  void getRes(int &x,int &y) const
94  { x = myXRes; y = myYRes; }
95 
96  void setRes(int x, int y);
97 
98  void setAspectRatio(float aspect)
99  { myAspect = (aspect > 0.0f) ? aspect : 1.0f; }
100  float getAspectRatio() const { return myAspect; }
101  float getVAspectRatio() const
102  { return (getInterlace()==INTERLACE_HALF) ? 2.0f:1.0f; }
103 
105  { return myRenderTime; }
107  { myRenderTime = t; }
109  { return myRenderMemory; }
111  { myRenderMemory = mem; }
112 
114  { b = myPreExtend; a = myPostExtend; }
115  void getTemporalHold(int &before, int &after) const
116  { before = myPreHold; after = myPostHold; }
117 
119  { myPreExtend = before; myPostExtend = after; }
120  void setTemporalHold(int before, int after)
121  { myPreHold = before; myPostHold = after; }
122 
123  // utility functions
124 
125  // These return the actual image index, from 0 to N-1
126  exint getImageIndex(double t, int clamp_range = 1,
127  int round_off = SEQUENCE_NEAREST) const;
128  double getImageTime(double t, int clamp_range =1,
129  int round_off = SEQUENCE_NEAREST) const;
130 
131  // These return the frame index for interlaced frames (imageindex/2)
132  exint getFrameIndex(double t, int clamp_range = 1,
133  int round_off = SEQUENCE_NEAREST) const;
134  double getFrameTime(double t,int clamp_range =1,
135  int round_off = SEQUENCE_NEAREST) const;
136 
137  // returns the time of image at image_index (in the range 0 - length-1)
138  double getIndexTime(exint image_index) const;
139 
140  exint checkIndexBounds(exint image_index) const;
141 
142  // plane management
143  int getNumPlanes() const { return myPlanes.entries(); }
144 
145  // If reorder is true, then addPlane can re-order the plane and the
146  // caller cannot assume that we will append the plane to the end
147  TIL_Plane * addPlane(const char *name, TIL_DataFormat format,
148  const char *vn1 = 0,
149  const char *vn2 = 0,
150  const char *vn3 = 0,
151  const char *vn4 = 0,
152  bool reorder=false);
153  TIL_Plane * addPlane(const TIL_Plane *plane,
154  bool reorder=false);
155 
156  // removes and delete a plane.
157  void removePlane(int index);
158  void removePlane(const char *name);
159 
160  void clearAllPlanes();
161 
162  // plane accessor functions.
163  TIL_Plane * getPlane(int index);
164  const TIL_Plane * getPlane(int index) const;
165 
166  TIL_Plane * getPlane(const char *name);
167  const TIL_Plane * getPlane(const char *name) const;
168 
169  TIL_Plane * getPlaneWithElement(const char *elem_name);
170  const TIL_Plane * getPlaneWithElement(const char *elem_name) const;
171 
172  int getPlaneByName(const char *name) const;
173 
174  // Interlacing
175  void setInterlace(TIL_Interlace i, TIL_Dominance d);
176  TIL_Interlace getInterlace() const { return myInterlace; }
177  TIL_Dominance getFieldDominance() const { return myDominance; }
178 
179  void print(std::ostream &os) const;
180 
181  void bumpColorAlphaToFront();
182 
183  // metadata support
184  UT_Options &metaData() { return myMetaData; }
185  const UT_Options &metaData() const { return myMetaData; }
186 
187  void clearMetaData() { myMetaData.clear(); }
188 
189 private:
190  void makeUnique(UT_String &name);
191 
192  unsigned myValidFlag :1,
193  mySingleImage : 1;
194 
195  // sequence rate, start & length
196  exint myLength;
197  double myStart;
198  double myRate;
199 
200  // image resolution.
201  int myXRes;
202  int myYRes;
203  float myAspect;
204 
205  // Temporal extend conditions
206  TIL_Extend myPreExtend;
207  TIL_Extend myPostExtend;
208 
209  int myPreHold;
210  int myPostHold;
211 
212  // sequence planes (r,g,b, etc)
213  UT_ValArray<TIL_Plane *> myPlanes;
214 
215  TIL_Interlace myInterlace;
216  TIL_Dominance myDominance;
217 
218  UT_Options myMetaData;
219 
220  // TODO: Move these into a generic metadata structure
221  fpreal myRenderTime;
222  int64 myRenderMemory;
223 };
224 
225 #endif
void setRenderMemory(int64 mem)
Definition: TIL_Sequence.h:110
TIL_Dominance getFieldDominance() const
Definition: TIL_Sequence.h:177
exint getLength() const
Definition: TIL_Sequence.h:79
void setFrameRate(double rate)
Definition: TIL_Sequence.h:77
void setTemporalExtend(TIL_Extend before, TIL_Extend after)
Definition: TIL_Sequence.h:118
void setStart(double start)
Definition: TIL_Sequence.h:83
void setSingleImage(bool on)
Definition: TIL_Sequence.h:74
GLuint start
Definition: glcorearb.h:474
void setTemporalHold(int before, int after)
Definition: TIL_Sequence.h:120
void clearMetaData()
Definition: TIL_Sequence.h:187
TIL_Interlace
Definition: TIL_Defines.h:74
GLboolean GLboolean GLboolean GLboolean a
Definition: glcorearb.h:1221
void getRes(int &x, int &y) const
Definition: TIL_Sequence.h:93
GLint y
Definition: glcorearb.h:102
bool isSingleImage() const
Definition: TIL_Sequence.h:73
png_uint_32 i
Definition: png.h:2877
double getStartTime() const
Definition: TIL_Sequence.h:87
const UT_Options & metaData() const
Definition: TIL_Sequence.h:185
bool operator==(const BaseDimensions< T > &a, const BaseDimensions< Y > &b)
Definition: Dimensions.h:137
long long int64
Definition: SYS_Types.h:107
fpreal getRenderTime() const
Definition: TIL_Sequence.h:104
GLdouble n
Definition: glcorearb.h:2007
void setLength(exint n)
Definition: TIL_Sequence.h:80
GLfloat f
Definition: glcorearb.h:1925
#define TIL_DataFormat
Definition: TIL_Defines.h:64
TIL_Interlace getInterlace() const
Definition: TIL_Sequence.h:176
double getFrameRate() const
Definition: TIL_Sequence.h:76
int64 exint
Definition: SYS_Types.h:116
#define SEQUENCE_NEAREST
Definition: TIL_Sequence.h:24
double getEndTime() const
Definition: TIL_Sequence.h:88
void getTemporalExtend(TIL_Extend &b, TIL_Extend &a) const
Definition: TIL_Sequence.h:113
TIL_Dominance
Definition: TIL_Defines.h:82
float getAspectRatio() const
Definition: TIL_Sequence.h:100
GLuint const GLchar * name
Definition: glcorearb.h:785
GLboolean GLboolean GLboolean b
Definition: glcorearb.h:1221
double getEnd() const
Definition: TIL_Sequence.h:85
double getStart() const
Definition: TIL_Sequence.h:82
GLint GLint GLsizei GLint GLenum format
Definition: glcorearb.h:107
double fpreal
Definition: SYS_Types.h:270
A map of string to various well defined value types.
Definition: UT_Options.h:42
GLuint index
Definition: glcorearb.h:785
void setAspectRatio(float aspect)
Definition: TIL_Sequence.h:98
GLint GLenum GLint x
Definition: glcorearb.h:408
int64 getRenderMemory() const
Definition: TIL_Sequence.h:108
Contains the details of a specific image file, used by IMG_File. This class contains all the high-lev...
Definition: IMG_Stat.h:40
void setValid(bool valid)
Definition: TIL_Sequence.h:49
bool isValid() const
Definition: TIL_Sequence.h:48
void getTemporalHold(int &before, int &after) const
Definition: TIL_Sequence.h:115
void setRenderTime(fpreal t)
Definition: TIL_Sequence.h:106
#define TIL_API
Definition: TIL_API.h:10
int getNumPlanes() const
Definition: TIL_Sequence.h:143
UT_Options & metaData()
Definition: TIL_Sequence.h:184
float getVAspectRatio() const
Definition: TIL_Sequence.h:101
TIL_Extend
Definition: TIL_Defines.h:92