aboutsummaryrefslogtreecommitdiff
path: root/src/dsd2pcm/dsd2pcm.h
blob: 80e8ce0ccca92fa48be76e1f048ed5941b79350e (plain)
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
#ifndef DSD2PCM_H_INCLUDED
#define DSD2PCM_H_INCLUDED

#include <stddef.h>
#include <string.h>

#ifdef __cplusplus
extern "C" {
#endif

struct dsd2pcm_ctx_s;

typedef struct dsd2pcm_ctx_s dsd2pcm_ctx;

/**
 * initializes a "dsd2pcm engine" for one channel
 * (precomputes tables and allocates memory)
 *
 * This is the only function that is not thread-safe in terms of the
 * POSIX thread-safety definition because it modifies global state
 * (lookup tables are computed during the first call)
 */
extern dsd2pcm_ctx* dsd2pcm_init(void);

/**
 * deinitializes a "dsd2pcm engine"
 * (releases memory, don't forget!)
 */
extern void dsd2pcm_destroy(dsd2pcm_ctx *ctx);

/**
 * clones the context and returns a pointer to the
 * newly allocated copy
 */
extern dsd2pcm_ctx* dsd2pcm_clone(dsd2pcm_ctx *ctx);

/**
 * resets the internal state for a fresh new stream
 */
extern void dsd2pcm_reset(dsd2pcm_ctx *ctx);

/**
 * "translates" a stream of octets to a stream of floats
 * (8:1 decimation)
 * @param ctx -- pointer to abstract context (buffers)
 * @param samples -- number of octets/samples to "translate"
 * @param src -- pointer to first octet (input)
 * @param src_stride -- src pointer increment
 * @param lsbitfirst -- bitorder, 0=msb first, 1=lsbfirst
 * @param dst -- pointer to first float (output)
 * @param dst_stride -- dst pointer increment
 */
extern void dsd2pcm_translate(dsd2pcm_ctx *ctx,
	size_t samples,
	const unsigned char *src, ptrdiff_t src_stride,
	int lsbitfirst,
	float *dst, ptrdiff_t dst_stride);

#ifdef __cplusplus
} /* extern "C" */
#endif

#endif /* include guard DSD2PCM_H_INCLUDED */