forked from hegdi/libldacdec
-
Notifications
You must be signed in to change notification settings - Fork 7
/
ldacdec.h
87 lines (67 loc) · 2.08 KB
/
ldacdec.h
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
#ifndef __LDACDEC_H_
#define __LDACDEC_H_
#define MAX_QUANT_UNITS (34)
#define MAX_FRAME_SAMPLES (256)
#include "log.h"
#include "imdct.h"
#include "libldacBT_dec.h"
#define container_of( ptr, type, member ) ({ \
const typeof( ((type*)0)->member ) *__mptr = (ptr); \
(type *)((char*)__ptr - offsetof(type, memeber)); \
})
#define min( a, b ) \
({ __typeof__ (a) _a = (a); \
__typeof__ (b) _b = (b); \
_a < _b ? _a : _b; });
#define max( a, b ) \
({ __typeof__ (a) _a = (a); \
__typeof__ (b) _b = (b); \
_a > _b ? _a : _b; });
typedef struct Frame frame_t;
typedef struct Channel channel_t;
struct Channel {
frame_t *frame;
int scaleFactorMode;
int scaleFactorBitlen;
int scaleFactorOffset;
int scaleFactorWeight;
int scaleFactors[MAX_QUANT_UNITS];
int precisions[MAX_QUANT_UNITS];
int precisionsFine[MAX_QUANT_UNITS];
int precisionMask[MAX_QUANT_UNITS];
int quantizedSpectra[MAX_FRAME_SAMPLES];
int quantizedSpectraFine[MAX_FRAME_SAMPLES];
float spectra[MAX_FRAME_SAMPLES];
float pcm[MAX_FRAME_SAMPLES];
Mdct mdct;
};
struct Frame {
int sampleRateId;
int channelConfigId;
int frameLength;
int frameStatus;
int frameSamplesPower;
int frameSamples;
int nbrBands;
// gradient data
int gradient[MAX_QUANT_UNITS];
int gradientMode;
int gradientStartUnit;
int gradientEndUnit;
int gradientStartValue;
int gradientEndValue;
int gradientBoundary;
int quantizationUnitCount;
int channelCount;
channel_t channels[2];
};
typedef struct {
frame_t frame;
} ldacdec_t;
int ldacdecInit( ldacdec_t *this );
int ldacDecode( ldacdec_t *this, uint8_t *stream, short *pcm, int *bytesUsed );
int ldacDecode_type( ldacdec_t *this, uint8_t *stream, void *pcm, int *bytesUsed, LDACBT_SMPL_FMT_T fmt );
int ldacNullPacket( ldacdec_t *this, uint8_t *output, int *bytesUsed );
int ldacdecGetSampleRate( ldacdec_t *this );
int ldacdecGetChannelCount( ldacdec_t *this );
#endif // __LDACDEC_H_