summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErik de Castro Lopo <erikd@mega-nerd.com>2017-07-20 19:41:55 +1000
committerErik de Castro Lopo <erikd@mega-nerd.com>2017-07-21 07:10:13 +1000
commit20a2100d7d7e304f2f332e1a8adafe1b43988d61 (patch)
tree40b7f370d5fbdc32702cc0870e25e6cb9efd4290
parentf7cd466c24fb5d1966943f3ea36a1f4a37858597 (diff)
downloadflac-20a2100d7d7e304f2f332e1a8adafe1b43988d61.tar.gz
replaygain_synthesis.c: Fix a cppcheck warning
Cppcheck was incorrectly warning that `doubletmp` was being used un-initialized. This was due to the fact that it was being used and initialized in a pre-processor macro. Chaning the macro to an inline function stops cppcheck from raising a warning.
-rw-r--r--src/share/replaygain_synthesis/replaygain_synthesis.c31
1 files changed, 18 insertions, 13 deletions
diff --git a/src/share/replaygain_synthesis/replaygain_synthesis.c b/src/share/replaygain_synthesis/replaygain_synthesis.c
index c14ab1b9..5069d26c 100644
--- a/src/share/replaygain_synthesis/replaygain_synthesis.c
+++ b/src/share/replaygain_synthesis/replaygain_synthesis.c
@@ -223,20 +223,27 @@ void FLAC__replaygain_synthesis__init_dither_context(DitherContext *d, int bits,
d->LastHistoryIndex = 0;
}
+static inline int64_t
+ROUND64 (DitherContext *d, double x)
+{
+ union {
+ double d;
+ int64_t i;
+ } doubletmp;
+
+ doubletmp.d = x + d->Add + (int64_t)FLAC__I64L(0x001FFFFD80000000);
+
+ return doubletmp.i - (int64_t)FLAC__I64L(0x433FFFFD80000000);
+}
+
/*
* the following is based on parts of wavegain.c
*/
-static FLAC__int64 dither_output_(DitherContext *d, FLAC__bool do_dithering, int shapingtype, int i, double Sum, int k)
+static int64_t dither_output_(DitherContext *d, FLAC__bool do_dithering, int shapingtype, int i, double Sum, int k)
{
- union {
- double d;
- FLAC__int64 i;
- } doubletmp;
double Sum2;
- FLAC__int64 val;
-
-#define ROUND64(x) ( doubletmp.d = (x) + d->Add + (FLAC__int64)FLAC__I64L(0x001FFFFD80000000), doubletmp.i - (FLAC__int64)FLAC__I64L(0x433FFFFD80000000) )
+ int64_t val;
if(do_dithering) {
if(shapingtype == 0) {
@@ -244,21 +251,19 @@ static FLAC__int64 dither_output_(DitherContext *d, FLAC__bool do_dithering, int
Sum2 = tmp - d->LastRandomNumber [k];
d->LastRandomNumber [k] = (int)tmp;
Sum2 = Sum += Sum2;
- val = ROUND64(Sum2) & d->Mask;
+ val = ROUND64(d, Sum2) & d->Mask;
}
else {
Sum2 = random_triangular_(d->Dither) - scalar16_(d->DitherHistory[k], d->FilterCoeff + i);
Sum += d->DitherHistory [k] [(-1-i)&15] = (float)Sum2;
Sum2 = Sum + scalar16_(d->ErrorHistory [k], d->FilterCoeff + i);
- val = ROUND64(Sum2) & d->Mask;
+ val = ROUND64(d, Sum2) & d->Mask;
d->ErrorHistory [k] [(-1-i)&15] = (float)(Sum - val);
}
return val;
}
- else
- return ROUND64(Sum);
-#undef ROUND64
+ return ROUND64(d, Sum);
}
#if 0