git subrepo pull --force deps/lightrec
[pcsx_rearmed.git] / deps / libretro-common / include / libchdr / flac.h
CommitLineData
3719602c
PC
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 "libchdr_zlib.h"
18#include "FLAC/ordinals.h"
19#include "FLAC/stream_decoder.h"
20
21/***************************************************************************
22 * TYPE DEFINITIONS
23 ***************************************************************************
24 */
25
26typedef struct _flac_decoder flac_decoder;
27struct _flac_decoder {
28 /* output state */
29 FLAC__StreamDecoder* decoder; /* actual encoder */
30 uint32_t sample_rate; /* decoded sample rate */
31 uint8_t channels; /* decoded number of channels */
32 uint8_t bits_per_sample; /* decoded bits per sample */
33 uint32_t compressed_offset; /* current offset in compressed data */
34 const FLAC__byte * compressed_start; /* start of compressed data */
35 uint32_t compressed_length; /* length of compressed data */
36 const FLAC__byte * compressed2_start; /* start of compressed data */
37 uint32_t compressed2_length; /* length of compressed data */
38 int16_t * uncompressed_start[8]; /* pointer to start of uncompressed data (up to 8 streams) */
39 uint32_t uncompressed_offset; /* current position in uncompressed data */
40 uint32_t uncompressed_length; /* length of uncompressed data */
41 int uncompressed_swap; /* swap uncompressed sample data */
42 uint8_t custom_header[0x2a]; /* custom header */
43};
44
45/* ======================> flac_decoder */
46
47void flac_decoder_init(flac_decoder* decoder);
48void flac_decoder_free(flac_decoder* decoder);
49int flac_decoder_reset(flac_decoder* decoder, uint32_t sample_rate, uint8_t num_channels, uint32_t block_size, const void *buffer, uint32_t length);
50int flac_decoder_decode_interleaved(flac_decoder* decoder, int16_t *samples, uint32_t num_samples, int swap_endian);
51uint32_t flac_decoder_finish(flac_decoder* decoder);
52
53/* codec-private data for the CDFL codec */
54typedef struct _cdfl_codec_data cdfl_codec_data;
55struct _cdfl_codec_data {
56 /* internal state */
57 int swap_endian;
58 flac_decoder decoder;
59#ifdef WANT_SUBCODE
60 zlib_codec_data subcode_decompressor;
61#endif
62 uint8_t* buffer;
63};
64
65/* cdfl compression codec */
66chd_error cdfl_codec_init(void* codec, uint32_t hunkbytes);
67void cdfl_codec_free(void* codec);
68chd_error cdfl_codec_decompress(void *codec, const uint8_t *src, uint32_t complen, uint8_t *dest, uint32_t destlen);
69
70#endif /* __FLAC_H__ */