[PD-cvs] pd/src builtins_dsp.c,1.1.2.4,1.1.2.5

Mathieu Bouchard matju at users.sourceforge.net
Wed Jan 3 22:46:18 CET 2007


Update of /cvsroot/pure-data/pd/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25078

Modified Files:
      Tag: desiredata
	builtins_dsp.c 
Log Message:
added PERFORM macro


Index: builtins_dsp.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/Attic/builtins_dsp.c,v
retrieving revision 1.1.2.4
retrieving revision 1.1.2.5
diff -C2 -d -r1.1.2.4 -r1.1.2.5
*** builtins_dsp.c	3 Jan 2007 21:26:39 -0000	1.1.2.4
--- builtins_dsp.c	3 Jan 2007 21:46:15 -0000	1.1.2.5
***************
*** 47,106 ****
  }
  
! t_int *plus_perform(t_int *w)
! {
!     t_float *in1 = (t_float *)(w[1]);
!     t_float *in2 = (t_float *)(w[2]);
!     t_float *out = (t_float *)(w[3]);
!     int n = (int)(w[4]);
!     while (n--) *out++ = *in1++ + *in2++; 
!     return (w+5);
! }
! 
! t_int *plus_perf8(t_int *w)
! {
!     t_float *in1 = (t_float *)(w[1]);
!     t_float *in2 = (t_float *)(w[2]);
!     t_float *out = (t_float *)(w[3]);
!     int n = (int)(w[4]);
!     for (; n; n -= 8, in1 += 8, in2 += 8, out += 8)
!     {
!         float f0 = in1[0], f1 = in1[1], f2 = in1[2], f3 = in1[3];
!         float f4 = in1[4], f5 = in1[5], f6 = in1[6], f7 = in1[7];
! 
!         float g0 = in2[0], g1 = in2[1], g2 = in2[2], g3 = in2[3];
!         float g4 = in2[4], g5 = in2[5], g6 = in2[6], g7 = in2[7];
! 
!         out[0] = f0 + g0; out[1] = f1 + g1; out[2] = f2 + g2; out[3] = f3 + g3;
!         out[4] = f4 + g4; out[5] = f5 + g5; out[6] = f6 + g6; out[7] = f7 + g7;
!     }
!     return (w+5);
! }
! 
! t_int *scalarplus_perform(t_int *w)
! {
!     t_float *in = (t_float *)(w[1]);
!     t_float f = *(t_float *)(w[2]);
!     t_float *out = (t_float *)(w[3]);
!     int n = (int)(w[4]);
!     while (n--) *out++ = *in++ + f; 
!     return (w+5);
! }
! 
! t_int *scalarplus_perf8(t_int *w)
! {
!     t_float *in = (t_float *)(w[1]);
!     t_float g = *(t_float *)(w[2]);
!     t_float *out = (t_float *)(w[3]);
!     int n = (int)(w[4]);
!     for (; n; n -= 8, in += 8, out += 8)
!     {
!         float f0 = in[0], f1 = in[1], f2 = in[2], f3 = in[3];
!         float f4 = in[4], f5 = in[5], f6 = in[6], f7 = in[7];
  
!         out[0] = f0 + g; out[1] = f1 + g; out[2] = f2 + g; out[3] = f3 + g;
!         out[4] = f4 + g; out[5] = f5 + g; out[6] = f6 + g; out[7] = f7 + g;
!     }
!     return (w+5);
! }
  
  void dsp_add_plus(t_sample *in1, t_sample *in2, t_sample *out, int n)
--- 47,94 ----
  }
  
