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