-
Notifications
You must be signed in to change notification settings - Fork 2
/
aacdmsplit.h
103 lines (93 loc) · 2.33 KB
/
aacdmsplit.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/stat.h>
#include <string.h>
#include <neaacdec.h>
#define MAX_FRAME_SIZE ((1<<13)-1)
#define BUF_SIZE 65536
#define INDEX_SIZE_INC 4096
typedef struct {
unsigned char *data;
unsigned int *index;
size_t size;
unsigned int nframe;
} AACDATA;
typedef struct header_change_t {
unsigned int frame;
struct header_change_t *next;
} HEADER_CHANGE;
enum AAC_SYNTAX_ELEMENTS {
ID_SCE = 0x0,
ID_CPE = 0x1,
ID_CCE = 0x2,
ID_LFE = 0x3,
ID_DSE = 0x4,
ID_PCE = 0x5,
ID_FIL = 0x6,
ID_END = 0x7
};
#define ZERO_MAX_SFB
#define NO_MS_MASK
#define CRC_LEN 16
#define CRC_POLYNOMIAL 0x8005 /* CRC-16 */
#define CRC_INIT 0xffff
#define MAX_CRC_TARGETS 16
class dualmono_splitter {
private:
AACDATA aacdata;
HEADER_CHANGE *header_change;
bool is_dualmono;
struct {
unsigned char buf[MAX_FRAME_SIZE];
int len;
int pos;
int crc_cnt;
struct {
int pos0;
int pos1;
int len;
} crc_target[MAX_CRC_TARGETS];
} bitstream;
void errorexit(const char *msg);
void aacrelease(void);
inline bool is_sync(unsigned char *p) {
return p[0] == 0xff && (p[1] & 0xf6) == 0xf0;
}
/* Bit access stuff */
void reset_bitstream(void);
void setpos(int pos);
int putbits(int n, unsigned long x);
unsigned long getbits(unsigned char *p, int pos, int bits);
unsigned long getbits(int bits);
/* CRC stuff */
void clear_crc_target(void);
void add_crc_target(int pos0, int pos1, int len);
unsigned long calculate_crc(void);
unsigned long CRC_update(unsigned long x, int bits, unsigned long crc);
unsigned long CRC_update_bitstream(int pos0, int pos1, int len, unsigned long crc);
/* Silent frame stuff */
int adts_frame_silent(unsigned char *data);
int raw_data_block_silent(int channel_configuration);
int single_channel_element(int element_instance_tag);
int channel_pair_element(int element_instance_tag);
int lfe_channel_element(int element_instance_tag);
int individual_channel_stream(int common_window);
int ics_info(void);
int section_data(void);
public:
dualmono_splitter() {
memset(&aacdata, 0, sizeof(aacdata));
header_change = NULL;
reset_bitstream();
is_dualmono = false;
};
~dualmono_splitter() {
aacrelease();
}
void aacopen(const char *filepath);
bool isdualmono(void) {
return is_dualmono;
}
void split(const char *filename0, const char *filename1);
};