Initial revision

This commit is contained in:
Josh Coalson
2000-12-10 04:09:52 +00:00
commit bb7f6b99d0
63 changed files with 12744 additions and 0 deletions

28
include/FLAC/all.h Normal file
View File

@@ -0,0 +1,28 @@
/* libFLAC - Free Lossless Audio Coder library
* Copyright (C) 2000 Josh Coalson
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef FLAC__ALL_H
#define FLAC__ALL_H
#include "encoder.h"
#include "file_decoder.h"
#include "ordinals.h"
#include "stream_decoder.h"
#endif

77
include/FLAC/encoder.h Normal file
View File

@@ -0,0 +1,77 @@
/* libFLAC - Free Lossless Audio Coder library
* Copyright (C) 2000 Josh Coalson
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef FLAC__ENCODER_H
#define FLAC__ENCODER_H
#include "format.h"
typedef enum {
FLAC__ENCODER_WRITE_OK = 0,
FLAC__ENCODER_WRITE_FATAL_ERROR = 1
} FLAC__EncoderWriteStatus;
typedef enum {
FLAC__ENCODER_OK,
FLAC__ENCODER_UNINITIALIZED,
FLAC__ENCODER_INVALID_NUMBER_OF_CHANNELS,
FLAC__ENCODER_INVALID_BITS_PER_SAMPLE,
FLAC__ENCODER_INVALID_SAMPLE_RATE,
FLAC__ENCODER_INVALID_BLOCK_SIZE,
FLAC__ENCODER_INVALID_QLP_COEFF_PRECISION,
FLAC__ENCODER_MID_SIDE_CHANNELS_MISMATCH,
FLAC__ENCODER_MID_SIDE_SAMPLE_SIZE_MISMATCH,
FLAC__ENCODER_BLOCK_SIZE_TOO_SMALL_FOR_LPC_ORDER,
FLAC__ENCODER_NOT_STREAMABLE,
FLAC__ENCODER_FRAMING_ERROR,
FLAC__ENCODER_FATAL_ERROR_WHILE_ENCODING,
FLAC__ENCODER_FATAL_ERROR_WHILE_WRITING, /* that is, the write_callback returned an error */
FLAC__ENCODER_MEMORY_ALLOCATION_ERROR
} FLAC__EncoderState;
struct FLAC__EncoderPrivate;
typedef struct {
/*
* none of these fields may change once FLAC__encoder_init() is called
*/
struct FLAC__EncoderPrivate *guts; /* must be 0 when passed to FLAC__encoder_init() */
FLAC__EncoderState state; /* must be FLAC__ENCODER_UNINITIALIZED when passed to FLAC__encoder_init() */
bool streamable_subset;
bool do_mid_side_stereo; /* 0 or 1; 1 only if channels==2 */
unsigned channels; /* must be <= FLAC__MAX_CHANNELS */
unsigned bits_per_sample; /* do not give the encoder wider data than what you specify here or bad things will happen! */
unsigned sample_rate;
unsigned blocksize;
unsigned max_lpc_order; /* 0 => encoder will not try general LPC, only fixed predictors; must be <= FLAC__MAX_LPC_ORDER */
unsigned qlp_coeff_precision; /* >= FLAC__MIN_QLP_COEFF_PRECISION, or 0 to let encoder select based on blocksize; */
/* qlp_coeff_precision+bits_per_sample must be < 32 */
bool do_qlp_coeff_prec_search; /* 0 => use qlp_coeff_precision, 1 => search around qlp_coeff_precision, take best */
bool do_exhaustive_model_search; /* 0 => use estimated bits per residual for scoring, 1 => generate all, take shortest */
unsigned rice_optimization_level; /* 0 => estimate Rice parameter based on residual variance, 1-8 => partition residual, use parameter for each */
} FLAC__Encoder;
FLAC__Encoder *FLAC__encoder_get_new_instance();
void FLAC__encoder_free_instance(FLAC__Encoder *encoder);
FLAC__EncoderState FLAC__encoder_init(FLAC__Encoder *encoder, FLAC__EncoderWriteStatus (*write_callback)(const FLAC__Encoder *encoder, const byte buffer[], unsigned bytes, unsigned samples, unsigned current_frame, void *client_data), void (*metadata_callback)(const FLAC__Encoder *encoder, const FLAC__StreamMetaData *metadata, void *client_data), void *client_data);
void FLAC__encoder_finish(FLAC__Encoder *encoder);
bool FLAC__encoder_process(FLAC__Encoder *encoder, const int32 *buf[], unsigned samples);
bool FLAC__encoder_process_interleaved(FLAC__Encoder *encoder, const int32 buf[], unsigned samples);
#endif

