Skip to content

Commit

Permalink
Supress warnings on MSVC
Browse files Browse the repository at this point in the history
  • Loading branch information
Flamefire committed Aug 9, 2019
1 parent 49aa63a commit ed8b07f
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 1 deletion.
19 changes: 19 additions & 0 deletions src/src_sinc.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,20 @@
typedef int32_t increment_t ;
typedef float coeff_t ;

#ifdef _MSC_VER
#define MSVC_DISABLE_WARNING(n) __pragma(warning(push)) \
__pragma(warning(disable:n))
#define MSVC_POP_WARNING() __pragma(warning(pop))
#else
#define MSVC_DISABLE_WARNING(n)
#define MSVC_POP_WARNING()
#endif

MSVC_DISABLE_WARNING(4305)
#include "fastest_coeffs.h"
#include "mid_qual_coeffs.h"
#include "high_qual_coeffs.h"
MSVC_POP_WARNING()

typedef struct
{ int sinc_magic_marker ;
Expand Down Expand Up @@ -474,8 +485,10 @@ calc_output_stereo (SINC_FILTER *filter, increment_t increment, increment_t star
}
while (filter_index > MAKE_INCREMENT_T (0)) ;

MSVC_DISABLE_WARNING(4244)
output [0] = scale * (left [0] + right [0]) ;
output [1] = scale * (left [1] + right [1]) ;
MSVC_POP_WARNING()
} /* calc_output_stereo */

static int
Expand Down Expand Up @@ -625,10 +638,12 @@ calc_output_quad (SINC_FILTER *filter, increment_t increment, increment_t start_
}
while (filter_index > MAKE_INCREMENT_T (0)) ;

MSVC_DISABLE_WARNING(4244)
output [0] = scale * (left [0] + right [0]) ;
output [1] = scale * (left [1] + right [1]) ;
output [2] = scale * (left [2] + right [2]) ;
output [3] = scale * (left [3] + right [3]) ;
MSVC_POP_WARNING()
} /* calc_output_quad */

static int
Expand Down Expand Up @@ -782,12 +797,14 @@ calc_output_hex (SINC_FILTER *filter, increment_t increment, increment_t start_f
}
while (filter_index > MAKE_INCREMENT_T (0)) ;

MSVC_DISABLE_WARNING(4244)
output [0] = scale * (left [0] + right [0]) ;
output [1] = scale * (left [1] + right [1]) ;
output [2] = scale * (left [2] + right [2]) ;
output [3] = scale * (left [3] + right [3]) ;
output [4] = scale * (left [4] + right [4]) ;
output [5] = scale * (left [5] + right [5]) ;
MSVC_POP_WARNING()
} /* calc_output_hex */

static int
Expand Down Expand Up @@ -1018,6 +1035,7 @@ calc_output_multi (SINC_FILTER *filter, increment_t increment, increment_t start
ch = channels ;
do
{
MSVC_DISABLE_WARNING(4244)
switch (ch % 8)
{ default :
ch -- ;
Expand Down Expand Up @@ -1052,6 +1070,7 @@ calc_output_multi (SINC_FILTER *filter, increment_t increment, increment_t start
output [ch] = scale * (left [ch] + right [ch]) ;
} ;
}
MSVC_POP_WARNING()
while (ch > 0) ;

return ;
Expand Down
4 changes: 4 additions & 0 deletions tests/float_short_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,14 @@ main (void)
static void
float_to_short_test (void)
{
MSVC_DISABLE_WARNING(4305)
static float fpos [] =
{ 0.95, 0.99, 1.0, 1.01, 1.1, 2.0, 11.1, 111.1, 2222.2, 33333.3
} ;
static float fneg [] =
{ -0.95, -0.99, -1.0, -1.01, -1.1, -2.0, -11.1, -111.1, -2222.2, -33333.3
} ;
MSVC_POP_WARNING()

static short out [MAX (ARRAY_LEN (fpos), ARRAY_LEN (fneg))] ;

Expand Down Expand Up @@ -115,12 +117,14 @@ short_to_float_test (void)
static void
float_to_int_test (void)
{
MSVC_DISABLE_WARNING(4305)
static float fpos [] =
{ 0.95, 0.99, 1.0, 1.01, 1.1, 2.0, 11.1, 111.1, 2222.2, 33333.3
} ;
static float fneg [] =
{ -0.95, -0.99, -1.0, -1.01, -1.1, -2.0, -11.1, -111.1, -2222.2, -33333.3
} ;
MSVC_POP_WARNING()

static int out [MAX (ARRAY_LEN (fpos), ARRAY_LEN (fneg))] ;

Expand Down
2 changes: 1 addition & 1 deletion tests/termination_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ stream_test (int converter, double src_ratio)
fflush (stdout) ;

/* Erik */
for (k = 0 ; k < LONG_BUFFER_LEN ; k++) input [k] = k * 1.0 ;
for (k = 0 ; k < LONG_BUFFER_LEN ; k++) input [k] = k * 1.0f ;

/* Calculate maximun input and output lengths. */
if (src_ratio >= 1.0)
Expand Down
4 changes: 4 additions & 0 deletions tests/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,17 @@ gen_windowed_sines (int freq_count, const double *freqs, double max, float *outp
exit (1) ;
} ;

MSVC_DISABLE_WARNING(4244)
for (k = 0 ; k < output_len ; k++)
output [k] += amplitude * sin (freqs [freq] * (2 * k) * M_PI + phase) ;
MSVC_POP_WARNING()
} ;

/* Apply Hanning Window. */
MSVC_DISABLE_WARNING(4244)
for (k = 0 ; k < output_len ; k++)
output [k] *= 0.5 - 0.5 * cos ((2 * k) * M_PI / (output_len - 1)) ;
MSVC_POP_WARNING()

/* data [k] *= 0.3635819 - 0.4891775 * cos ((2 * k) * M_PI / (output_len - 1))
+ 0.1365995 * cos ((4 * k) * M_PI / (output_len - 1))
Expand Down
9 changes: 9 additions & 0 deletions tests/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@

#define ARRAY_LEN(x) ((int) (sizeof (x) / sizeof ((x) [0])))

#ifdef _MSC_VER
#define MSVC_DISABLE_WARNING(n) __pragma(warning(push)) \
__pragma(warning(disable:n))
#define MSVC_POP_WARNING() __pragma(warning(pop))
#else
#define MSVC_DISABLE_WARNING(n)
#define MSVC_POP_WARNING()
#endif

void gen_windowed_sines (int freq_count, const double *freqs, double max, float *output, int output_len) ;

void save_oct_float (char *filename, float *input, int in_len, float *output, int out_len) ;
Expand Down

0 comments on commit ed8b07f

Please sign in to comment.