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