View File

@@ -0,0 +1,59 @@
/* libFLAC - Free Lossless Audio Coder library
* Copyright (C) 2000 Josh Coalson
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef FLAC__FILE_DECODER_H
#define FLAC__FILE_DECODER_H
#include "stream_decoder.h"
typedef enum {
FLAC__FILE_DECODER_OK,
FLAC__FILE_DECODER_SEEKING,
FLAC__FILE_DECODER_END_OF_FILE,
FLAC__FILE_DECODER_ERROR_OPENING_FILE,
FLAC__FILE_DECODER_MEMORY_ALLOCATION_ERROR,
FLAC__FILE_DECODER_SEEK_ERROR,
FLAC__FILE_DECODER_STREAM_ERROR,
FLAC__FILE_DECODER_UNINITIALIZED
} FLAC__FileDecoderState;
struct FLAC__FileDecoderPrivate;
typedef struct {
FLAC__FileDecoderState state; /* must be FLAC__FILE_DECODER_UNINITIALIZED when passed to FLAC__file_decoder_init() */
struct FLAC__FileDecoderPrivate *guts; /* must be 0 when passed to FLAC__file_decoder_init() */
} FLAC__FileDecoder;
FLAC__FileDecoder *FLAC__file_decoder_get_new_instance();
void FLAC__file_decoder_free_instance(FLAC__FileDecoder *decoder);
FLAC__FileDecoderState FLAC__file_decoder_init(
FLAC__FileDecoder *decoder,
const char *filename,
FLAC__StreamDecoderWriteStatus (*write_callback)(const FLAC__FileDecoder *decoder, const FLAC__FrameHeader *header, const int32 *buffer[], void *client_data),
void (*metadata_callback)(const FLAC__FileDecoder *decoder, const FLAC__StreamMetaData *metadata, void *client_data),
void (*error_callback)(const FLAC__FileDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data),
void *client_data
);
void FLAC__file_decoder_finish(FLAC__FileDecoder *decoder);
bool FLAC__file_decoder_process_whole_file(FLAC__FileDecoder *decoder);
bool FLAC__file_decoder_process_metadata(FLAC__FileDecoder *decoder);
bool FLAC__file_decoder_process_one_frame(FLAC__FileDecoder *decoder);
bool FLAC__file_decoder_process_remaining_frames(FLAC__FileDecoder *decoder);
bool FLAC__file_decoder_seek_absolute(FLAC__FileDecoder *decoder, uint64 sample);
#endif

315
include/FLAC/format.h Normal file
View File