! #define PERFORM(NAME,EXPR) \
! t_int *NAME##_perform(t_int *w) { \
!     t_float *in1 = (t_float *)w[1], *in2 = (t_float *)w[2], *out = (t_float *)w[3]; \
!     int n = (int)w[4]; \
!     while (n--) {t_float a=*in1++, b=*in2++; *out++ = (EXPR);} \
!     return w+5;} \
! t_int *NAME##_perf8(t_int *w) { \
!     t_float *in1 = (t_float *)w[1], *in2 = (t_float *)w[2], *out = (t_float *)w[3]; \
!     int n = (int)w[4]; \
!     for (; n; n -= 8, in1 += 8, in2 += 8, out += 8) { \
!         {t_float a=in1[0], b=in2[0]; out[0] = (EXPR);} \
!         {t_float a=in1[1], b=in2[1]; out[1] = (EXPR);} \
!         {t_float a=in1[2], b=in2[2]; out[2] = (EXPR);} \
!         {t_float a=in1[3], b=in2[3]; out[3] = (EXPR);} \
!         {t_float a=in1[4], b=in2[4]; out[4] = (EXPR);} \
!         {t_float a=in1[5], b=in2[5]; out[5] = (EXPR);} \
!         {t_float a=in1[6], b=in2[6]; out[6] = (EXPR);} \
!         {t_float a=in1[7], b=in2[7]; out[7] = (EXPR);}} \
!     return w+5;} \
! t_int *scalar##NAME##_perform(t_int *w) { \
!     t_float *in = (t_float *)w[1]; t_float b = *(t_float *)w[2]; t_float *out = (t_float *)w[3]; \
!     int n = (int)w[4]; \
!     while (n--) {t_float a=*in++; *out++ = (EXPR);} \
!     return w+5;} \
! t_int *scalar##NAME##_perf8(t_int *w) { \
!     t_float *in = (t_float *)w[1]; t_float b = *(t_float *)w[2]; t_float *out = (t_float *)w[3]; \
!     int n = (int)w[4]; \
!     for (; n; n -= 8, in += 8, out += 8) { \
! 	{t_float a=in[0]; out[0] = (EXPR);} \
! 	{t_float a=in[1]; out[1] = (EXPR);} \
! 	{t_float a=in[2]; out[2] = (EXPR);} \
! 	{t_float a=in[3]; out[3] = (EXPR);} \
! 	{t_float a=in[4]; out[4] = (EXPR);} \
! 	{t_float a=in[5]; out[5] = (EXPR);} \
! 	{t_float a=in[6]; out[6] = (EXPR);} \
! 	{t_float a=in[7]; out[7] = (EXPR);}} \
!     return w+5;}
  
! PERFORM(plus,a+b)
! PERFORM(minus,a-b)
! PERFORM(times,a*b)
! //PERFORM(over,a/b)
! PERFORM(min,a<b?a:b)
! PERFORM(max,a>b?a:b)
  
  void dsp_add_plus(t_sample *in1, t_sample *in2, t_sample *out, int n)
***************
*** 176,236 ****
  }
  
- t_int *minus_perform(t_int *w)
- {
-     t_float *in1 = (t_float *)(w[1]);
-     t_float *in2 = (t_float *)(w[2]);
-     t_float *out = (t_float *)(w[3]);
-     int n = (int)(w[4]);
-     while (n--) *out++ = *in1++ - *in2++; 
-     return (w+5);
- }
- 
- t_int *minus_perf8(t_int *w)
- {
-     t_float *in1 = (t_float *)(w[1]);
-     t_float *in2 = (t_float *)(w[2]);
-     t_float *out = (t_float *)(w[3]);
-     int n = (int)(w[4]);
-     for (; n; n -= 8, in1 += 8, in2 += 8, out += 8)
-     {
-         float f0 = in1[0], f1 = in1[1], f2 = in1[2], f3 = in1[3];
-         float f4 = in1[4], f5 = in1[5], f6 = in1[6], f7 = in1[7];
- 
-         float g0 = in2[0], g1 = in2[1], g2 = in2[2], g3 = in2[3];
-         float g4 = in2[4], g5 = in2[5], g6 = in2[6], g7 = in2[7];
- 
-         out[0] = f0 - g0; out[1] = f1 - g1; out[2] = f2 - g2; out[3] = f3 - g3;
-         out[4] = f4 - g4; out[5] = f5 - g5; out[6] = f6 - g6; out[7] = f7 - g7;
-     }
-     return (w+5);
- }
- 
- t_int *scalarminus_perform(t_int *w)
- {
-     t_float *in = (t_float *)(w[1]);
-     t_float f = *(t_float *)(w[2]);
-     t_float *out = (t_float *)(w[3]);
-     int n = (int)(w[4]);
-     while (n--) *out++ = *in++ - f; 
-     return (w+5);
- }
- 
- t_int *scalarminus_perf8(t_int *w)
- {
-     t_float *in = (t_float *)(w[1]);
-     t_float g = *(t_float *)(w[2]);
-     t_float *out = (t_float *)(w[3]);
-     int n = (int)(w[4]);
-     for (; n; n -= 8, in += 8, out += 8)
-     {
-         float f0 = in[0], f1 = in[1], f2 = in[2], f3 = in[3];
-         float f4 = in[4], f5 = in[5], f6 = in[6], f7 = in[7];
- 
-         out[0] = f0 - g; out[1] = f1 - g; out[2] = f2 - g; out[3] = f3 - g;
-         out[4] = f4 - g; out[5] = f5 - g; out[6] = f6 - g; out[7] = f7 - g;
-     }
-     return (w+5);
- }
- 
  static void minus_dsp(t_minus *x, t_signal **sp)
  {
--- 164,167 ----
***************
*** 298,331 ****
  }
  
