git subrepo clone (merge) https://github.com/rtissera/libchdr deps/libchdr
[pcsx_rearmed.git] / deps / libchdr / include / libchdr / flac.h
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
18 /***************************************************************************
19  *  TYPE DEFINITIONS
20  ***************************************************************************
21  */
22
23 typedef struct _flac_decoder flac_decoder;
24 struct _flac_decoder {
25                 /* output state */
26         void *                  decoder;                                /* actual encoder */
27         uint32_t                sample_rate;                    /* decoded sample rate */
28         uint8_t                 channels;                               /* decoded number of channels */
29         uint8_t                 bits_per_sample;                /* decoded bits per sample */
30         uint32_t                compressed_offset;              /* current offset in compressed data */
31         const uint8_t *         compressed_start;               /* start of compressed data */
32         uint32_t                compressed_length;              /* length of compressed data */
33         const uint8_t *         compressed2_start;              /* start of compressed data */
34         uint32_t                compressed2_length;             /* length of compressed data */
35         int16_t *               uncompressed_start[8];  /* pointer to start of uncompressed data (up to 8 streams) */
36         uint32_t                uncompressed_offset;    /* current position in uncompressed data */
37         uint32_t                uncompressed_length;    /* length of uncompressed data */
38         int                     uncompressed_swap;              /* swap uncompressed sample data */
39         uint8_t                 custom_header[0x2a];    /* custom header */
40 };
41
42 /* ======================> flac_decoder */
43
44 int             flac_decoder_init(flac_decoder* decoder);
45 void            flac_decoder_free(flac_decoder* decoder);
46 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);
47 int             flac_decoder_decode_interleaved(flac_decoder* decoder, int16_t *samples, uint32_t num_samples, int swap_endian);
48 uint32_t        flac_decoder_finish(flac_decoder* decoder);
49
50 #endif /* __FLAC_H__ */