From: Mike Brady Date: Mon, 30 Jan 2017 18:34:09 +0000 (+0000) Subject: Add possibility of using an array of precalculated pseudo random numbers to reduce... X-Git-Tag: 3.0.d18~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=07641995451bb00b75794092c8e499c003d3ed8a;p=thirdparty%2Fshairport-sync.git Add possibility of using an array of precalculated pseudo random numbers to reduce processor load. --- diff --git a/common.c b/common.c index d2eb17e4..cf1138a1 100644 --- a/common.c +++ b/common.c @@ -757,6 +757,8 @@ uint64_t ranarrayval() { ranarraynext = (ranarraynext++)%ranarraylength; } +void r64arrayinit() { ranarrayinit(); } + uint64_t ranarray64u() { return (ranarrayval()); } int64_t ranarray64i() { return (ranarrayval(&rx) >> 1); } diff --git a/common.h b/common.h index e52f82d2..e15edf1a 100644 --- a/common.h +++ b/common.h @@ -152,6 +152,10 @@ void r64init(uint64_t seed); uint64_t r64u(); int64_t r64i(); +void r64arrayinit(); +uint64_t ranarray64u(); +int64_t ranarray64i(); + int debuglev; void die(char *format, ...); void warn(char *format, ...); diff --git a/player.c b/player.c index edc3dfbf..edf2f4b0 100644 --- a/player.c +++ b/player.c @@ -677,6 +677,8 @@ static inline void process_sample(int32_t sample, char **outp, enum sps_format_t } dither_mask -= 1; int64_t r = r64i(); + // int64_t r = ranarray64i(); + int64_t tpdf = (r & dither_mask) - (previous_random_number & dither_mask); previous_random_number = r; // add dither, allowing for clipping diff --git a/shairport.c b/shairport.c index 6106aca6..4afd8e5d 100644 --- a/shairport.c +++ b/shairport.c @@ -858,6 +858,10 @@ int main(int argc, char **argv) { // initialise random number generator r64init(0); + + // initialise the randomw number array + + r64arrayinit(); /* Check if we are called with -V or --version parameter */ if (argc >= 2 && ((strcmp(argv[1], "-V") == 0) || (strcmp(argv[1], "--version") == 0))) {