- t_int *times_perform(t_int *w)
- {
-     t_float *in1 = (t_float *)(w[1]);
-     t_float *in2 = (t_float *)(w[2]);
-     t_float *out = (t_float *)(w[3]);
-     int n = (int)(w[4]);
-     while (n--) *out++ = *in1++ * *in2++; 
-     return (w+5);
- }
- 
- t_int *times_perf8(t_int *w)
- {
-     t_float *in1 = (t_float *)(w[1]);
-     t_float *in2 = (t_float *)(w[2]);
-     t_float *out = (t_float *)(w[3]);
-     int n = (int)(w[4]);
-     for (; n; n -= 8, in1 += 8, in2 += 8, out += 8)
-     {
-         float f0 = in1[0], f1 = in1[1], f2 = in1[2], f3 = in1[3];
-         float f4 = in1[4], f5 = in1[5], f6 = in1[6], f7 = in1[7];
- 
-         float g0 = in2[0], g1 = in2[1], g2 = in2[2], g3 = in2[3];
-         float g4 = in2[4], g5 = in2[5], g6 = in2[6], g7 = in2[7];
- 
-         out[0] = f0 * g0; out[1] = f1 * g1; out[2] = f2 * g2; out[3] = f3 * g3;
-         out[4] = f4 * g4; out[5] = f5 * g5; out[6] = f6 * g6; out[7] = f7 * g7;
-     }
-     return (w+5);
- }
- 
  /* T.Grill - squaring: optimized * for equal input signals */
  t_int *sqr_perf8(t_int *w)
--- 229,232 ----
***************
*** 346,376 ****
  }
  
- t_int *scalartimes_perform(t_int *w)
- {
-     t_float *in = (t_float *)(w[1]);
-     t_float f = *(t_float *)(w[2]);
-     t_float *out = (t_float *)(w[3]);
-     int n = (int)(w[4]);
-     while (n--) *out++ = *in++ * f; 
-     return (w+5);
- }
- 
- t_int *scalartimes_perf8(t_int *w)
- {
-     t_float *in = (t_float *)(w[1]);
-     t_float g = *(t_float *)(w[2]);
-     t_float *out = (t_float *)(w[3]);
-     int n = (int)(w[4]);
-     for (; n; n -= 8, in += 8, out += 8)
-     {
-         float f0 = in[0], f1 = in[1], f2 = in[2], f3 = in[3];
-         float f4 = in[4], f5 = in[5], f6 = in[6], f7 = in[7];
- 
-         out[0] = f0 * g; out[1] = f1 * g; out[2] = f2 * g; out[3] = f3 * g;
-         out[4] = f4 * g; out[5] = f5 * g; out[6] = f6 * g; out[7] = f7 * g;
-     }
-     return (w+5);
- }
- 
  /* T.Grill - added optimization for equal input signals */
  static void times_dsp(t_times *x, t_signal **sp)
--- 247,250 ----
***************
*** 583,654 ****
  }
  
- t_int *max_perform(t_int *w)
- {
-     t_float *in1 = (t_float *)(w[1]);
-     t_float *in2 = (t_float *)(w[2]);
-     t_float *out = (t_float *)(w[3]);
-     int n = (int)(w[4]);
-     while (n--)
-     {
-         float f = *in1++, g = *in2++;
-         *out++ = (f > g ? f : g); 
-     }
-     return (w+5);
- }
- 
- t_int *max_perf8(t_int *w)
- {
-     t_float *in1 = (t_float *)(w[1]);
-     t_float *in2 = (t_float *)(w[2]);
-     t_float *out = (t_float *)(w[3]);
-     int n = (int)(w[4]);
-     for (; n; n -= 8, in1 += 8, in2 += 8, out += 8)
-     {
-         float f0 = in1[0], f1 = in1[1], f2 = in1[2], f3 = in1[3];
-         float f4 = in1[4], f5 = in1[5], f6 = in1[6], f7 = in1[7];
- 
-         float g0 = in2[0], g1 = in2[1], g2 = in2[2], g3 = in2[3];
-         float g4 = in2[4], g5 = in2[5], g6 = in2[6], g7 = in2[7];
- 
-         out[0] = (f0 > g0 ? f0 : g0); out[1] = (f1 > g1 ? f1 : g1);
-         out[2] = (f2 > g2 ? f2 : g2); out[3] = (f3 > g3 ? f3 : g3);
-         out[4] = (f4 > g4 ? f4 : g4); out[5] = (f5 > g5 ? f5 : g5);
-         out[6] = (f6 > g6 ? f6 : g6); out[7] = (f7 > g7 ? f7 : g7);
-     }
-     return (w+5);
- }
- 
- t_int *scalarmax_perform(t_int *w)
- {
-     t_float *in = (t_float *)(w[1]);
-     t_float f = *(t_float *)(w[2]);
-     t_float *out = (t_float *)(w[3]);
-     int n = (int)(w[4]);
-     while (n--)
-     {
-         t_float g = *in++;
-         *out++ = (f > g ? f : g); 
-     }
-     return (w+5);
- }
- 
- t_int *scalarmax_perf8(t_int *w)
- {
-     t_float *in = (t_float *)(w[1]);
-     t_float g = *(t_float *)(w[2]);
-     t_float *out = (t_float *)(w[3]);
-     int n = (int)(w[4]);
-     for (; n; n -= 8, in += 8, out += 8)
-     {
-         float f0 = in[0], f1 = in[1], f2 = in[2], f3 = in[3];
-         float f4 = in[4], f5 = in[5], f6 = in[6], f7 = in[7];
- 
-         out[0] = (f0 > g ? f0 : g); out[1] = (f1 > g ? f1 : g);
-         out[2] = (f2 > g ? f2 : g); out[3] = (f3 > g ? f3 : g);
-         out[4] = (f4 > g ? f4 : g); out[5] = (f5 > g ? f5 : g);
-         out[6] = (f6 > g ? f6 : g); out[7] = (f7 > g ? f7 : g);
-     }
-     return (w+5);
- }
  
  static void max_dsp(t_max *x, t_signal **sp)