@@ -0,0 +1,315 @@
/* libFLAC - Free Lossless Audio Coder library
* Copyright (C) 2000 Josh Coalson
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef FLAC__FORMAT_H
#define FLAC__FORMAT_H
#include "ordinals.h"
/* changing the following values to be higher will break the framing and hence the stream format, so DON'T! */
#define FLAC__MIN_BLOCK_SIZE (16u)
#define FLAC__MAX_BLOCK_SIZE (65535u)
#define FLAC__MAX_CHANNELS (8u)
/*NOTE: only up to 24 because of the current predictor coefficient quantization and the fact we use int32s for all work */
#define FLAC__MAX_BITS_PER_SAMPLE (24u)
/* the following is ((2 ** 20) - 1) div 10 */
#define FLAC__MAX_SAMPLE_RATE (1048570u)
#define FLAC__MAX_LPC_ORDER (32u)
#define FLAC__MIN_QLP_COEFF_PRECISION (5u)
/* changing this also means changing all of fixed.c and more, so DON'T! */
#define FLAC__MAX_FIXED_ORDER (4u)
#define FLAC__MAX_RICE_PARTITION_ORDER (15u)
#define FLAC__VERSION_STRING "0.2"
extern const unsigned FLAC__MAJOR_VERSION;
extern const unsigned FLAC__MINOR_VERSION;
extern const byte FLAC__STREAM_SYNC_STRING[4]; /* = "fLaC" */;
extern const unsigned FLAC__STREAM_SYNC; /* = 0x664C6143 */;
extern const unsigned FLAC__STREAM_SYNC_LEN; /* = 32 bits */;
/*****************************************************************************
*
* NOTE: Within the bitstream, all fixed-width numbers are big-endian coded.
* All numbers are unsigned unless otherwise noted.
*
*****************************************************************************/
typedef enum {
FLAC__METADATA_TYPE_ENCODING = 0
} FLAC__MetaDataType;
/*****************************************************************************
*
* 16: minimum blocksize (in samples) of all blocks in the stream
* 16: maximum blocksize (in samples) of all blocks in the stream
* 24: minimum framesize (in bytes) of all frames in the stream; 0 => unknown
* 24: maximum framesize (in bytes) of all frames in the stream; 0 => unknown
* 20: sample rate in Hz, 0 is invalid
* 3: (number of channels)-1
* 5: (bits per sample)-1
* 36: total samples, 0 => unknown
*---- -----------------
* 18 bytes total
*/
typedef struct {
unsigned min_blocksize, max_blocksize;
unsigned min_framesize, max_framesize;
unsigned sample_rate;
unsigned channels;
unsigned bits_per_sample;
uint64 total_samples;
} FLAC__StreamMetaData_Encoding;
extern const unsigned FLAC__STREAM_METADATA_ENCODING_MIN_BLOCK_SIZE_LEN; /* = 16 bits */
extern const unsigned FLAC__STREAM_METADATA_ENCODING_MAX_BLOCK_SIZE_LEN; /* = 16 bits */
extern const unsigned FLAC__STREAM_METADATA_ENCODING_MIN_FRAME_SIZE_LEN; /* = 24 bits */
extern const unsigned FLAC__STREAM_METADATA_ENCODING_MAX_FRAME_SIZE_LEN; /* = 24 bits */
extern const unsigned FLAC__STREAM_METADATA_ENCODING_SAMPLE_RATE_LEN; /* = 20 bits */
extern const unsigned FLAC__STREAM_METADATA_ENCODING_CHANNELS_LEN; /* = 3 bits */
extern const unsigned FLAC__STREAM_METADATA_ENCODING_BITS_PER_SAMPLE_LEN; /* = 5 bits */
extern const unsigned FLAC__STREAM_METADATA_ENCODING_TOTAL_SAMPLES_LEN; /* = 36 bits */
extern const unsigned FLAC__STREAM_METADATA_ENCODING_LENGTH; /* = 18 bytes */
/*****************************************************************************
*
* 1: =1 if this is the last meta-data block, else =0
* 7: meta-data type (c.f. FLAC__MetaDataType)
* 24: length (in bytes) of the block-specific data to follow
*---- -----------------
* 4 bytes total
*/
typedef struct {
FLAC__MetaDataType type;
bool is_last;
unsigned length; /* in bytes */
union {
FLAC__StreamMetaData_Encoding encoding;
} data;
} FLAC__StreamMetaData;
extern const unsigned FLAC__STREAM_METADATA_IS_LAST_LEN; /* = 1 bits */
extern const unsigned FLAC__STREAM_METADATA_TYPE_LEN; /* = 7 bits */
extern const unsigned FLAC__STREAM_METADATA_LENGTH_LEN; /* = 24 bits */
/*****************************************************************************/
typedef enum {
FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE = 0
} FLAC__EntropyCodingMethodType;
/*****************************************************************************
*
* 4: partition order => (2 ** order) subdivisions
*/
typedef struct {
unsigned order;
unsigned parameters[1 << FLAC__MAX_RICE_PARTITION_ORDER];
} FLAC__EntropyCodingMethod_PartitionedRice;
extern const unsigned FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ORDER_LEN; /* = 4 bits */
extern const unsigned FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_PARAMETER_LEN; /* = 4 bits */
/*****************************************************************************
*
* 2: entropy coding method:
* 00: partitioned rice coding
* 01-11: reserved
* ?: entropy coding method data
*/
typedef struct {
FLAC__EntropyCodingMethodType type;
union {
FLAC__EntropyCodingMethod_PartitionedRice partitioned_rice;
} data;
} FLAC__EntropyCodingMethod;
extern const unsigned FLAC__ENTROPY_CODING_METHOD_TYPE_LEN; /* = 2 bits */
/*****************************************************************************/
typedef enum {
FLAC__CHANNEL_ASSIGNMENT_INDEPENDENT = 0,
FLAC__CHANNEL_ASSIGNMENT_LEFT_SIDE = 1,
FLAC__CHANNEL_ASSIGNMENT_RIGHT_SIDE = 2,
FLAC__CHANNEL_ASSIGNMENT_MID_SIDE = 3
} FLAC__ChannelAssignment;
/*****************************************************************************
*
* 9: sync code '111111110'
* 3: blocksize in samples
* 000: get from stream header => implies constant blocksize throughout stream
* 001: 192 samples (AES/EBU) => implies constant blocksize throughout stream
* 010-101: 576 * (2^(2-n)) samples, i.e. 576/1152/2304/4608 => implies constant blocksize throughout stream
* 110: get 8 bit (blocksize-1) from end of header => variable blocksize throughout stream unless it's the last frame
* 111: get 16 bit (blocksize-1) from end of header => variable blocksize throughout stream unless it's the last frame
* 4: sample rate:
* 0000: get from stream header
* 0001-0011: reserved
* 0100: 8kHz
* 0101: 16kHz
* 0110: 22.05kHz
* 0111: 24kHz
* 1000: 32kHz
* 1001: 44.1kHz
* 1010: 48kHz
* 1011: 96kHz
* 1100: get 8 bit sample rate (in kHz) from end of header
* 1101: get 16 bit sample rate (in Hz) from end of header
* 1110: get 16 bit sample rate (in tens of Hz) from end of header
* 1111: invalid, to prevent sync-fooling string of 1s (use to check for erroneous sync)
* 4: channel assignment
* 0000-0111: (number of independent channels)-1. when == 0001, channel 0 is the left channel and channel 1 is the right
* 1000: left/side stereo : channel 0 is the left channel, channel 1 is the side(difference) channel
* 1001: right/side stereo: channel 0 is the side(difference) channel, channel 1 is the right channel
* 1010: mid/side stereo : channel 0 is the mid(average) channel, channel 1 is the side(difference) channel
* 1011-1111: reserved
* 3: sample size in bits
* 000: get from stream header
* 001: 8 bits per sample
* 010: 12 bits per sample
* 011: reserved
* 100: 16 bits per sample
* 101: 20 bits per sample
* 110: 24 bits per sample
* 111: reserved
* 1: zero pad, to prevent sync-fooling string of 1s (use to check for erroneous sync)
* ?: if(variable blocksize)
* 8-56: 'UTF-8' coded sample number (decoded number is 0-36 bits) (use to check for erroneous sync)
* else
* 8-48: 'UTF-8' coded frame number (decoded number is 0-31 bits) (use to check for erroneous sync)
* ?: if(blocksize bits == 11x)
* 8/16 bit (blocksize-1)
* ?: if(sample rate bits == 11xx)
* 8/16 bit sample rate
* 8: CRC-8 (polynomial = x^8 + x^2 + x + 1) of everything before the crc, including the sync code
*/
typedef struct {
unsigned blocksize; /* in samples */
unsigned sample_rate; /* in Hz */
unsigned channels;
FLAC__ChannelAssignment channel_assignment;
unsigned bits_per_sample;
union {
uint32 frame_number;
uint64 sample_number;
} number;
} FLAC__FrameHeader;
extern const unsigned FLAC__FRAME_HEADER_SYNC; /* = 0x1fe */
extern const unsigned FLAC__FRAME_HEADER_SYNC_LEN; /* = 9 bits */
extern const unsigned FLAC__FRAME_HEADER_BLOCK_SIZE_LEN; /* = 3 bits */
extern const unsigned FLAC__FRAME_HEADER_SAMPLE_RATE_LEN; /* = 4 bits */
extern const unsigned FLAC__FRAME_HEADER_CHANNEL_ASSIGNMENT_LEN; /* = 4 bits */
extern const unsigned FLAC__FRAME_HEADER_BITS_PER_SAMPLE_LEN; /* = 3 bits */
extern const unsigned FLAC__FRAME_HEADER_ZERO_PAD_LEN; /* = 1 bit */
extern const unsigned FLAC__FRAME_HEADER_CRC8_LEN; /* = 8 bits */
/*****************************************************************************/
typedef enum {
FLAC__SUBFRAME_TYPE_CONSTANT = 0,
FLAC__SUBFRAME_TYPE_VERBATIM = 1,
FLAC__SUBFRAME_TYPE_FIXED = 2,
FLAC__SUBFRAME_TYPE_LPC = 3
} FLAC__SubframeType;
/*****************************************************************************
*
* n: constant value for signal; n = frame's bits-per-sample
*/
typedef struct {
int32 value;
} FLAC__SubframeHeader_Constant;
/*****************************************************************************
*
* n*i: unencoded signal; n = frame's bits-per-sample, i = frame's blocksize
*/
/* There is no (trivial) for structure FLAC__SubframeHeader_Verbatim */
/*****************************************************************************
*
* n: unencoded warm-up samples (n = fixed-predictor order * bits per sample)
* ?: entropy coding method info
* ?: encoded residual ((blocksize minus fixed-predictor order) samples)
* The order is stored in the main subframe header
*/
typedef struct {
FLAC__EntropyCodingMethod entropy_coding_method;
unsigned order;
int32 warmup[FLAC__MAX_FIXED_ORDER];
} FLAC__SubframeHeader_Fixed;
/*****************************************************************************
*
* n: unencoded warm-up samples (n = lpc order * bits per sample)
* 4: (qlp coeff precision in bits)-1 (1111 = invalid, use to check for erroneous sync)
* 5: qlp shift needed in bits (signed)
* n: unencoded predictor coefficients (n = lpc order * qlp coeff precision)
* ?: entropy coding method info
* ?: encoded residual ((blocksize minus lpc order) samples)
* The order is stored in the main subframe header
*/
typedef struct {
FLAC__EntropyCodingMethod entropy_coding_method;
unsigned order;
unsigned qlp_coeff_precision;
int quantization_level;
int32 qlp_coeff[FLAC__MAX_LPC_ORDER];
int32 warmup[FLAC__MAX_LPC_ORDER];
} FLAC__SubframeHeader_LPC;
extern const unsigned FLAC__SUBFRAME_HEADER_LPC_QLP_COEFF_PRECISION_LEN; /* = 4 bits */
extern const unsigned FLAC__SUBFRAME_HEADER_LPC_QLP_SHIFT_LEN; /* = 5 bits */
/*****************************************************************************
*
* 8: subframe type
* xxxxxxx1: invalid, to prevent sync-fooling string of 1s (use to check for erroneous sync)
* 00000000: constant value
* 00000010: verbatim
* 000001x0: reserved
* 00001xx0: reserved
* 0001xxx0: fixed predictor, xxx=order <= 4, else reserved
* 001xxxx0: reserved
* 01xxxxx0: lpc, xxxxx=order-1
* 1xxxxxxx: invalid, to prevent sync-fooling string of 1s (use to check for erroneous sync)
* ?: subframe-specific header (c.f. FLAC__SubframeHeader_*)
*/
typedef struct {
FLAC__SubframeType type;
union {
FLAC__SubframeHeader_Constant constant;
FLAC__SubframeHeader_Fixed fixed;
FLAC__SubframeHeader_LPC lpc;
} data; /* data will be undefined for FLAC__SUBFRAME_TYPE_VERBATIM */
} FLAC__SubframeHeader;
extern const unsigned FLAC__SUBFRAME_HEADER_TYPE_CONSTANT; /* = 0x00 */
extern const unsigned FLAC__SUBFRAME_HEADER_TYPE_VERBATIM; /* = 0x02 */
extern const unsigned FLAC__SUBFRAME_HEADER_TYPE_FIXED; /* = 0x10 */
extern const unsigned FLAC__SUBFRAME_HEADER_TYPE_LPC; /* = 0x40 */
extern const unsigned FLAC__SUBFRAME_HEADER_TYPE_LEN; /* = 8 bits */
/*****************************************************************************/
#endif

