changeset 25069:d2f7027f0556

Avoid some casts by changing int8_t* to void* in af_scaletempo
author reimar
date Sun, 18 Nov 2007 14:57:59 +0000
parents 4b14d188ed34
children 60b34bf9a41e
files libaf/af_scaletempo.c
diffstat 1 files changed, 27 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- a/libaf/af_scaletempo.c	Sun Nov 18 13:17:00 2007 +0000
+++ b/libaf/af_scaletempo.c	Sun Nov 18 14:57:59 2007 +0000
@@ -60,14 +60,14 @@
   int     samples_standing;
   int     bytes_overlap;
   int     bytes_standing;
-  int8_t* buf_overlap;
-  int8_t* table_blend;
-  void    (*output_overlap)(struct af_scaletempo_s* s, int8_t* out_buf, int bytes_off);
+  void*   buf_overlap;
+  void*   table_blend;
+  void    (*output_overlap)(struct af_scaletempo_s* s, void* out_buf, int bytes_off);
   // best overlap
   int     frames_search;
   int     num_channels;
-  int8_t* buf_pre_corr;
-  int8_t* table_window;
+  void*   buf_pre_corr;
+  void*   table_window;
   int     (*best_overlap_offset)(struct af_scaletempo_s* s);
   short   shift_corr;
   // command line
@@ -123,9 +123,10 @@
   int best_off = 0;
   int i, off;
 
-  pw  = (float*)s->table_window;
-  po  = (float*)s->buf_overlap + s->num_channels;
-  ppc = (float*)s->buf_pre_corr;
+  pw  = s->table_window;
+  po  = s->buf_overlap;
+  po += s->num_channels;
+  ppc = s->buf_pre_corr;
   for (i=s->num_channels; i<s->samples_overlap; i++) {
     *ppc++ = *pw++ * *po++;
   }
@@ -134,7 +135,7 @@
   for (off=0; off<s->frames_search; off++) {
     float corr = 0;
     float* ps = search_start;
-    ppc = (float*)s->buf_pre_corr;
+    ppc = s->buf_pre_corr;
     for (i=s->num_channels; i<s->samples_overlap; i++) {
       corr += *ppc++ * *ps++;
     }
@@ -156,9 +157,10 @@
   int best_off = 0;
   int i, off;
 
-  pw  = (int32_t*)s->table_window;
-  po  = (int16_t*)s->buf_overlap + s->num_channels;
-  ppc = (int32_t*)s->buf_pre_corr;
+  pw  = s->table_window;
+  po  = s->buf_overlap;
+  po += s->num_channels;
+  ppc = s->buf_pre_corr;
   for (i=s->num_channels; i<s->samples_overlap; i++) {
     *ppc++ = ( *pw++ * *po++ ) >> 15;
   }
@@ -167,7 +169,7 @@
   for (off=0; off<s->frames_search; off++) {
     int32_t corr = 0;
     int16_t* ps = search_start;
-    ppc = (int32_t*)s->buf_pre_corr;
+    ppc = s->buf_pre_corr;
     for (i=s->num_channels; i<s->samples_overlap; i++) {
       corr += ( *ppc++ * *ps++ ) >> s->shift_corr;
     }
@@ -181,24 +183,24 @@
   return best_off * 2 * s->num_channels;
 }
 
-static void output_overlap_float(af_scaletempo_t* s, int8_t* buf_out,
+static void output_overlap_float(af_scaletempo_t* s, void* buf_out,
 				  int bytes_off)
 {
-  float* pout = (float*)buf_out;
-  float* pb   = (float*)s->table_blend;
-  float* po   = (float*)s->buf_overlap;
+  float* pout = buf_out;
+  float* pb   = s->table_blend;
+  float* po   = s->buf_overlap;
   float* pin  = (float*)(s->buf_queue + bytes_off);
   int i;
   for (i=0; i<s->samples_overlap; i++) {
     *pout++ = *po - *pb++ * ( *po - *pin++ ); po++;
   }
 }
-static void output_overlap_s16(af_scaletempo_t* s, int8_t* buf_out,
+static void output_overlap_s16(af_scaletempo_t* s, void* buf_out,
 			       int bytes_off)
 {
-  int16_t* pout = (int16_t*)buf_out;
-  int32_t* pb   = (int32_t*)s->table_blend;
-  int16_t* po   = (int16_t*)s->buf_overlap;
+  int16_t* pout = buf_out;
+  int32_t* pb   = s->table_blend;
+  int16_t* po   = s->buf_overlap;
   int16_t* pin  = (int16_t*)(s->buf_queue + bytes_off);
   int i;
   for (i=0; i<s->samples_overlap; i++) {
@@ -333,7 +335,7 @@
       }
       bzero(s->buf_overlap, s->bytes_overlap);
       if (use_int) {
-        int32_t* pb = (int32_t*)s->table_blend;
+        int32_t* pb = s->table_blend;
         int64_t blend = 0;
         for (i=0; i<frames_overlap; i++) {
           int32_t v = blend / frames_overlap;
@@ -344,7 +346,7 @@
         }
         s->output_overlap = output_overlap_s16;
       } else {
-        float* pb = (float*)s->table_blend;
+        float* pb = s->table_blend;
         for (i=0; i<frames_overlap; i++) {
           float v = i / (float)frames_overlap;
           for (j=0; j<nch; j++) {
@@ -369,7 +371,7 @@
           af_msg(AF_MSG_FATAL, "[scaletempo] Out of memory\n");
           return AF_ERROR;
         }
-        pw = (int32_t*)s->table_window;
+        pw = s->table_window;
         for (i=1; i<frames_overlap; i++) {
           int32_t v = ( i * (t - i) * n ) >> 15;
           for (j=0; j<nch; j++) {
@@ -386,7 +388,7 @@
           af_msg(AF_MSG_FATAL, "[scaletempo] Out of memory\n");
           return AF_ERROR;
         }
-        pw = (float*)s->table_window;
+        pw = s->table_window;
         for (i=1; i<frames_overlap; i++) {
           float v = i * (frames_overlap - i);
           for (j=0; j<nch; j++) {