1 /* license:BSD-3-Clause
2  * copyright-holders:Aaron Giles
3  ***************************************************************************
4 
5     flac.h
6 
7     FLAC compression wrappers
8 
9 ***************************************************************************/
10 
11 #pragma once
12 
13 #ifndef __FLAC_H__
14 #define __FLAC_H__
15 
16 #include <stdint.h>
17 #include <FLAC/all.h>
18 
19 /***************************************************************************
20  *  TYPE DEFINITIONS
21  ***************************************************************************
22  */
23 
24 typedef struct _flac_decoder flac_decoder;
25 struct _flac_decoder {
26 		/* output state */
27 	FLAC__StreamDecoder*	decoder;				/* actual encoder */
28 	uint32_t                sample_rate;			/* decoded sample rate */
29 	uint8_t                 channels;				/* decoded number of channels */
30 	uint8_t                 bits_per_sample;		/* decoded bits per sample */
31 	uint32_t                compressed_offset;		/* current offset in compressed data */
32 	const FLAC__byte *      compressed_start;		/* start of compressed data */
33 	uint32_t                compressed_length;		/* length of compressed data */
34 	const FLAC__byte *      compressed2_start;		/* start of compressed data */
35 	uint32_t                compressed2_length;		/* length of compressed data */
36 	int16_t *               uncompressed_start[8];	/* pointer to start of uncompressed data (up to 8 streams) */
37 	uint32_t                uncompressed_offset;	/* current position in uncompressed data */
38 	uint32_t                uncompressed_length;	/* length of uncompressed data */
39 	int                    	uncompressed_swap;		/* swap uncompressed sample data */
40 	uint8_t                 custom_header[0x2a];	/* custom header */
41 };
42 
43 /* ======================> flac_decoder */
44 
45 void 		flac_decoder_init(flac_decoder* decoder);
46 void 		flac_decoder_free(flac_decoder* decoder);
47 int 		flac_decoder_reset(flac_decoder* decoder, uint32_t sample_rate, uint8_t num_channels, uint32_t block_size, const void *buffer, uint32_t length);
48 int 		flac_decoder_decode_interleaved(flac_decoder* decoder, int16_t *samples, uint32_t num_samples, int swap_endian);
49 uint32_t 	flac_decoder_finish(flac_decoder* decoder);
50 
51 #endif /* __FLAC_H__ */
52