/usr/include/bse/bseblockutils.hh is in libbse-dev 0.7.8-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 | // Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#ifndef __BSE_BLOCK_UTILS_H__
#define __BSE_BLOCK_UTILS_H__
#include <wchar.h> /* wmemset */
#include <bse/bseieee754.hh>
template<class TYPE> inline
void bse_block_fill_0 (size_t n_values, /* 4-byte variant of memset */
TYPE *values);
/* --- C API --- */
G_BEGIN_DECLS
const
char* bse_block_impl_name (void);
static inline
void bse_block_fill_uint32 (guint n_values, /* 4-byte variant of memset for ints */
guint32 *values,
guint32 vuint32);
static inline
void bse_block_fill_float (uint n_values, /* 4-byte variant of memset for floats */
float *values,
const float value);
static inline
void bse_block_copy_uint32 (guint n_values, /* 4-byte variant of memcpy for ints */
guint32 *values,
const guint32 *ivalues);
static inline
void bse_block_copy_float (guint n_values, /* 4-byte variant of memcpy for floats */
gfloat *values,
const gfloat *ivalues);
void bse_block_add_floats (guint n_values,
float *ovalues,
const float *ivalues);
void bse_block_sub_floats (guint n_values,
float *ovalues,
const float *ivalues);
void bse_block_mul_floats (guint n_values,
float *ovalues,
const float *ivalues);
void bse_block_scale_floats (guint n_values,
float *ovalues,
const float *ivalues,
const float level);
void bse_block_interleave2_floats (guint n_ivalues,
float *ovalues, /* length_ovalues = n_ivalues * 2 */
const float *ivalues,
guint offset); /* 0=left, 1=right */
void bse_block_interleave2_add_floats (guint n_ivalues,
float *ovalues, /* length_ovalues = n_ivalues * 2 */
const float *ivalues,
guint offset); /* 0=left, 1=right */
void bse_block_calc_float_range (guint n_values,
const float *ivalues,
float *min_value,
float *max_value);
float bse_block_calc_float_square_sum (guint n_values,
const float *ivalues);
float bse_block_calc_float_range_and_square_sum (guint n_values,
const float *ivalues,
float *min_value,
float *max_value);
G_END_DECLS
#ifdef __cplusplus
#include <bse/bseresampler.hh>
namespace Bse {
/* --- C++ API --- */
class Block {
public:
static const char* impl_name () { return singleton->impl_name (); }
static inline void fill (guint n_values,
float *values,
float value);
static inline void fill (guint n_values,
guint32 *values,
guint32 value);
static inline void copy (guint n_values,
float *values,
const float *ivalues);
static inline void copy (guint n_values,
guint32 *values,
const guint32 *ivalues);
static inline void add (guint n_values,
float *ovalues,
const float *ivalues) { singleton->add (n_values, ovalues, ivalues); }
static inline void sub (guint n_values,
float *ovalues,
const float *ivalues) { singleton->sub (n_values, ovalues, ivalues); }
static inline void mul (guint n_values,
float *ovalues,
const float *ivalues) { singleton->mul (n_values, ovalues, ivalues); }
static inline void scale (guint n_values,
float *ovalues,
const float *ivalues,
const float level) { singleton->scale (n_values, ovalues, ivalues, level); }
static inline void interleave2 (guint n_ivalues,
float *ovalues,
const float *ivalues,
guint offset) { singleton->interleave2 (n_ivalues, ovalues, ivalues, offset); }
static inline void interleave2_add (guint n_ivalues,
float *ovalues,
const float *ivalues,
guint offset) { singleton->interleave2_add (n_ivalues, ovalues, ivalues, offset); }
static inline void range (guint n_values,
const float *ivalues,
float& min_value,
float& max_value) { singleton->range (n_values, ivalues, min_value, max_value); }
static inline float square_sum (guint n_values,
const float *ivalues) { return singleton->square_sum (n_values, ivalues); }
static inline float range_and_square_sum (guint n_values,
const float *ivalues,
float& min_value,
float& max_value) { return singleton->range_and_square_sum (n_values, ivalues, min_value, max_value); }
typedef Resampler::Resampler2 Resampler2;
static inline
Resampler2* create_resampler2 (BseResampler2Mode mode,
BseResampler2Precision precision) { return singleton->create_resampler2 (mode, precision); }
static inline
bool test_resampler2 (bool verbose) { return singleton->test_resampler2 (verbose); }
class Impl {
protected:
virtual ~Impl ();
virtual const char* impl_name () = 0;
virtual void add (guint n_values,
float *ovalues,
const float *ivalues) = 0;
virtual void sub (guint n_values,
float *ovalues,
const float *ivalues) = 0;
virtual void mul (guint n_values,
float *ovalues,
const float *ivalues) = 0;
virtual void scale (guint n_values,
float *ovalues,
const float *ivalues,
const float level) = 0;
virtual void interleave2 (guint n_ivalues,
float *ovalues, /* length_ovalues = n_ivalues * 2 */
const float *ivalues,
guint offset) = 0; /* 0=left, 1=right */
virtual void interleave2_add (guint n_ivalues,
float *ovalues, /* length_ovalues = n_ivalues * 2 */
const float *ivalues,
guint offset) = 0; /* 0=left, 1=right */
virtual void range (guint n_values,
const float *ivalues,
float& min_value,
float& max_value) = 0;
virtual float square_sum (guint n_values,
const float *ivalues) = 0;
virtual float range_and_square_sum (guint n_values,
const float *ivalues,
float& min_value,
float& max_value) = 0;
virtual
Resampler2* create_resampler2 (BseResampler2Mode mode,
BseResampler2Precision precision) = 0;
virtual bool test_resampler2 (bool verbose) = 0;
friend class Block;
static void substitute (Impl *substitute_impl);
};
static Impl* default_singleton ();
static Impl* current_singleton ();
private:
static Impl *singleton;
};
/* --- C++ implementation bits --- */
inline void
Block::fill (guint n_values,
float *values,
float value)
{
BIRNET_STATIC_ASSERT (sizeof (float) == 4);
BIRNET_STATIC_ASSERT (sizeof (wchar_t) == 4);
const union { float f; guint32 vuint32; } u = { value };
wmemset ((wchar_t*) values, u.vuint32, n_values);
}
inline void
Block::fill (guint n_values,
guint32 *values,
guint32 value)
{
BIRNET_STATIC_ASSERT (sizeof (wchar_t) == 4);
wmemset ((wchar_t*) values, value, n_values);
}
inline void
Block::copy (guint n_values,
guint32 *values,
const guint32 *ivalues)
{
BIRNET_STATIC_ASSERT (sizeof (wchar_t) == 4);
wmemcpy ((wchar_t*) values, (const wchar_t*) ivalues, n_values);
}
inline void
Block::copy (guint n_values,
gfloat *values,
const gfloat *ivalues)
{
BIRNET_STATIC_ASSERT (sizeof (float) == 4);
BIRNET_STATIC_ASSERT (sizeof (wchar_t) == 4);
wmemcpy ((wchar_t*) values, (const wchar_t*) ivalues, n_values);
}
} // Bse
#endif /* __cplusplus */
/* --- C implementation bits --- */
G_BEGIN_DECLS
static inline void
bse_block_fill_uint32 (guint n_values,
guint32 *values,
guint32 vuint32)
{
BIRNET_STATIC_ASSERT (sizeof (wchar_t) == 4);
wmemset ((wchar_t*) values, vuint32, n_values);
}
static inline void
bse_block_fill_float (guint n_values,
float *values,
const float value)
{
BIRNET_STATIC_ASSERT (sizeof (float) == 4);
const union { float f; guint32 vuint32; } u = { value };
BIRNET_STATIC_ASSERT (sizeof (wchar_t) == 4);
wmemset ((wchar_t*) values, u.vuint32, n_values);
}
static inline void
bse_block_copy_uint32 (guint n_values,
guint32 *values,
const guint32 *ivalues)
{
BIRNET_STATIC_ASSERT (sizeof (wchar_t) == 4);
wmemcpy ((wchar_t*) values, (const wchar_t*) ivalues, n_values);
}
static inline void
bse_block_copy_float (guint n_values,
gfloat *values,
const gfloat *ivalues)
{
BIRNET_STATIC_ASSERT (sizeof (float) == 4);
BIRNET_STATIC_ASSERT (sizeof (wchar_t) == 4);
wmemcpy ((wchar_t*) values, (const wchar_t*) ivalues, n_values);
}
G_END_DECLS
// == C++ Implementations ==
template<class TYPE> inline void
bse_block_fill_0 (size_t n_values, TYPE *values)
{
size_t n_bytes = n_values * sizeof (TYPE);
char *p = (char*) values;
uint r = size_t (p) & 3;
if (UNLIKELY (r))
{
r = MIN (r, n_values); // rest for pointer alignment
memset (p, 0, r);
p += r;
n_bytes -= r;
}
const size_t n_aligned = n_bytes / 4;
wmemset ((wchar_t*) p, 0, n_aligned);
n_bytes -= n_aligned * 4;
if (UNLIKELY (n_bytes))
{
p += n_aligned * 4;
memset (p, 0, n_bytes);
}
}
#endif /* __BSE_BLOCK_UTILS_H__ */
|