HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
IMG_RasterFilter.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: IMG_Filter.h ( IMG Library, C++)
7  *
8  * COMMENTS: Code to apply a simple 2D symmetric separable filter to an
9  * image. This code allows for re-sizing of the image as well as
10  * filtering to the same resolution.
11  */
12 
13 #ifndef __IMG_Filter__
14 #define __IMG_Filter__
15 
16 #include "IMG_API.h"
17 #include <UT/UT_Filter.h>
18 #include "IMG_FileTypes.h"
19 
20 // Private to this class
21 class img_FilterStorage;
22 class SPUT_ThreadSet;
23 
24 #ifdef CELLBE
25 #include <SPU/SPU_FastBlur.h>
26 #endif
27 
29 {
30 public:
31  typedef exint (*fetchFunc)(void *tag, void *buffer, exint scanline);
32 
34  exint inpXres, exint inpYres,
35  exint outXres, exint outYres,
36  fetchFunc inpFetch,
37 
38  UT_FilterType xfilter = UT_FILTER_BOX,
39  float xwidth = 1,
40 
41  UT_FilterType yfilter = UT_FILTER_BOX,
42  float ywidth = 1,
43 
44  IMG_DataType srcType = IMG_UCHAR,
45  IMG_DataType destType = IMG_UCHAR,
46 
47  // We do not do color model conversions in this code
48  IMG_ColorModel colorModel = IMG_RGBA);
49 
51  exint inpXres, exint inpYres,
52  exint outXres, exint outYres,
53  fetchFunc inpFetch,
54 
55  UT_Filter * xfilter,
56  float xwidth,
57 
58  UT_Filter * yfilter,
59  float ywidth,
60 
61  IMG_DataType srcType = IMG_UCHAR,
62  IMG_DataType destType = IMG_UCHAR,
63 
64  // We do not do color model conversions in this code
65  IMG_ColorModel colorModel = IMG_RGBA);
66 
67 
69 
70  void restartFilter();
71  exint nextScanline(exint y, void *buf, void *tag);
72 
73 
74  // This is the constructor for fast approximations of Box, Cone and Gauss
75  // filters. You must use fastApproxBlur() for this version instead of
76  // nextScanline(). restartFilter() is not needed before reusing the filter.
77  // - only single channel data is supported
78  // - different X/Y filter types are not supported (though sizes are)
79  // - data conversion is not supported
80  IMG_RasterFilter( exint xres, exint yres,
81  fetchFunc inpFetch,
83  float xwidth = 1.0f,
84  float ywidth = 1.0f,
86 
87  static void getApproxBlurBound(UT_FilterType type,
88  float xsize,float ysize,
89  exint ix1,exint iy1, exint ix2, exint iy2,
90  exint &x1,exint &y1, exint &x2, exint &y2);
91 
92  // this method does a fast gaussian filter by using 4 successive box
93  // filters (or a cone filter with 2, and an exact box filter). This
94  // is most optimal for larger filter sizes. Small filter sizes have a
95  // considerably more error (<10). 'buf' is a pointer to the entire image
96  // (xres x yres, Format = type, from the constructor)
97  int fastApproxBlur(void *buf, void *tag);
98 
99  // These only apply to the CELLBE version of fast approx blur. They have
100  // no effect on other platforms.
101  bool isRunning();
102  void close();
103 
104 private:
105  exint myInXres, myInYres;
106  exint myOutXres, myOutYres;
107  fetchFunc myFetch;
108 
109  exint myYWindow; // Size of filter window in Y.
110  float myYRadius; // Filter radius as a float
111  float myXScale, myYScale;
112 
113  IMG_DataType myInType;
114  IMG_DataType myOutType;
115  exint myWPP; // Channels per pixel (words)
116 
117  UT_Filter *myYFilter;
118  UT_FilterWindow *myXWeight;
119  UT_FilterWindow myYWeight;
120 
121  void *myInputBuffer;
122  float *myFinal;
123  float *myLoader;
124  float **myActive;
125  exint *myLineBuf;
126 
127  // Extra stuff for the Fast Approximate blur.
128  void filterVerticalFastApprox(exint x, float *tmp1, float *tmp2);
129 
130  bool myFastApprox;
131  int myNumPasses;
132 
133  exint myXRadius;
134  float myXRadiusWeight;
135  float myXArea;
136  exint myXOffset;
137 
138  exint myYIntRadius;
139  float myYRadiusWeight;
140  float myYArea;
141  exint myYOffset;
142 };
143 
144 #endif
GLint y
Definition: glcorearb.h:102
UT_FilterType
Definition: UT_FilterType.h:16
GLuint buffer
Definition: glcorearb.h:659
#define IMG_API
Definition: IMG_API.h:10
GLfloat f
Definition: glcorearb.h:1925
int64 exint
Definition: SYS_Types.h:115
IMG_DataType
Definition: IMG_FileTypes.h:17
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glcorearb.h:2539
virtual void close()
IMG_ColorModel
Definition: IMG_FileTypes.h:53
GLint GLenum GLint x
Definition: glcorearb.h:408
GLint GLint GLsizei GLint GLenum GLenum type
Definition: glcorearb.h:107
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glcorearb.h:1296