Mercurial > repos > blastem
annotate flac.h @ 2296:789802d99629
Add basic FLAC decoder and add FLAC playback support to the media player
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Sun, 19 Feb 2023 21:12:46 -0800 |
parents | |
children | 9d68799f945b |
rev | line source |
---|---|
2296
789802d99629
Add basic FLAC decoder and add FLAC playback support to the media player
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1 #ifndef FLAC_H_ |
789802d99629
Add basic FLAC decoder and add FLAC playback support to the media player
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2 #define FLAC_H_ |
789802d99629
Add basic FLAC decoder and add FLAC playback support to the media player
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3 |
789802d99629
Add basic FLAC decoder and add FLAC playback support to the media player
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
4 #include <stdint.h> |
789802d99629
Add basic FLAC decoder and add FLAC playback support to the media player
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5 #include <stdio.h> |
789802d99629
Add basic FLAC decoder and add FLAC playback support to the media player
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
6 |
789802d99629
Add basic FLAC decoder and add FLAC playback support to the media player
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
7 typedef struct flac_file flac_file; |
789802d99629
Add basic FLAC decoder and add FLAC playback support to the media player
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
8 |
789802d99629
Add basic FLAC decoder and add FLAC playback support to the media player
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
9 typedef uint8_t (*flac_read)(flac_file *f); |
789802d99629
Add basic FLAC decoder and add FLAC playback support to the media player
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
10 typedef void (*flac_seek)(flac_file *f, uint32_t offset, uint8_t relative); |
789802d99629
Add basic FLAC decoder and add FLAC playback support to the media player
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
11 |
789802d99629
Add basic FLAC decoder and add FLAC playback support to the media player
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
12 typedef struct { |
789802d99629
Add basic FLAC decoder and add FLAC playback support to the media player
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
13 uint32_t allocated_samples; |
789802d99629
Add basic FLAC decoder and add FLAC playback support to the media player
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
14 int32_t *decoded; |
789802d99629
Add basic FLAC decoder and add FLAC playback support to the media player
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
15 } flac_subframe; |
789802d99629
Add basic FLAC decoder and add FLAC playback support to the media player
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
16 |
789802d99629
Add basic FLAC decoder and add FLAC playback support to the media player
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
17 struct flac_file { |
789802d99629
Add basic FLAC decoder and add FLAC playback support to the media player
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
18 uint64_t total_samples; |
789802d99629
Add basic FLAC decoder and add FLAC playback support to the media player
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
19 uint64_t frame_start_sample; |
789802d99629
Add basic FLAC decoder and add FLAC playback support to the media player
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
20 void *read_data; |
789802d99629
Add basic FLAC decoder and add FLAC playback support to the media player
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
21 flac_read read_byte; |
789802d99629
Add basic FLAC decoder and add FLAC playback support to the media player
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
22 flac_seek seek; |
789802d99629
Add basic FLAC decoder and add FLAC playback support to the media player
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
23 flac_subframe *subframes; |
789802d99629
Add basic FLAC decoder and add FLAC playback support to the media player
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
24 uint32_t offset; |
789802d99629
Add basic FLAC decoder and add FLAC playback support to the media player
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
25 uint32_t buffer_size; |
789802d99629
Add basic FLAC decoder and add FLAC playback support to the media player
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
26 |
789802d99629
Add basic FLAC decoder and add FLAC playback support to the media player
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
27 uint32_t frame_sample_pos; |
789802d99629
Add basic FLAC decoder and add FLAC playback support to the media player
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
28 uint32_t remaining_frame_samples; |
789802d99629
Add basic FLAC decoder and add FLAC playback support to the media player
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
29 |
789802d99629
Add basic FLAC decoder and add FLAC playback support to the media player
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
30 uint32_t sample_rate; |
789802d99629
Add basic FLAC decoder and add FLAC playback support to the media player
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
31 uint32_t frame_sample_rate; |
789802d99629
Add basic FLAC decoder and add FLAC playback support to the media player
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
32 uint32_t frame_block_size; |
789802d99629
Add basic FLAC decoder and add FLAC playback support to the media player
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
33 uint8_t bits_per_sample; |
789802d99629
Add basic FLAC decoder and add FLAC playback support to the media player
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
34 uint8_t frame_bits_per_sample; |
789802d99629
Add basic FLAC decoder and add FLAC playback support to the media player
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
35 uint8_t channels; |
789802d99629
Add basic FLAC decoder and add FLAC playback support to the media player
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
36 uint8_t frame_channels; |
789802d99629
Add basic FLAC decoder and add FLAC playback support to the media player
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
37 uint8_t frame_joint_stereo; |
789802d99629
Add basic FLAC decoder and add FLAC playback support to the media player
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
38 uint8_t subframe_alloc; |
789802d99629
Add basic FLAC decoder and add FLAC playback support to the media player
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
39 |
789802d99629
Add basic FLAC decoder and add FLAC playback support to the media player
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
40 uint8_t cur_byte; |
789802d99629
Add basic FLAC decoder and add FLAC playback support to the media player
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
41 uint8_t bits; |
789802d99629
Add basic FLAC decoder and add FLAC playback support to the media player
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
42 }; |
789802d99629
Add basic FLAC decoder and add FLAC playback support to the media player
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
43 |
789802d99629
Add basic FLAC decoder and add FLAC playback support to the media player
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
44 flac_file *flac_file_from_buffer(void *buffer, uint32_t size); |
789802d99629
Add basic FLAC decoder and add FLAC playback support to the media player
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
45 flac_file *flac_file_from_file(FILE *file); |
789802d99629
Add basic FLAC decoder and add FLAC playback support to the media player
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
46 uint8_t flac_get_sample(flac_file *f, int16_t *out, uint8_t desired_channels); |
789802d99629
Add basic FLAC decoder and add FLAC playback support to the media player
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
47 |
789802d99629
Add basic FLAC decoder and add FLAC playback support to the media player
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
48 #endif //FLAC_H_ |