Home My Page Projects Code Snippets Project Openings diderot
Summary Activity Tracker Tasks SCM

SCM Repository

[diderot] Diff of /branches/pure-cfg/src/include/Diderot/inline-image.h
ViewVC logotype

Diff of /branches/pure-cfg/src/include/Diderot/inline-image.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 857, Tue Apr 19 19:42:13 2011 UTC revision 983, Tue Apr 26 16:58:46 2011 UTC
# Line 23  Line 23 
23  #ifndef _DIDEROT_INLINE_VEC4_H_  #ifndef _DIDEROT_INLINE_VEC4_H_
24  #  include "inline-vec4.h"  #  include "inline-vec4.h"
25  #endif  #endif
26    #ifndef _DIDEROT_INLINE_MATRIX_H_
27    #  include "inline-matrix.h"
28    #endif
29    
30  /***** 1D Image functions *****/  /***** 1D Image functions *****/
31    
32  // check if pos is inside the img, assuming that we have a border of width s.  // check if pos is inside the img, assuming that we have a border of width s.
33  //  //
34  STATIC_INLINE bool Diderot_Inside1f (float pos, Diderot_image1D_t *img, int s)  STATIC_INLINE bool Inside1f (float pos, Diderot_image1D_t *img, int s)
35  {  {
36      return ((s-1 < pos) && (pos < (img->size[0] - s)));      return ((s-1 < pos) && (pos < (img->size[0] - s)));
37  }  }
38    
39  STATIC_INLINE float Diderot_ToImageSpace1f (Diderot_image1D_t *img, float pos)  STATIC_INLINE float ToImageSpace1f (Diderot_image1D_t *img, float pos)
40  {  {
41      vec2f_t p = __extension__ vec2f(pos, 1.0f);      vec2f_t p = __extension__ vec2f(pos, 1.0f);
42    
43      return dot3f(img->mInv[0].v, p);      return dot2f(img->mInv[0].v, p);
44  }  }
45    
46  /***** 2D Image functions *****/  /***** 2D Image functions *****/
47    
48  // check if pos is inside the img, assuming that we have a border of width s.  // check if pos is inside the img, assuming that we have a border of width s.
49  //  //
50  STATIC_INLINE bool Diderot_Inside2f (vec2f_t posArg, Diderot_image2D_t *img, int s)  STATIC_INLINE bool Inside2f (vec2f_t posArg, Diderot_image2D_t *img, int s)
51  {  {
52  // NOTE: there might be a vectorized way to do this compare!  // NOTE: there might be a vectorized way to do this compare!
53  // cvtps2pi -- converts vector of floats to vector of int32_t values  // cvtps2pi -- converts vector of floats to vector of int32_t values
# Line 55  Line 58 
58          &&  (s-1 < pos.r[1]) && (pos.r[1] < (img->size[1] - s)));          &&  (s-1 < pos.r[1]) && (pos.r[1] < (img->size[1] - s)));
59  }  }
60    
61  STATIC_INLINE vec2f_t Diderot_ToImageSpace2f (Diderot_image2D_t *img, vec2f_t posArg)  STATIC_INLINE vec2f_t ToImageSpace2f (Diderot_image2D_t *img, vec2f_t posArg)
62  {  {
63      vec3f_t p = __extension__ vec3f(      vec3f_t p = __extension__ vec3f(
64          ((union2f_t)posArg).r[0],          ((union2f_t)posArg).r[0],
# Line 67  Line 70 
70          dot3f(img->mInv[1].v, p));          dot3f(img->mInv[1].v, p));
71  }  }
72    
73    STATIC_INLINE vec2f_t ToWorldSpace2f (Diderot_image2D_t *img, vec2f_t gradArg)
74    {
75        vec3f_t g = __extension__ vec3f(
76            ((union2f_t)gradArg).r[0],
77            ((union2f_t)gradArg).r[1],
78            0.0f);
79    
80        return vec2f(
81            dot3f(img->mInvT[0].v, g),
82            dot3f(img->mInvT[1].v, g));
83    }
84    
85    STATIC_INLINE void ToWorldSpace2x2f (Diderot_Mat2x2_t dst, Diderot_image2D_t *img, Diderot_Mat2x2_t src)
86    {
87        copy2x2f(dst, src);  // FIXME: only works for identity transforms
88    }
89    
90  /***** 3D Image functions *****/  /***** 3D Image functions *****/
91    
92  // check if pos is inside the img, assuming that we have a border of width s.  // check if pos is inside the img, assuming that we have a border of width s.
93  //  //
94  STATIC_INLINE bool Diderot_Inside3f (vec3f_t posArg, Diderot_image3D_t *img, int s)  STATIC_INLINE bool Inside3f (vec3f_t posArg, Diderot_image3D_t *img, int s)
95  {  {
96  // NOTE: there might be a vectorized way to do this compare!  // NOTE: there might be a vectorized way to do this compare!
97  // cvtps2pi -- converts vector of floats to vector of int32_t values  // cvtps2pi -- converts vector of floats to vector of int32_t values
# Line 83  Line 103 
103          &&  (s-1 < pos.r[2]) && (pos.r[2] < (img->size[2] - s)));          &&  (s-1 < pos.r[2]) && (pos.r[2] < (img->size[2] - s)));
104  }  }
105    
106  STATIC_INLINE vec3f_t Diderot_ToImageSpace3f (Diderot_image3D_t *img, vec3f_t posArg)  STATIC_INLINE vec3f_t ToImageSpace3f (Diderot_image3D_t *img, vec3f_t posArg)
107  {  {
108      vec4f_t p = __extension__ vec4f(      vec4f_t p = __extension__ vec4f(
109          ((union3f_t)posArg).r[0],          ((union3f_t)posArg).r[0],
# Line 97  Line 117 
117          dot4f(img->mInv[2].v, p));          dot4f(img->mInv[2].v, p));
118  }  }
119    
120    STATIC_INLINE vec3f_t ToWorldSpace3f (Diderot_image3D_t *img, vec3f_t gradArg)
121    {
122        vec4f_t g = __extension__ vec4f(
123            ((union3f_t)gradArg).r[0],
124            ((union3f_t)gradArg).r[1],
125            ((union3f_t)gradArg).r[2],
126            0.0f);
127    
128        return vec3f(
129            dot4f(img->mInvT[0].v, g),
130            dot4f(img->mInvT[1].v, g),
131            dot4f(img->mInvT[2].v, g));
132    }
133    
134    STATIC_INLINE void ToWorldSpace3x3f (Diderot_Mat3x3_t dst, Diderot_image3D_t *img, Diderot_Mat3x3_t src)
135    {
136        copy3x3f(dst, src);  // FIXME: only works for identity transforms
137    }
138    
139  #endif /* !_DIDEROT_INLINE_IMAGE_H_ */  #endif /* !_DIDEROT_INLINE_IMAGE_H_ */

Legend:
Removed from v.857  
changed lines
  Added in v.983

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0