75
include/FLAC/ordinals.h Normal file
View File

@@ -0,0 +1,75 @@
/* libFLAC - Free Lossless Audio Coder library
* Copyright (C) 2000 Josh Coalson
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef FLAC__ORDINALS_H
#define FLAC__ORDINALS_H
#ifdef bool
#undef bool
#endif
#ifdef true
#undef true
#endif
#ifdef false
#undef false
#endif
#ifdef byte
#undef byte
#endif
#ifdef int16
#undef int16
#endif
#ifdef uint16
#undef uint16
#endif
#ifdef int32
#undef int32
#endif
#ifdef uint32
#undef uint32
#endif
#ifdef int64
#undef int64
#endif
#ifdef uint64
#undef uint64
#endif
#ifdef real
#undef real
#endif
#define true 1
#define false 0
typedef int bool;
typedef unsigned char byte;
typedef short int16;
typedef unsigned short uint16;
typedef int int32;
typedef unsigned int uint32;
#if defined _WIN32 && !defined __CYGWIN__
typedef __int64 int64;
typedef unsigned __int64 uint64;
#else
typedef long long int int64;
typedef unsigned long long uint64;
#endif
typedef double real;
#endif

View File

@@ -0,0 +1,83 @@
/* libFLAC - Free Lossless Audio Coder library
* Copyright (C) 2000 Josh Coalson
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef FLAC__STREAM_DECODER_H
#define FLAC__STREAM_DECODER_H
#include "format.h"
typedef enum {
FLAC__STREAM_DECODER_SEARCH_FOR_METADATA,
FLAC__STREAM_DECODER_READ_METADATA,
FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC,
FLAC__STREAM_DECODER_READ_FRAME,
FLAC__STREAM_DECODER_RESYNC_IN_HEADER,
FLAC__STREAM_DECODER_END_OF_STREAM,
FLAC__STREAM_DECODER_ABORTED,
FLAC__STREAM_DECODER_UNPARSEABLE_STREAM,
FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR,
FLAC__STREAM_DECODER_UNINITIALIZED
} FLAC__StreamDecoderState;
typedef enum {
FLAC__STREAM_DECODER_READ_CONTINUE,
FLAC__STREAM_DECODER_READ_END_OF_STREAM,
FLAC__STREAM_DECODER_READ_ABORT
} FLAC__StreamDecoderReadStatus;
typedef enum {
FLAC__STREAM_DECODER_WRITE_CONTINUE,
FLAC__STREAM_DECODER_WRITE_ABORT
} FLAC__StreamDecoderWriteStatus;
typedef enum {
FLAC__STREAM_DECODER_ERROR_LOST_SYNC
} FLAC__StreamDecoderErrorStatus;
struct FLAC__StreamDecoderPrivate;
typedef struct {
/* these fields are read-only and valid as of the last write_callback() */
unsigned channels;
FLAC__ChannelAssignment channel_assignment;
unsigned bits_per_sample;
unsigned sample_rate; /* in Hz */
unsigned blocksize; /* in samples (per channel) */
FLAC__StreamDecoderState state; /* must be FLAC__STREAM_DECODER_UNINITIALIZED when passed to FLAC__stream_decoder_init() */
struct FLAC__StreamDecoderPrivate *guts; /* must be 0 when passed to FLAC__stream_decoder_init() */
} FLAC__StreamDecoder;
FLAC__StreamDecoder *FLAC__stream_decoder_get_new_instance();
void FLAC__stream_decoder_free_instance(FLAC__StreamDecoder *decoder);
FLAC__StreamDecoderState FLAC__stream_decoder_init(
FLAC__StreamDecoder *decoder,
FLAC__StreamDecoderReadStatus (*read_callback)(const FLAC__StreamDecoder *decoder, byte buffer[], unsigned *bytes, void *client_data),
FLAC__StreamDecoderWriteStatus (*write_callback)(const FLAC__StreamDecoder *decoder, const FLAC__FrameHeader *header, const int32 *buffer[], void *client_data),
void (*metadata_callback)(const FLAC__StreamDecoder *decoder, const FLAC__StreamMetaData *metadata, void *client_data),
void (*error_callback)(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data),
void *client_data
);
void FLAC__stream_decoder_finish(FLAC__StreamDecoder *decoder);
bool FLAC__stream_decoder_flush(FLAC__StreamDecoder *decoder);
bool FLAC__stream_decoder_reset(FLAC__StreamDecoder *decoder);
bool FLAC__stream_decoder_process_whole_stream(FLAC__StreamDecoder *decoder);
bool FLAC__stream_decoder_process_metadata(FLAC__StreamDecoder *decoder);
bool FLAC__stream_decoder_process_one_frame(FLAC__StreamDecoder *decoder);
bool FLAC__stream_decoder_process_remaining_frames(FLAC__StreamDecoder *decoder);
#endif