Debian Codegraph @

include/wavpack.h

raw symbols SCIP
1 /*
2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15 */
16
17 #define WAVPACK_BLOCK_SIZE 4096
18
19 typedef struct {
20 // char ckID [4]; // "wvpk"
21 uint32_t ckSize; // size of entire block (minus 8, of course)
22 uint16_t version; // 0x402 to 0x410 are currently valid for decode
23 u_char track_no; // track number (0 if not used, like now)
24 u_char index_no; // track sub-index (0 if not used, like now)
25 uint32_t total_samples; // total samples for entire file, but this is
26 // only valid if block_index == 0 and a value of
27 // -1 indicates unknown length
28 uint32_t block_index; // index of first sample in block relative to
29 // beginning of file (normally this would start
30 // at 0 for the first block)
31 uint32_t block_samples; // number of samples in this block (0 = no audio)
32 uint32_t flags; // various flags for id and decoding
33 uint32_t crc; // crc for actual decoded data
34 } WavpackHeader;
35
36 typedef struct {
37 unsigned short FormatTag, NumChannels;
38 uint32_t SampleRate, BytesPerSecond;
39 unsigned short BlockAlign, BitsPerSample;
40 } WaveHeader3;
41
42 typedef struct {
43 // char ckID [4];
44 int32_t ckSize;
45 short version;
46 short bits; // added for version 2.00
47 short flags, shift; // added for version 3.00
48 int32_t total_samples; //, crc, crc2;
49 // char extension [4], extra_bc, extras [3];
50 } WavpackHeader3;
51
52 typedef struct wvpinfo {
53 PerlIO *infile;
54 char *file;
55 Buffer *buf;
56 HV *info;
57 off_t file_size;
58 off_t file_offset;
59 off_t audio_offset;
60
61 WavpackHeader *header; // current block header data
62
63 uint8_t seeking; // flag if we're seeking
64 } wvpinfo;
65
66 const int wavpack_sample_rates[] = {
67 6000, 8000, 9600, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000, 64000, 88200, 96000, 192000
68 };
69
70 #define ID_UNIQUE 0x3f
71 #define ID_OPTIONAL_DATA 0x20
72 #define ID_ODD_SIZE 0x40
73 #define ID_LARGE 0x80
74
75 #define ID_DUMMY 0x0
76 #define ID_ENCODER_INFO 0x1
77 #define ID_DECORR_TERMS 0x2
78 #define ID_DECORR_WEIGHTS 0x3
79 #define ID_DECORR_SAMPLES 0x4
80 #define ID_ENTROPY_VARS 0x5
81 #define ID_HYBRID_PROFILE 0x6
82 #define ID_SHAPING_WEIGHTS 0x7
83 #define ID_FLOAT_INFO 0x8
84 #define ID_INT32_INFO 0x9
85 #define ID_WV_BITSTREAM 0xa
86 #define ID_WVC_BITSTREAM 0xb
87 #define ID_WVX_BITSTREAM 0xc
88 #define ID_CHANNEL_INFO 0xd
89 #define ID_DSD_BLOCK 0xe
90
91 #define ID_RIFF_HEADER (ID_OPTIONAL_DATA | 0x1)
92 #define ID_RIFF_TRAILER (ID_OPTIONAL_DATA | 0x2)
93 #define ID_ALT_HEADER (ID_OPTIONAL_DATA | 0x3)
94 #define ID_ALT_TRAILER (ID_OPTIONAL_DATA | 0x4)
95 #define ID_CONFIG_BLOCK (ID_OPTIONAL_DATA | 0x5)
96 #define ID_MD5_CHECKSUM (ID_OPTIONAL_DATA | 0x6)
97 #define ID_SAMPLE_RATE (ID_OPTIONAL_DATA | 0x7)
98 #define ID_ALT_EXTENSION (ID_OPTIONAL_DATA | 0x8)
99 #define ID_ALT_MD5_CHECKSUM (ID_OPTIONAL_DATA | 0x9)
100 #define ID_NEW_CONFIG_BLOCK (ID_OPTIONAL_DATA | 0xa)
101 #define ID_BLOCK_CHECKSUM (ID_OPTIONAL_DATA | 0xf)
102
103 static int get_wavpack_info(PerlIO *infile, char *file, HV *info);
104 wvpinfo * _wavpack_parse(PerlIO *infile, char *file, HV *info, uint8_t seeking);
105 int _wavpack_parse_block(wvpinfo *wvp);
106 int _wavpack_parse_sample_rate(wvpinfo *wvp, uint32_t size);
107 int _wavpack_parse_channel_info(wvpinfo *wvp, uint32_t size);
108 int _wavpack_parse_dsd_block(wvpinfo *wvp, uint32_t size);
109 void _wavpack_skip(wvpinfo *wvp, uint32_t size);
110 int _wavpack_parse_old(wvpinfo *wvp);