/[svn]/linuxsampler/trunk/src/common/RTMath.h
ViewVC logotype

Diff of /linuxsampler/trunk/src/common/RTMath.h

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

revision 554 by schoenebeck, Thu May 19 19:25:14 2005 UTC revision 818 by wylder, Thu Dec 22 19:35:42 2005 UTC
# Line 36  enum implementation_t { Line 36  enum implementation_t {
36      ASM_X86_MMX_SSE      ASM_X86_MMX_SSE
37  };  };
38    
39    /** @brief Real Time Math Base Class
40     *
41     * Math functions for real time operation. This base class contains all
42     * non-template methods.
43     */
44  class RTMathBase {  class RTMathBase {
45      public:      public:
46          /**          /**
# Line 77  class RTMathBase { Line 82  class RTMathBase {
82          static float* InitCentsToFreqTable();          static float* InitCentsToFreqTable();
83  };  };
84    
85  /** Real Time Math  /** @brief Real Time Math
86   *   *
87   * Math functions for real time operation.   * This is a template which provides customized methods for the desired low
88     * level implementation. The ASM_X86_MMX_SSE implementation of each method
89     * for example doesn't use 387 FPU instruction. This is needed for MMX
90     * algorithms which do not allow mixed MMX and 387 instructions.
91   */   */
92  template<implementation_t IMPL = CPP>  template<implementation_t IMPL = CPP>
93  class __RTMath : public RTMathBase {  class __RTMath : public RTMathBase {
# Line 87  class __RTMath : public RTMathBase { Line 95  class __RTMath : public RTMathBase {
95          // conversion using truncate          // conversion using truncate
96          inline static int Int(const float a) {          inline static int Int(const float a) {
97              switch (IMPL) {              switch (IMPL) {
98                  case CPP: {                  #if CONFIG_ASM && ARCH_X86
                     return (int) a;  
                 }  
                 #if ARCH_X86  
99                  case ASM_X86_MMX_SSE: {                  case ASM_X86_MMX_SSE: {
100                      int ret;                      int ret;
101                      asm (                      asm (
# Line 100  class __RTMath : public RTMathBase { Line 105  class __RTMath : public RTMathBase {
105                      );                      );
106                      return ret;                      return ret;
107                  }                  }
108                  #endif // ARCH_X86                  #endif // CONFIG_ASM && ARCH_X86
109                    default: {
110                        return (int) a;
111                    }
112              }              }
113          }          }
114    
# Line 111  class __RTMath : public RTMathBase { Line 119  class __RTMath : public RTMathBase {
119    
120          inline static float Float(const int a) {          inline static float Float(const int a) {
121              switch (IMPL) {              switch (IMPL) {
122                  case CPP: {                  #if CONFIG_ASM && ARCH_X86
                     return (float) a;  
                 }  
                 #if ARCH_X86  
123                  case ASM_X86_MMX_SSE: {                  case ASM_X86_MMX_SSE: {
124                      float ret;                      float ret;
125                      asm (                      asm (
# Line 125  class __RTMath : public RTMathBase { Line 130  class __RTMath : public RTMathBase {
130                      );                      );
131                      return ret;                      return ret;
132                  }                  }
133                  #endif // ARCH_X86                  #endif // CONFIG_ASM && ARCH_X86
134                    default: {
135                        return (float) a;
136                    }
137              }              }
138          }          }
139    
# Line 138  class __RTMath : public RTMathBase { Line 146  class __RTMath : public RTMathBase {
146    
147          inline static float Sum(const float& a, const float& b) {          inline static float Sum(const float& a, const float& b) {
148              switch (IMPL) {              switch (IMPL) {
149                  case CPP: {                  #if CONFIG_ASM && ARCH_X86
                     return (a + b);  
                 }  
                 #if ARCH_X86  
150                  case ASM_X86_MMX_SSE: {                  case ASM_X86_MMX_SSE: {
151                      float ret;                      float ret;
152                      asm (                      asm (
# Line 153  class __RTMath : public RTMathBase { Line 158  class __RTMath : public RTMathBase {
158                      );                      );
159                      return ret;                      return ret;
160                  }                  }
161                  #endif // ARCH_X86                  #endif // CONFIG_ASM && ARCH_X86
162                    default: {
163                        return (a + b);
164                    }
165              }              }
166          }          }
167    
# Line 163  class __RTMath : public RTMathBase { Line 171  class __RTMath : public RTMathBase {
171    
172          inline static float Sub(const float& a, const float& b) {          inline static float Sub(const float& a, const float& b) {
173              switch (IMPL) {              switch (IMPL) {
174                  case CPP: {                  #if CONFIG_ASM && ARCH_X86
                     return (a - b);  
                 }  
                 #if ARCH_X86  
175                  case ASM_X86_MMX_SSE: {                  case ASM_X86_MMX_SSE: {
176                      float ret;                      float ret;
177                      asm (                      asm (
# Line 178  class __RTMath : public RTMathBase { Line 183  class __RTMath : public RTMathBase {
183                      );                      );
184                      return ret;                      return ret;
185                  }                  }
186                  #endif // ARCH_X86                  #endif // CONFIG_ASM && ARCH_X86
187                    default: {
188                        return (a - b);
189                    }
190              }              }
191          }          }
192    
# Line 188  class __RTMath : public RTMathBase { Line 196  class __RTMath : public RTMathBase {
196    
197          inline static float Mul(const float a, const float b) {          inline static float Mul(const float a, const float b) {
198              switch (IMPL) {              switch (IMPL) {
199                  case CPP: {                  #if CONFIG_ASM && ARCH_X86
                     return (a * b);  
                 }  
                 #if ARCH_X86  
200                  case ASM_X86_MMX_SSE: {                  case ASM_X86_MMX_SSE: {
201                      float ret;                      float ret;
202                      asm (                      asm (
# Line 203  class __RTMath : public RTMathBase { Line 208  class __RTMath : public RTMathBase {
208                      );                      );
209                      return ret;                      return ret;
210                  }                  }
211                  #endif // ARCH_X86                  #endif // CONFIG_ASM && ARCH_X86
212                    default: {
213                        return (a * b);
214                    }
215              }              }
216          }          }
217    
# Line 213  class __RTMath : public RTMathBase { Line 221  class __RTMath : public RTMathBase {
221    
222          inline static float Div(const float a, const float b) {          inline static float Div(const float a, const float b) {
223              switch (IMPL) {              switch (IMPL) {
224                  case CPP: {                  #if CONFIG_ASM && ARCH_X86
                     return (a / b);  
                 }  
                 #if ARCH_X86  
225                  case ASM_X86_MMX_SSE: {                  case ASM_X86_MMX_SSE: {
226                      float ret;                      float ret;
227                      asm (                      asm (
# Line 228  class __RTMath : public RTMathBase { Line 233  class __RTMath : public RTMathBase {
233                      );                      );
234                      return ret;                      return ret;
235                  }                  }
236                  #endif // ARCH_X86                  #endif // CONFIG_ASM && ARCH_X86
237                    default: {
238                        return (a / b);
239                    }
240              }              }
241          }          }
242    
# Line 238  class __RTMath : public RTMathBase { Line 246  class __RTMath : public RTMathBase {
246    
247          inline static float Min(const float a, const float b) {          inline static float Min(const float a, const float b) {
248              switch (IMPL) {              switch (IMPL) {
249                  case CPP: {                  #if CONFIG_ASM && ARCH_X86
                     return (b < a) ? b : a;  
                 }  
                 #if ARCH_X86  
250                  case ASM_X86_MMX_SSE: {                  case ASM_X86_MMX_SSE: {
251                      float ret;                      float ret;
252                      asm (                      asm (
# Line 253  class __RTMath : public RTMathBase { Line 258  class __RTMath : public RTMathBase {
258                      );                      );
259                      return ret;                      return ret;
260                  }                  }
261                  #endif // ARCH_X86                  #endif // CONFIG_ASM && ARCH_X86
262                    default: {
263                        return std::min(a, b);
264                    }
265              }              }
266          }          }
267    
# Line 263  class __RTMath : public RTMathBase { Line 271  class __RTMath : public RTMathBase {
271    
272          inline static float Max(const float a, const float b) {          inline static float Max(const float a, const float b) {
273              switch (IMPL) {              switch (IMPL) {
274                  case CPP: {                  #if CONFIG_ASM && ARCH_X86
                     return (b > a) ? b : a;  
                 }  
                 #if ARCH_X86  
275                  case ASM_X86_MMX_SSE: {                  case ASM_X86_MMX_SSE: {
276                      float ret;                      float ret;
277                      asm (                      asm (
# Line 278  class __RTMath : public RTMathBase { Line 283  class __RTMath : public RTMathBase {
283                      );                      );
284                      return ret;                      return ret;
285                  }                  }
286                  #endif // ARCH_X86                  #endif // CONFIG_ASM && ARCH_X86
287                    default: {
288                        return std::max(a, b);
289                    }
290              }              }
291          }          }
292    
# Line 288  class __RTMath : public RTMathBase { Line 296  class __RTMath : public RTMathBase {
296    
297          inline static float Fmodf(const float &a, const float &b) {          inline static float Fmodf(const float &a, const float &b) {
298              switch (IMPL) {              switch (IMPL) {
299                  case CPP: {                  #if CONFIG_ASM && ARCH_X86
                     return fmodf(a, b);  
                 }  
                 #if ARCH_X86  
300                  case ASM_X86_MMX_SSE: {                  case ASM_X86_MMX_SSE: {
301                      float ret;                      float ret;
302                      asm (                      asm (
# Line 310  class __RTMath : public RTMathBase { Line 315  class __RTMath : public RTMathBase {
315                      );                      );
316                      return ret;                      return ret;
317                  }                  }
318                  #endif // ARCH_X86                  #endif // CONFIG_ASM && ARCH_X86
319                    default: {
320                        return fmodf(a, b);
321                    }
322              }              }
323          }          }
324  };  };

Legend:
Removed from v.554  
changed lines
  Added in v.818

  ViewVC Help
Powered by ViewVC