Debian Codegraph @

include/flac.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 #pragma once
18
19 #define FLAC_BLOCK_SIZE 4096
20 #define FLAC_FRAME_MAX_HEADER 22
21
22 /* frame header size (16 bytes) + 4608 stereo 16-bit samples (higher than 4608 is possible, but not done) */
23 #define FLAC_MAX_FRAMESIZE 18448
24 #define FLAC_HEADER_LEN 16
25
26 enum flac_types {
27 FLAC_TYPE_STREAMINFO,
28 FLAC_TYPE_PADDING,
29 FLAC_TYPE_APPLICATION,
30 FLAC_TYPE_SEEKTABLE,
31 FLAC_TYPE_VORBIS_COMMENT,
32 FLAC_TYPE_CUESHEET,
33 FLAC_TYPE_PICTURE
34 };
35
36 typedef struct seekpoint {
37 uint64_t sample_number;
38 uint64_t stream_offset;
39 uint16_t frame_samples;
40 } seekpoint;
41
42 typedef struct flacinfo {
43 PerlIO *infile;
44 char *file;
45 Buffer *buf;
46 Buffer *scratch;
47 HV *info;
48 HV *tags;
49 off_t file_size;
50 off_t audio_offset;
51
52 uint32_t min_blocksize;
53 uint32_t max_blocksize;
54 uint32_t min_framesize;
55 uint32_t max_framesize;
56 uint8_t channels;
57 uint32_t samplerate;
58 uint32_t bits_per_sample;
59 uint64_t total_samples;
60
61 uint8_t seeking; // flag if we're seeking
62
63 uint32_t num_seekpoints;
64 struct seekpoint *seekpoints;
65 } flacinfo;
66
67 int get_flac_metadata(PerlIO *infile, char *file, HV *info, HV *tags);
68 flacinfo * _flac_parse(PerlIO *infile, char *file, HV *info, HV *tags, uint8_t seeking);
69 void _flac_parse_streaminfo(flacinfo *flac);
70 void _flac_parse_application(flacinfo *flac, int len);
71 void _flac_parse_seektable(flacinfo *flac, int len);
72 void _flac_parse_cuesheet(flacinfo *flac);
73 int _flac_parse_picture(flacinfo *flac);
74 int _flac_binary_search_sample(flacinfo *flac, uint64_t target_sample, off_t low, off_t high);
75 int _flac_read_frame_header(flacinfo *flac, unsigned char *buf, uint64_t *first_sample, uint64_t *last_sample);
76 int _flac_first_last_sample(flacinfo *flac, off_t seek_offset, off_t *frame_offset, uint64_t *first_sample, uint64_t *last_sample, uint64_t target_sample);
77 uint8_t _flac_crc8(const unsigned char *buf, unsigned len);
78 int _flac_read_utf8_uint64(unsigned char *raw, uint64_t *val, uint8_t *rawlen);
79 int _flac_read_utf8_uint32(unsigned char *raw, uint32_t *val, uint8_t *rawlen);
80 void _flac_skip(flacinfo *flac, uint32_t size);