--- 457,460 ----
***************
*** 716,788 ****
  }
  
- t_int *min_perform(t_int *w)
- {
-     t_float *in1 = (t_float *)(w[1]);
-     t_float *in2 = (t_float *)(w[2]);
-     t_float *out = (t_float *)(w[3]);
-     int n = (int)(w[4]);
-     while (n--)
-     {
-         float f = *in1++, g = *in2++;
-         *out++ = (f < g ? f : g); 
-     }
-     return (w+5);
- }
- 
- t_int *min_perf8(t_int *w)
- {
-     t_float *in1 = (t_float *)(w[1]);
-     t_float *in2 = (t_float *)(w[2]);
-     t_float *out = (t_float *)(w[3]);
-     int n = (int)(w[4]);
-     for (; n; n -= 8, in1 += 8, in2 += 8, out += 8)
-     {
-         float f0 = in1[0], f1 = in1[1], f2 = in1[2], f3 = in1[3];
-         float f4 = in1[4], f5 = in1[5], f6 = in1[6], f7 = in1[7];
- 
-         float g0 = in2[0], g1 = in2[1], g2 = in2[2], g3 = in2[3];
-         float g4 = in2[4], g5 = in2[5], g6 = in2[6], g7 = in2[7];
- 
-         out[0] = (f0 < g0 ? f0 : g0); out[1] = (f1 < g1 ? f1 : g1);
-         out[2] = (f2 < g2 ? f2 : g2); out[3] = (f3 < g3 ? f3 : g3);
-         out[4] = (f4 < g4 ? f4 : g4); out[5] = (f5 < g5 ? f5 : g5);
-         out[6] = (f6 < g6 ? f6 : g6); out[7] = (f7 < g7 ? f7 : g7);
-     }
-     return (w+5);
- }
- 
- t_int *scalarmin_perform(t_int *w)
- {
-     t_float *in = (t_float *)(w[1]);
-     t_float f = *(t_float *)(w[2]);
-     t_float *out = (t_float *)(w[3]);
-     int n = (int)(w[4]);
-     while (n--)
-     {
-         t_float g = *in++;
-         *out++ = (f < g ? f : g); 
-     }
-     return (w+5);
- }
- 
- t_int *scalarmin_perf8(t_int *w)
- {
-     t_float *in = (t_float *)(w[1]);
-     t_float g = *(t_float *)(w[2]);
-     t_float *out = (t_float *)(w[3]);
-     int n = (int)(w[4]);
-     for (; n; n -= 8, in += 8, out += 8)
-     {
-         float f0 = in[0], f1 = in[1], f2 = in[2], f3 = in[3];
-         float f4 = in[4], f5 = in[5], f6 = in[6], f7 = in[7];
- 
-         out[0] = (f0 < g ? f0 : g); out[1] = (f1 < g ? f1 : g);
-         out[2] = (f2 < g ? f2 : g); out[3] = (f3 < g ? f3 : g);
-         out[4] = (f4 < g ? f4 : g); out[5] = (f5 < g ? f5 : g);
-         out[6] = (f6 < g ? f6 : g); out[7] = (f7 < g ? f7 : g);
-     }
-     return (w+5);
- }
- 
  static void min_dsp(t_min *x, t_signal **sp)
  {
--- 522,525 ----





More information about the Pd-cvs mailing list