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