shithub: aubio

Download patch

ref: 1120f86f4c27475f0ae23afaa06d2a2e5996ecd8
parent: c4d251c12cfccd0fb5c64e57c3d36e79d12b2ec9
author: Paul Brossier <piem@piem.org>
date: Thu Apr 21 14:21:43 EDT 2016

src/{fvec,cvec,fmat,lvec}.{c,h}: added const qualifiers to unmodified pointers

--- a/src/cvec.c
+++ b/src/cvec.c
@@ -21,7 +21,7 @@
 #include "aubio_priv.h"
 #include "cvec.h"
 
-cvec_t * new_cvec( uint_t length) {
+cvec_t * new_cvec(uint_t length) {
   cvec_t * s;
   if ((sint_t)length <= 0) {
     return NULL;
@@ -55,17 +55,17 @@
   return s->phas[position];
 }
 
-smpl_t * cvec_norm_get_data (cvec_t *s) {
+smpl_t * cvec_norm_get_data (const cvec_t *s) {
   return s->norm;
 }
 
-smpl_t * cvec_phas_get_data (cvec_t *s) {
+smpl_t * cvec_phas_get_data (const cvec_t *s) {
   return s->phas;
 }
 
 /* helper functions */
 
-void cvec_print(cvec_t *s) {
+void cvec_print(const cvec_t *s) {
   uint_t j;
   AUBIO_MSG("norm: ");
   for (j=0; j< s->length; j++) {
@@ -79,7 +79,7 @@
   AUBIO_MSG("\n");
 }
 
-void cvec_copy(cvec_t *s, cvec_t *t) {
+void cvec_copy(const cvec_t *s, cvec_t *t) {
   if (s->length != t->length) {
     AUBIO_ERR("trying to copy %d elements to %d elements \n",
         s->length, t->length);
--- a/src/cvec.h
+++ b/src/cvec.h
@@ -150,7 +150,7 @@
   \param s vector to read from
 
 */
-smpl_t * cvec_norm_get_data (cvec_t *s);
+smpl_t * cvec_norm_get_data (const cvec_t *s);
 
 /** read phase data from a complex buffer
 
@@ -162,7 +162,7 @@
   \param s vector to read from
 
 */
-smpl_t * cvec_phas_get_data (cvec_t *s);
+smpl_t * cvec_phas_get_data (const cvec_t *s);
 
 /** print out cvec data
 
@@ -169,7 +169,7 @@
   \param s vector to print out
 
 */
-void cvec_print(cvec_t *s);
+void cvec_print(const cvec_t *s);
 
 /** make a copy of a vector
 
@@ -177,7 +177,7 @@
   \param t vector to copy to
 
 */
-void cvec_copy(cvec_t *s, cvec_t *t);
+void cvec_copy(const cvec_t *s, cvec_t *t);
 
 /** set all norm elements to a given value
 
--- a/src/fmat.c
+++ b/src/fmat.c
@@ -53,27 +53,27 @@
   s->data[channel][position] = data;
 }
 
-smpl_t fmat_get_sample(fmat_t *s, uint_t channel, uint_t position) {
+smpl_t fmat_get_sample(const fmat_t *s, uint_t channel, uint_t position) {
   return s->data[channel][position];
 }
 
-void fmat_get_channel(fmat_t *s, uint_t channel, fvec_t *output) {
+void fmat_get_channel(const fmat_t *s, uint_t channel, fvec_t *output) {
   output->data = s->data[channel];
   output->length = s->length;
   return;
 }
 
-smpl_t * fmat_get_channel_data(fmat_t *s, uint_t channel) {
+smpl_t * fmat_get_channel_data(const fmat_t *s, uint_t channel) {
   return s->data[channel];
 }
 
-smpl_t ** fmat_get_data(fmat_t *s) {
+smpl_t ** fmat_get_data(const fmat_t *s) {
   return s->data;
 }
 
 /* helper functions */
 
-void fmat_print(fmat_t *s) {
+void fmat_print(const fmat_t *s) {
   uint_t i,j;
   for (i=0; i< s->height; i++) {
     for (j=0; j< s->length; j++) {
@@ -116,7 +116,7 @@
   }
 }
 
-void fmat_weight(fmat_t *s, fmat_t *weight) {
+void fmat_weight(fmat_t *s, const fmat_t *weight) {
   uint_t i,j;
   uint_t length = MIN(s->length, weight->length);
   for (i=0; i< s->height; i++) {
@@ -126,7 +126,7 @@
   }
 }
 
-void fmat_copy(fmat_t *s, fmat_t *t) {
+void fmat_copy(const fmat_t *s, fmat_t *t) {
   uint_t i;
 #if !HAVE_MEMCPY_HACKS
   uint_t j;
@@ -154,7 +154,7 @@
 #endif
 }
 
-void fmat_vecmul(fmat_t *s, fvec_t *scale, fvec_t *output) {
+void fmat_vecmul(const fmat_t *s, const fvec_t *scale, fvec_t *output) {
   uint_t k;
 #if 0
   assert(s->height == output->length);
--- a/src/fmat.h
+++ b/src/fmat.h
@@ -65,7 +65,7 @@
   \param position sample position to read from
 
 */
-smpl_t fmat_get_sample(fmat_t *s, uint_t channel, uint_t position);
+smpl_t fmat_get_sample(const fmat_t *s, uint_t channel, uint_t position);
 
 /** write sample value in a buffer
 
@@ -84,7 +84,7 @@
   \param output ::fvec_t to output to
 
 */
-void fmat_get_channel (fmat_t *s, uint_t channel, fvec_t *output);
+void fmat_get_channel (const fmat_t *s, uint_t channel, fvec_t *output);
 
 /** get vector buffer from an fmat data
 
@@ -92,7 +92,7 @@
   \param channel channel to read from
 
 */
-smpl_t * fmat_get_channel_data (fmat_t *s, uint_t channel);
+smpl_t * fmat_get_channel_data (const fmat_t *s, uint_t channel);
 
 /** read data from a buffer
 
@@ -99,7 +99,7 @@
   \param s vector to read from
 
 */
-smpl_t ** fmat_get_data(fmat_t *s);
+smpl_t ** fmat_get_data(const fmat_t *s);
 
 /** print out fmat data
 
@@ -106,7 +106,7 @@
   \param s vector to print out
 
 */
-void fmat_print(fmat_t *s);
+void fmat_print(const fmat_t *s);
 
 /** set all elements to a given value
 
@@ -146,7 +146,7 @@
   \param weight weighting coefficients
 
 */
-void fmat_weight(fmat_t *s, fmat_t *weight);
+void fmat_weight(fmat_t *s, const fmat_t *weight);
 
 /** make a copy of a matrix
 
@@ -154,7 +154,7 @@
   \param t vector to copy to
 
 */
-void fmat_copy(fmat_t *s, fmat_t *t);
+void fmat_copy(const fmat_t *s, fmat_t *t);
 
 /* compute the product of a matrix by a vector
 
@@ -163,7 +163,7 @@
    \param output vector to store restults in
 
 */
-void fmat_vecmul(fmat_t *s, fvec_t *scale, fvec_t *output);
+void fmat_vecmul(const fmat_t *s, const fvec_t *scale, fvec_t *output);
 
 #ifdef __cplusplus
 }
--- a/src/fvec.c
+++ b/src/fvec.c
@@ -21,7 +21,7 @@
 #include "aubio_priv.h"
 #include "fvec.h"
 
-fvec_t * new_fvec( uint_t length) {
+fvec_t * new_fvec(uint_t length) {
   fvec_t * s;
   if ((sint_t)length <= 0) {
     return NULL;
@@ -41,17 +41,17 @@
   s->data[position] = data;
 }
 
-smpl_t fvec_get_sample(fvec_t *s, uint_t position) {
+smpl_t fvec_get_sample(const fvec_t *s, uint_t position) {
   return s->data[position];
 }
 
-smpl_t * fvec_get_data(fvec_t *s) {
+smpl_t * fvec_get_data(const fvec_t *s) {
   return s->data;
 }
 
 /* helper functions */
 
-void fvec_print(fvec_t *s) {
+void fvec_print(const fvec_t *s) {
   uint_t j;
   for (j=0; j< s->length; j++) {
     AUBIO_MSG(AUBIO_SMPL_FMT " ", s->data[j]);
@@ -95,7 +95,7 @@
   }
 }
 
-void fvec_weight(fvec_t *s, fvec_t *weight) {
+void fvec_weight(fvec_t *s, const fvec_t *weight) {
 #ifndef HAVE_ACCELERATE
   uint_t j;
   uint_t length = MIN(s->length, weight->length);
@@ -107,7 +107,7 @@
 #endif /* HAVE_ACCELERATE */
 }
 
-void fvec_weighted_copy(fvec_t *in, fvec_t *weight, fvec_t *out) {
+void fvec_weighted_copy(const fvec_t *in, const fvec_t *weight, fvec_t *out) {
 #ifndef HAVE_ACCELERATE
   uint_t j;
   uint_t length = MIN(out->length, weight->length);
@@ -119,7 +119,7 @@
 #endif /* HAVE_ACCELERATE */
 }
 
-void fvec_copy(fvec_t *s, fvec_t *t) {
+void fvec_copy(const fvec_t *s, fvec_t *t) {
   if (s->length != t->length) {
     AUBIO_ERR("trying to copy %d elements to %d elements \n",
         s->length, t->length);
--- a/src/fvec.h
+++ b/src/fvec.h
@@ -89,7 +89,7 @@
   \param position sample position to read from
 
 */
-smpl_t fvec_get_sample(fvec_t *s, uint_t position);
+smpl_t fvec_get_sample(const fvec_t *s, uint_t position);
 
 /** write sample value in a buffer
 
@@ -105,7 +105,7 @@
   \param s vector to read from
 
 */
-smpl_t * fvec_get_data(fvec_t *s);
+smpl_t * fvec_get_data(const fvec_t *s);
 
 /** print out fvec data
 
@@ -112,7 +112,7 @@
   \param s vector to print out
 
 */
-void fvec_print(fvec_t *s);
+void fvec_print(const fvec_t *s);
 
 /** set all elements to a given value
 
@@ -152,7 +152,7 @@
   \param weight weighting coefficients
 
 */
-void fvec_weight(fvec_t *s, fvec_t *weight);
+void fvec_weight(fvec_t *s, const fvec_t *weight);
 
 /** make a copy of a vector
 
@@ -160,7 +160,7 @@
   \param t vector to copy to
 
 */
-void fvec_copy(fvec_t *s, fvec_t *t);
+void fvec_copy(const fvec_t *s, fvec_t *t);
 
 /** make a copy of a vector, applying weights to each element
 
@@ -169,7 +169,7 @@
   \param out output vector
 
 */
-void fvec_weighted_copy(fvec_t *in, fvec_t *weight, fvec_t *out);
+void fvec_weighted_copy(const fvec_t *in, const fvec_t *weight, fvec_t *out);
 
 #ifdef __cplusplus
 }
--- a/src/lvec.c
+++ b/src/lvec.c
@@ -21,7 +21,7 @@
 #include "aubio_priv.h"
 #include "lvec.h"
 
-lvec_t * new_lvec( uint_t length) {
+lvec_t * new_lvec(uint_t length) {
   lvec_t * s;
   if ((sint_t)length <= 0) {
     return NULL;
@@ -45,13 +45,13 @@
   return s->data[position];
 }
 
-lsmp_t * lvec_get_data(lvec_t *s) {
+lsmp_t * lvec_get_data(const lvec_t *s) {
   return s->data;
 }
 
 /* helper functions */
 
-void lvec_print(lvec_t *s) {
+void lvec_print(const lvec_t *s) {
   uint_t j;
   for (j=0; j< s->length; j++) {
     AUBIO_MSG(AUBIO_LSMP_FMT " ", s->data[j]);
--- a/src/lvec.h
+++ b/src/lvec.h
@@ -80,7 +80,7 @@
   \param s vector to read from
 
 */
-lsmp_t * lvec_get_data(lvec_t *s);
+lsmp_t * lvec_get_data(const lvec_t *s);
 
 /** print out lvec data
 
@@ -87,7 +87,7 @@
   \param s vector to print out
 
 */
-void lvec_print(lvec_t *s);
+void lvec_print(const lvec_t *s);
 
 /** set all elements to a given value