NO-OP: clang-format whitespace

This commit is contained in:
Robin Gareus 2018-10-11 00:52:37 +02:00
parent 876e780e4d
commit 8e78827deb
2 changed files with 1106 additions and 1138 deletions

File diff suppressed because it is too large Load diff

View file

@ -17,53 +17,69 @@
// //
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
#ifndef _ZITA_CONVOLVER_H #ifndef _ZITA_CONVOLVER_H
#define _ZITA_CONVOLVER_H #define _ZITA_CONVOLVER_H
#include <fftw3.h>
#include <pthread.h> #include <pthread.h>
#include <stdint.h> #include <stdint.h>
#include <fftw3.h>
#include "zita-convolver/zconvolver_visibility.h" #include "zita-convolver/zconvolver_visibility.h"
namespace ArdourZita { namespace ArdourZita {
#ifdef ZCSEMA_IS_IMPLEMENTED #ifdef ZCSEMA_IS_IMPLEMENTED
#undef ZCSEMA_IS_IMPLEMENTED #undef ZCSEMA_IS_IMPLEMENTED
#endif #endif
#if defined(__linux__) || defined(__GNU__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
#if defined(__linux__) || defined(__GNU__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
#include <semaphore.h> #include <semaphore.h>
class LIBZCONVOLVER_API ZCsema class LIBZCONVOLVER_API ZCsema
{ {
public: public:
ZCsema (void)
{
init (0, 0);
}
ZCsema (void) { init (0, 0); } ~ZCsema (void)
~ZCsema (void) { sem_destroy (&_sema); } {
sem_destroy (&_sema);
}
ZCsema (const ZCsema&); // disabled ZCsema (const ZCsema&); // disabled
ZCsema& operator= (const ZCsema&); // disabled ZCsema& operator= (const ZCsema&); // disabled
int init (int s, int v) { return sem_init (&_sema, s, v); } int init (int s, int v)
int post (void) { return sem_post (&_sema); } {
int wait (void) { return sem_wait (&_sema); } return sem_init (&_sema, s, v);
int trywait (void) { return sem_trywait (&_sema); } }
int post (void)
{
return sem_post (&_sema);
}
int wait (void)
{
return sem_wait (&_sema);
}
int trywait (void)
{
return sem_trywait (&_sema);
}
private: private:
sem_t _sema;
sem_t _sema;
}; };
#define ZCSEMA_IS_IMPLEMENTED #define ZCSEMA_IS_IMPLEMENTED
#endif #endif
#ifdef __APPLE__ #ifdef __APPLE__
// NOTE: ***** I DO NOT REPEAT NOT PROVIDE SUPPORT FOR OSX ***** // NOTE: ***** I DO NOT REPEAT NOT PROVIDE SUPPORT FOR OSX *****
@ -76,392 +92,365 @@ private:
class LIBZCONVOLVER_API ZCsema class LIBZCONVOLVER_API ZCsema
{ {
public: public:
ZCsema (void) : _count (0)
ZCsema (void) : _count (0)
{
init (0, 0);
}
~ZCsema (void)
{
pthread_mutex_destroy (&_mutex);
pthread_cond_destroy (&_cond);
}
ZCsema (const ZCsema&); // disabled
ZCsema& operator= (const ZCsema&); // disabled
int init (int s, int v)
{
_count = v;
return pthread_mutex_init (&_mutex, 0) || pthread_cond_init (&_cond, 0);
}
int post (void)
{
pthread_mutex_lock (&_mutex);
_count++;
if (_count == 1) pthread_cond_signal (&_cond);
pthread_mutex_unlock (&_mutex);
return 0;
}
int wait (void)
{
pthread_mutex_lock (&_mutex);
while (_count < 1) pthread_cond_wait (&_cond, &_mutex);
_count--;
pthread_mutex_unlock (&_mutex);
return 0;
}
int trywait (void)
{
if (pthread_mutex_trylock (&_mutex)) return -1;
if (_count < 1)
{ {
pthread_mutex_unlock (&_mutex); init (0, 0);
return -1; }
~ZCsema (void)
{
pthread_mutex_destroy (&_mutex);
pthread_cond_destroy (&_cond);
}
ZCsema (const ZCsema&); // disabled
ZCsema& operator= (const ZCsema&); // disabled
int init (int s, int v)
{
_count = v;
return pthread_mutex_init (&_mutex, 0) || pthread_cond_init (&_cond, 0);
}
int post (void)
{
pthread_mutex_lock (&_mutex);
_count++;
if (_count == 1)
pthread_cond_signal (&_cond);
pthread_mutex_unlock (&_mutex);
return 0;
}
int wait (void)
{
pthread_mutex_lock (&_mutex);
while (_count < 1)
pthread_cond_wait (&_cond, &_mutex);
_count--;
pthread_mutex_unlock (&_mutex);
return 0;
}
int trywait (void)
{
if (pthread_mutex_trylock (&_mutex))
return -1;
if (_count < 1) {
pthread_mutex_unlock (&_mutex);
return -1;
}
_count--;
pthread_mutex_unlock (&_mutex);
return 0;
} }
_count--;
pthread_mutex_unlock (&_mutex);
return 0;
}
private: private:
int _count;
int _count; pthread_mutex_t _mutex;
pthread_mutex_t _mutex; pthread_cond_t _cond;
pthread_cond_t _cond;
}; };
#define ZCSEMA_IS_IMPLEMENTED #define ZCSEMA_IS_IMPLEMENTED
#endif #endif
#ifndef ZCSEMA_IS_IMPLEMENTED #ifndef ZCSEMA_IS_IMPLEMENTED
#error "The ZCsema class is not implemented." #error "The ZCsema class is not implemented."
#endif #endif
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
class LIBZCONVOLVER_API Inpnode class LIBZCONVOLVER_API Inpnode
{ {
private: private:
friend class Convlevel;
friend class Convlevel; Inpnode (uint16_t inp);
~Inpnode (void);
void alloc_ffta (uint16_t npar, int32_t size);
void free_ffta (void);
Inpnode (uint16_t inp); Inpnode* _next;
~Inpnode (void); fftwf_complex** _ffta;
void alloc_ffta (uint16_t npar, int32_t size); uint16_t _npar;
void free_ffta (void); uint16_t _inp;
Inpnode *_next;
fftwf_complex **_ffta;
uint16_t _npar;
uint16_t _inp;
}; };
class LIBZCONVOLVER_API Macnode class LIBZCONVOLVER_API Macnode
{ {
private: private:
friend class Convlevel;
friend class Convlevel; Macnode (Inpnode* inpn);
~Macnode (void);
void alloc_fftb (uint16_t npar);
void free_fftb (void);
Macnode (Inpnode *inpn); Macnode* _next;
~Macnode (void); Inpnode* _inpn;
void alloc_fftb (uint16_t npar); Macnode* _link;
void free_fftb (void); fftwf_complex** _fftb;
uint16_t _npar;
Macnode *_next;
Inpnode *_inpn;
Macnode *_link;
fftwf_complex **_fftb;
uint16_t _npar;
}; };
class LIBZCONVOLVER_API Outnode class LIBZCONVOLVER_API Outnode
{ {
private: private:
friend class Convlevel;
friend class Convlevel; Outnode (uint16_t out, int32_t size);
~Outnode (void);
Outnode (uint16_t out, int32_t size); Outnode* _next;
~Outnode (void); Macnode* _list;
float* _buff[3];
Outnode *_next; uint16_t _out;
Macnode *_list;
float *_buff [3];
uint16_t _out;
}; };
class LIBZCONVOLVER_API Converror class LIBZCONVOLVER_API Converror
{ {
public: public:
enum {
BAD_STATE = -1,
BAD_PARAM = -2,
MEM_ALLOC = -3
};
enum Converror (int error) : _error (error) {}
{
BAD_STATE = -1,
BAD_PARAM = -2,
MEM_ALLOC = -3
};
Converror (int error) : _error (error) {}
private: private:
int _error;
int _error;
}; };
class LIBZCONVOLVER_API Convlevel class LIBZCONVOLVER_API Convlevel
{ {
private: private:
friend class Convproc;
friend class Convproc; enum {
OPT_FFTW_MEASURE = 1,
OPT_VECTOR_MODE = 2,
OPT_LATE_CONTIN = 4
};
enum enum {
{ ST_IDLE,
OPT_FFTW_MEASURE = 1, ST_TERM,
OPT_VECTOR_MODE = 2, ST_PROC
OPT_LATE_CONTIN = 4 };
};
enum Convlevel (void);
{ ~Convlevel (void);
ST_IDLE,
ST_TERM,
ST_PROC
};
Convlevel (void); void configure (int prio,
~Convlevel (void); uint32_t offs,
uint32_t npar,
uint32_t parsize,
uint32_t options);
void configure (int prio, void impdata_write (uint32_t inp,
uint32_t offs, uint32_t out,
uint32_t npar, int32_t step,
uint32_t parsize, float* data,
uint32_t options); int32_t ind0,
int32_t ind1,
bool create);
void impdata_write (uint32_t inp, void impdata_clear (uint32_t inp,
uint32_t out, uint32_t out);
int32_t step,
float *data,
int32_t ind0,
int32_t ind1,
bool create);
void impdata_clear (uint32_t inp, void impdata_link (uint32_t inp1,
uint32_t out); uint32_t out1,
uint32_t inp2,
uint32_t out2);
void impdata_link (uint32_t inp1, void reset (uint32_t inpsize,
uint32_t out1, uint32_t outsize,
uint32_t inp2, float** inpbuff,
uint32_t out2); float** outbuff);
void reset (uint32_t inpsize, void start (int absprio, int policy);
uint32_t outsize,
float **inpbuff,
float **outbuff);
void start (int absprio, int policy); void process (bool sync);
void process (bool sync); int readout (bool sync, uint32_t skipcnt);
int readout (bool sync, uint32_t skipcnt); void stop (void);
void stop (void); void cleanup (void);
void cleanup (void); void fftswap (fftwf_complex* p);
void fftswap (fftwf_complex *p); void print (FILE* F);
void print (FILE *F); static void* static_main (void* arg);
static void *static_main (void *arg); void main (void);
void main (void); Macnode* findmacnode (uint32_t inp, uint32_t out, bool create);
Macnode *findmacnode (uint32_t inp, uint32_t out, bool create); volatile uint32_t _stat; // current processing state
int _prio; // relative priority
uint32_t _offs; // offset from start of impulse response
volatile uint32_t _stat; // current processing state uint32_t _npar; // number of partitions
int _prio; // relative priority uint32_t _parsize; // partition and outbut buffer size
uint32_t _offs; // offset from start of impulse response uint32_t _outsize; // step size for output buffer
uint32_t _npar; // number of partitions uint32_t _outoffs; // offset into output buffer
uint32_t _parsize; // partition and outbut buffer size uint32_t _inpsize; // size of shared input buffer
uint32_t _outsize; // step size for output buffer uint32_t _inpoffs; // offset into input buffer
uint32_t _outoffs; // offset into output buffer uint32_t _options; // various options
uint32_t _inpsize; // size of shared input buffer uint32_t _ptind; // rotating partition index
uint32_t _inpoffs; // offset into input buffer uint32_t _opind; // rotating output buffer index
uint32_t _options; // various options int _bits; // bit identifiying this level
uint32_t _ptind; // rotating partition index int _wait; // number of unfinished cycles
uint32_t _opind; // rotating output buffer index pthread_t _pthr; // posix thread executing this level
int _bits; // bit identifiying this level ZCsema _trig; // sema used to trigger a cycle
int _wait; // number of unfinished cycles ZCsema _done; // sema used to wait for a cycle
pthread_t _pthr; // posix thread executing this level Inpnode* _inp_list; // linked list of active inputs
ZCsema _trig; // sema used to trigger a cycle Outnode* _out_list; // linked list of active outputs
ZCsema _done; // sema used to wait for a cycle fftwf_plan _plan_r2c; // FFTW plan, forward FFT
Inpnode *_inp_list; // linked list of active inputs fftwf_plan _plan_c2r; // FFTW plan, inverse FFT
Outnode *_out_list; // linked list of active outputs float* _time_data; // workspace
fftwf_plan _plan_r2c; // FFTW plan, forward FFT float* _prep_data; // workspace
fftwf_plan _plan_c2r; // FFTW plan, inverse FFT fftwf_complex* _freq_data; // workspace
float *_time_data; // workspace float** _inpbuff; // array of shared input buffers
float *_prep_data; // workspace float** _outbuff; // array of shared output buffers
fftwf_complex *_freq_data; // workspace
float **_inpbuff; // array of shared input buffers
float **_outbuff; // array of shared output buffers
}; };
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
class LIBZCONVOLVER_API Convproc class LIBZCONVOLVER_API Convproc
{ {
public: public:
Convproc (void);
~Convproc (void);
Convproc (void); enum {
~Convproc (void); ST_IDLE,
ST_STOP,
ST_WAIT,
ST_PROC
};
enum enum {
{ FL_LATE = 0x0000FFFF,
ST_IDLE, FL_LOAD = 0x01000000
ST_STOP, };
ST_WAIT,
ST_PROC
};
enum enum {
{ OPT_FFTW_MEASURE = Convlevel::OPT_FFTW_MEASURE,
FL_LATE = 0x0000FFFF, OPT_VECTOR_MODE = Convlevel::OPT_VECTOR_MODE,
FL_LOAD = 0x01000000 OPT_LATE_CONTIN = Convlevel::OPT_LATE_CONTIN
}; };
enum enum {
{ MAXINP = 64,
OPT_FFTW_MEASURE = Convlevel::OPT_FFTW_MEASURE, MAXOUT = 64,
OPT_VECTOR_MODE = Convlevel::OPT_VECTOR_MODE, MAXLEV = 8,
OPT_LATE_CONTIN = Convlevel::OPT_LATE_CONTIN MINPART = 64,
}; MAXPART = 8192,
MAXDIVIS = 16,
MINQUANT = 16,
MAXQUANT = 8192
};
enum uint32_t state (void) const
{ {
MAXINP = 64, return _state;
MAXOUT = 64, }
MAXLEV = 8,
MINPART = 64,
MAXPART = 8192,
MAXDIVIS = 16,
MINQUANT = 16,
MAXQUANT = 8192
};
uint32_t state (void) const float* inpdata (uint32_t inp) const
{ {
return _state; return _inpbuff[inp] + _inpoffs;
} }
float *inpdata (uint32_t inp) const float* outdata (uint32_t out) const
{ {
return _inpbuff [inp] + _inpoffs; return _outbuff[out] + _outoffs;
} }
float *outdata (uint32_t out) const int configure (uint32_t ninp,
{ uint32_t nout,
return _outbuff [out] + _outoffs; uint32_t maxsize,
} uint32_t quantum,
uint32_t minpart,
uint32_t maxpart,
float density);
int configure (uint32_t ninp, int impdata_create (uint32_t inp,
uint32_t nout, uint32_t out,
uint32_t maxsize, int32_t step,
uint32_t quantum, float* data,
uint32_t minpart, int32_t ind0,
uint32_t maxpart, int32_t ind1);
float density);
int impdata_create (uint32_t inp, int impdata_clear (uint32_t inp,
uint32_t out, uint32_t out);
int32_t step,
float *data,
int32_t ind0,
int32_t ind1);
int impdata_clear (uint32_t inp, int impdata_update (uint32_t inp,
uint32_t out); uint32_t out,
int32_t step,
float* data,
int32_t ind0,
int32_t ind1);
int impdata_update (uint32_t inp, int impdata_link (uint32_t inp1,
uint32_t out, uint32_t out1,
int32_t step, uint32_t inp2,
float *data, uint32_t out2);
int32_t ind0,
int32_t ind1);
int impdata_link (uint32_t inp1, // Deprecated, use impdata_link() instead.
uint32_t out1, int impdata_copy (uint32_t inp1,
uint32_t inp2, uint32_t out1,
uint32_t out2); uint32_t inp2,
uint32_t out2)
{
return impdata_link (inp1, out1, inp2, out2);
}
// Deprecated, use impdata_link() instead. void set_options (uint32_t options);
int impdata_copy (uint32_t inp1,
uint32_t out1,
uint32_t inp2,
uint32_t out2)
{
return impdata_link (inp1, out1, inp2, out2);
}
void set_options (uint32_t options); void set_skipcnt (uint32_t skipcnt);
void set_skipcnt (uint32_t skipcnt); int reset (void);
int reset (void); int start_process (int abspri, int policy);
int start_process (int abspri, int policy); int process (bool sync = false);
int process (bool sync = false); int stop_process (void);
int stop_process (void); bool check_stop (void);
bool check_stop (void); int cleanup (void);
int cleanup (void); void print (FILE* F = stdout);
void print (FILE *F = stdout);
private: private:
uint32_t _state; // current state
float* _inpbuff[MAXINP]; // input buffers
float* _outbuff[MAXOUT]; // output buffers
uint32_t _inpoffs; // current offset in input buffers
uint32_t _outoffs; // current offset in output buffers
uint32_t _options; // option bits
uint32_t _skipcnt; // number of frames to skip
uint32_t _ninp; // number of inputs
uint32_t _nout; // number of outputs
uint32_t _quantum; // processing block size
uint32_t _minpart; // smallest partition size
uint32_t _maxpart; // largest allowed partition size
uint32_t _nlevels; // number of partition sizes
uint32_t _inpsize; // size of input buffers
uint32_t _latecnt; // count of cycles ending too late
Convlevel* _convlev[MAXLEV]; // array of processors
void* _dummy[64];
uint32_t _state; // current state static float _mac_cost;
float *_inpbuff [MAXINP]; // input buffers static float _fft_cost;
float *_outbuff [MAXOUT]; // output buffers
uint32_t _inpoffs; // current offset in input buffers
uint32_t _outoffs; // current offset in output buffers
uint32_t _options; // option bits
uint32_t _skipcnt; // number of frames to skip
uint32_t _ninp; // number of inputs
uint32_t _nout; // number of outputs
uint32_t _quantum; // processing block size
uint32_t _minpart; // smallest partition size
uint32_t _maxpart; // largest allowed partition size
uint32_t _nlevels; // number of partition sizes
uint32_t _inpsize; // size of input buffers
uint32_t _latecnt; // count of cycles ending too late
Convlevel *_convlev [MAXLEV]; // array of processors
void *_dummy [64];
static float _mac_cost;
static float _fft_cost;
}; };
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
} /* end namespace */ } /* end namespace */
#endif #endif